A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: a kibbutz is told apart from the moshav: a dining hall by the water tower, row houses, a farm yard of sheds (refs #32) (#820)
Beri8d46f9cba0e7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 902373225..d837d3a1a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,13 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBThe checks file is now written in the bundle cache and copied beside the shipped bundles.### Changed+- A kibbutz no longer looks like a moshav or a moshava (refs #32). The five kibbutz game settlements and the kibbutz rows+ of the 1948 localities get a dining hall near the heart, opposite the water tower (white, flat roof, a raised+ clerestory), long one-storey members' houses under red tiles, and grey-roofed farm sheds on one side, the farm yard.+ The plan follows Kauffmann's kibbutz layout: the dining hall at the centre, the farm kept apart from the houses+ (he.wiki "גן הנוף הקיבוצי"). Nahalal's moshav ring and the moshavot are unchanged (their renders are pixel-identical),+ and no other place moves; inside a kibbutz the hall's lot can take a plot. Yad Mordechai has no hall: no free ground is left near its heart, and a hall pushed to the edge+ would take its houses.- The GDD game has its twelve cities (GDD Phase 3 PR 1, refs #732, #383; R-CITY-006, R-CITY-007): `content/cities.yaml`holds the `city` and `town` rows of the 1948 settlements, each starting from its census population of 8 November 1948(CBS Statistical Abstract No. 14, Table 11; Zikhron Ya'akov from No. 3; Rosh Pinna from Hebrew Wikipedia, as the ownerdiff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.csnew file mode 100644index 000000000..7c4c105bd--- /dev/null+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs@@ -0,0 +1,113 @@+#nullable enable+using UnityEngine;++namespace Statecraft.Game.Map.Kits+{+ /// <summary>What a kibbutz's plot holds (#32): a member's house or a farm shed (None: not a kibbutz building).</summary>+ enum KibbutzPart : byte { None, House, Shed }++ /// <summary>The kibbutz kit (issue #32): a kibbutz no longer shares the moshava's houses, so a kibbutz and a moshav (Nahalal's+ /// ring) or a moshava read as different places. The basis is Richard Kauffmann's plans as the Hebrew Wikipedia's "גן הנוף+ /// הקיבוצי" sums them up (https://he.wikipedia.org/wiki/גן_הנוף_הקיבוצי, checked 2026-10-16): the farm area kept apart from+ /// the living area ("ההפרדה בין אזור המשק לאזור המגורים"), the farm about a third of the kibbutz's ground, the dining hall at+ /// the centre ("חדר האוכל, במרכזו של הקיבוץ"), and in the early kibbutzim the members' houses built in rows, one storey+ /// ("הוקמו מבני המגורים בשורות", "בני קומה אחת"). The sizes are modelling choices that fit the moshava's plot lattice, on+ /// which a kibbutz is still laid out, so its plots are where they were.</summary>+ public static partial class SettlementKits+ {+ /// <summary>The dining hall's wall height in storeys: taller than the one-storey houses round it (a hall's high room).</summary>+ const float KibbutzHallStoreys = 1.6f;++ /// <summary>The dining hall's footprint (real m, at the house scale) and the spots it tries in turn (shares of the radius+ /// from the heart): across the heart from the water tower (which stands at +0.35, -0.2), each far enough from it that+ /// their lots do not meet.</summary>+ const float KibbutzHallW = 8.4f, KibbutzHallD = 6.4f;+ static readonly Vector2[] KibbutzHallAt = { new Vector2(-0.35f, 0.25f), new Vector2(-0.38f, -0.05f), new Vector2(0f, 0.45f) };++ /// <summary>The farm yard: plots farther than this share of the radius from the heart, within 60 degrees either side of+ /// the farm's bearing: a third of the directions, about a quarter of the ring's area (the source gives the farm about a+ /// third of the ground; a modelling choice that keeps most plots for houses in a kibbutz of a few plots).</summary>+ const float FarmYardFromT = 0.45f;++ /// <summary>Running counts for <see cref="Result.KibbutzHalls"/> and <see cref="Result.FarmSheds"/> during a Build.</summary>+ [System.ThreadStatic] static int kibbutzHalls, farmSheds;++ /// <summary>Whether a kibbutz plot <paramref name="offset"/> from the heart (t: distance over the radius) lies in its farm+ /// yard. The farm's bearing is the kibbutz's grid angle, so the yard is one side of the place, not a ring.</summary>+ static bool FarmYard(Settlement s, Vector2 offset, float t)+ {+ if (t <= FarmYardFromT) return false;+ float a = GridYaw(s.Id) * Mathf.Deg2Rad;+ return Vector2.Dot(offset.normalized, new Vector2(Mathf.Cos(a), Mathf.Sin(a))) > 0.5f;+ }++ /// <summary>A kibbutz building of <paramref name="part"/>, <paramref name="u"/> and <paramref name="v"/> (0-1) picking its+ /// size, at scale <paramref name="m"/>; its lot is the half diagonal times <paramref name="lotK"/>. Real sizes: a+ /// member's house 7.5-9 x 4.6-5.4 m (a long, narrow row house), a farm shed 7.8-9.4 x 6.2-7.2 m, one storey. Both fit+ /// the moshava's 11.5 x 9.8 m plot with its jitter and yaw.</summary>+ static Spec KibbutzSpec(KibbutzPart part, float u, float v, float m, float lotK)+ {+ bool shed = part == KibbutzPart.Shed;+ float w = shed ? Mathf.Lerp(7.8f, 9.4f, u) : Mathf.Lerp(7.5f, 9f, u), d = shed ? Mathf.Lerp(6.2f, 7.2f, v) : Mathf.Lerp(4.6f, 5.4f, v);+ return new Spec { w = w * m, d = d * m, h = 3.3f * m, storeys = 1, part = part, lotR = 0.5f * Mathf.Sqrt(w * w + d * d) * m * lotK };+ }++ /// <summary>What stands on a kibbutz plot: a shed in the farm yard, else the member's house <paramref name="house"/> (its+ /// size picks the shed's within the shed's range, so no extra draw moves the place's stream).</summary>+ static Spec KibbutzPlot(Settlement s, Vector2 offset, float t, Spec house, float m, float lotK)+ {+ if (!FarmYard(s, offset, t)) return house;+ float u = Mathf.InverseLerp(7.5f * m, 9f * m, house.w), v = Mathf.InverseLerp(4.6f * m, 5.4f * m, house.d);+ return KibbutzSpec(KibbutzPart.Shed, u, v, m, lotK);+ }++ /// <summary>A kibbutz's dining hall (a landmark, placed with the water tower before any house): white, a flat roof and+ /// a raised clerestory, 1.6 storeys, at the house scale, on a free spot near one of+ /// <see cref="KibbutzHallAt"/> round <paramref name="heart"/> (radius <paramref name="R"/>), or none. Returns how many were built (0 or 1).</summary>+ static int DiningHall(string owner, Vector2 heart, float R, KitGround ground, KitMesh km, Lots lots)+ {+ float m = KitScale.Houses, w = KitScale.Houses * KibbutzHallW, d = KitScale.Houses * KibbutzHallD, h = KibbutzHallStoreys * 3.3f * m;+ // One ring of the search only (half a lot from the spot): a hall pushed to the edge would no longer be the heart, and+ // would take the ground of the few houses a small kibbutz has (Yad Mordechai, with no free ground near its heart).+ var p = Vector2.zero; bool found = false;+ foreach (var at in KibbutzHallAt)+ if (found = Claim(lots, heart + at * R, 0.5f * Mathf.Sqrt(w * w + d * d), owner, ground, out p, rings: 1)) break;+ if (!found) return 0;+ float yaw = GridYaw(owner);+ var (bottom, top) = GroundSpan(p, yaw, w, d, ground, m);+ var wall = WhitePlaster; var roof = C(0.86f, 0.85f, 0.82f);+ km.Box(p.x, p.y, yaw, w, d, bottom, top, h, wall, roof, Facade.Plain, m);+ km.Box(p.x, p.y, yaw, w * 0.8f, d * 0.4f, top + h - 0.3f * m, top + h, 1.2f * m, wall, roof, Facade.Plain, m);+ Record(owner, "dining_hall", p, yaw, w, d, h, wall);+ kibbutzHalls++;+ return 1;+ }++ /// <summary>Draws a kibbutz building: a member's house whitewashed under a red tiled gable, a farm shed with weathered+ /// walls under a low grey roof (corrugated sheet). Exactly two colour jitters whatever the part (a 1948 locality's+ /// stream relies on it). Returns the wall colour.</summary>+ static Color32 KibbutzBuilding(KitMesh km, Vector2 p, float yaw, Spec b, float bottom, float top, float m, ref KitRandom rnd)+ {+ switch (b.part)+ {+ case KibbutzPart.Shed:+ {+ var wall = Jitter(C(0.80f, 0.76f, 0.68f), ref rnd, 0.04f);+ var roof = Jitter(C(0.47f, 0.48f, 0.49f), ref rnd, 0.05f);+ km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Plain, m, roofed: true);+ km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.3f, roof, wall);+ farmSheds++;+ return wall;+ }+ default:+ {+ var wall = Jitter(C(0.93f, 0.92f, 0.87f), ref rnd, 0.03f);+ var roof = Jitter(C(0.74f, 0.31f, 0.20f), ref rnd, 0.08f);+ km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Village, m, roofed: true);+ km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.42f, roof, wall);+ return wall;+ }+ }+ }+ }+}diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs.meta b/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs.metanew file mode 100644index 000000000..f4119d09e--- /dev/null+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: c9695a2fad634b9c80aabec1ee8415acdiff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.csindex a09178948..74dc53136 100644--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs@@ -29,7 +29,9 @@ namespace Statecraft.Game.Map.Kits{case Archetype.OldTown: return Mosque(s.Id, heart, ground, km, lots, ref rnd, 1.2f);case Archetype.ArabTown: return Mosque(s.Id, heart, ground, km, lots, ref rnd, 1f);- case Archetype.Moshava: return WaterTower(s.Id, heart + new Vector2(R * 0.35f, -R * 0.2f), ground, km, lots);+ case Archetype.Moshava:+ return WaterTower(s.Id, heart + new Vector2(R * 0.35f, -R * 0.2f), ground, km, lots)+ + (s.Type == "kibbutz" ? DiningHall(s.Id, heart, R, ground, km, lots) : 0); // #32default: return 0;}}diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.csindex 02c2807ee..45d3d69f8 100644--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.cs+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.cs@@ -105,6 +105,8 @@ namespace Statecraft.Game.Map.Kitspublic List<(string name, Mesh mesh)> Tiles = new List<(string, Mesh)>();public List<(Vector2 centre, float radius, string id)> Claimed = new List<(Vector2, float, string)>();public int LocalityBuildings, Camps, Tents;+ /// <summary>Kibbutz dining halls and farm sheds built (#32), the game settlements' and the localities' together.</summary>+ public int KibbutzHalls, FarmSheds;/// <summary>Landmarks each game settlement built (SettlementKits.Landmarks.cs: a city's own, else its archetype's).</summary>public Dictionary<string, int> TownLandmarks = new Dictionary<string, int>();}@@ -118,6 +120,7 @@ namespace Statecraft.Game.Map.Kitspublic static Result Build(IReadOnlyList<Settlement> towns, IReadOnlyList<Settlement> localities, IReadOnlyList<Localities.Area> camps,KitGround ground, Dictionary<string, Bounds[]>? columns = null){+ kibbutzHalls = farmSheds = 0;var merged = new HashSet<string>();foreach (var s in localities) merged.Add(s.Id);var order = new List<Settlement>(towns); order.AddRange(localities);@@ -229,6 +232,7 @@ namespace Statecraft.Game.Map.Kits}foreach (var kv in tiles) result.Tiles.Add(($"Localities {kv.Key.Item1},{kv.Key.Item2}", kv.Value.ToMesh($"localities_{kv.Key.Item1}_{kv.Key.Item2}")));result.Claimed = lots.List.ConvertAll(l => (centre: l.c, radius: l.r, id: l.id));+ result.KibbutzHalls = kibbutzHalls; result.FarmSheds = farmSheds;return result;}@@ -313,9 +317,9 @@ namespace Statecraft.Game.Map.Kits/// <summary>A landmark's spot (review N2): the dry spot nearest <paramref name="want"/> (rings out to four radii) that no/// lot of any town already holds; claimed for <paramref name="owner"/>. False, and nothing claimed, when there is none:/// the landmark is then left out rather than overlapping a bigger neighbour.</summary>- static bool Claim(Lots lots, Vector2 want, float r, string owner, KitGround ground, out Vector2 at)+ static bool Claim(Lots lots, Vector2 want, float r, string owner, KitGround ground, out Vector2 at, int rings = 8){- for (int ring = 0; ring <= 8; ring++)+ for (int ring = 0; ring <= rings; ring++){int around = ring == 0 ? 1 : 8 * ring;for (int k = 0; k < around; k++)@@ -347,8 +351,11 @@ namespace Statecraft.Game.Map.KitsOldHouse,/// <summary>An Arab town's or village's stone or mud-brick house (100x).</summary>Village,- /// <summary>A moshava's, kibbutz's or moshav's red-roofed house (100x).</summary>+ /// <summary>A moshava's or moshav's red-roofed house (100x).</summary>Moshava,+ /// <summary>A kibbutz (#32): members' houses in rows, the dining hall at the heart, farm sheds in the farm yard (100x;+ /// the moshava's plot lattice, <see cref="KibbutzPart"/>).</summary>+ Kibbutz,/// <summary>A Templer house of Haifa's German Colony: stone, red roof (100x; placed along its avenue, not on a lattice).</summary>Templer,}@@ -406,7 +413,7 @@ namespace Statecraft.Game.Map.Kitsdefault:return s.Type == "town" && KitPopulation.Of(s.Id) >= LargeMoshava? new List<Lattice> { new Lattice(Style.TownBlock, yaw, 0), new Lattice(Style.Moshava, yaw, 1) }- : new List<Lattice> { new Lattice(Style.Moshava, yaw, 0) };+ : new List<Lattice> { new Lattice(s.Type == "kibbutz" ? Style.Kibbutz : Style.Moshava, yaw, 0) };}}@@ -532,6 +539,8 @@ namespace Statecraft.Game.Map.Kitsvar spec = Pick(L.Style, t, ref rnd, g.scale);// Inside Jerusalem's walls, one or two storeys: the walls and the Dome of the Rock stand above the roofs.if (s.Id == "jerusalem" && L.Style == Style.OldHouse && spec.storeys > 2) { spec.storeys = 2; spec.h = 2f * 3.3f * g.scale; }+ // A kibbutz (#32): the farm yard's plots hold sheds.+ if (L.Style == Style.Kibbutz) spec = KibbutzPlot(s, p0 - centre, t, spec, g.scale, 1f);float yaw = L.Yaw + (g.jitter > 0f ? rnd.Range(-4f, 4f) : 0f);ulong detail = rnd.Next();if (!build) continue;@@ -601,7 +610,7 @@ namespace Statecraft.Game.Map.Kitsfor (int i = 0; i < ScatterTries; i++){float r = reach * Mathf.Sqrt(srnd.Value()), ang = srnd.Range(0f, 2f * Mathf.PI);- var b = Pick(arch, r / R, ref srnd, m);+ var b = Pick(arch, r / R, ref srnd, m, s.Type == "kibbutz");b.lotR = 0.5f * Mathf.Sqrt(b.w * b.w + b.d * b.d); // the whole footprint, as a plot's (round 1's lot let a corner reach a road)float yaw = arch == Archetype.Moshava || arch == Archetype.WhiteCity ? GridYaw(s.Id) + srnd.Range(-4f, 4f) : srnd.Range(0f, 90f);spots.Add((r, i, centre + new Vector2(Mathf.Cos(ang), Mathf.Sin(ang)) * r, yaw, b, srnd.Next()));@@ -623,6 +632,7 @@ namespace Statecraft.Game.Map.Kits{if (!site[k]) continue;var (r, _, p, yaw, full, detail) = spots[k];+ if (s.Type == "kibbutz") full = KibbutzPlot(s, p - centre, r / R, full, m, 1f);var b = Shrink(full, shrink);if (!lots.Free(p, b.lotR) || ground.OnRoute(p, b.lotR)) continue;if (ground.Slope(p.x, p.y, b.w) > (hillTown ? 0.6f : 0.35f)) continue;@@ -660,7 +670,7 @@ namespace Statecraft.Game.Map.Kits};static Spec Shrink(Spec b, float k) =>- k >= 1f ? b : new Spec { w = b.w * k, d = b.d * k, h = b.h, storeys = b.storeys, lotR = b.lotR * k };+ k >= 1f ? b : new Spec { w = b.w * k, d = b.d * k, h = b.h, storeys = b.storeys, lotR = b.lotR * k, part = b.part };/// <summary>How far (m) a new town's buildings keep back from the sea: the beach strip (ScShore's ScBeachM, 900 m on@@ -715,7 +725,7 @@ namespace Statecraft.Game.Map.Kits/// shore; the others get a seeded angle).</summary>static float GridYaw(string id) => id == "tel_aviv" ? 20f : id == "haifa" ? 35f : new KitRandom(id, 7).Range(0f, 90f);- struct Spec { public float w, d, h, lotR; public int storeys; }+ struct Spec { public float w, d, h, lotR; public int storeys; public KibbutzPart part; }/// <summary>A plot's building: real size and storeys by style and by t (0 at the heart, 1 at the footprint's edge),/// times the scale <paramref name="m"/>. Every size fits its lattice's plot with a street to spare.</summary>@@ -756,6 +766,10 @@ namespace Statecraft.Game.Map.Kitsw = rnd.Range(8.5f, 10.5f); d = rnd.Range(7.5f, 9f);storeys = 2;break;+ case Style.Kibbutz:+ // The moshava's three draws (size, size, storeys), so the plots are built or left as before.+ w = rnd.Range(0f, 1f); d = rnd.Range(0f, 1f); rnd.Chance(0.15f);+ return KibbutzSpec(KibbutzPart.House, w, d, m, 1f);default:w = rnd.Range(7.5f, 10f); d = rnd.Range(6f, 7.8f);storeys = rnd.Chance(0.15f) ? 2 : 1;@@ -873,6 +887,12 @@ namespace Statecraft.Game.Map.KitsRecord(id, "building", p, yaw, b.w, b.d, b.h, wall);break;}+ case Style.Kibbutz:+ {+ var wall = KibbutzBuilding(km, p, yaw, b, bottom, top, m, ref rnd);+ Record(id, "building", p, yaw, b.w, b.d, b.h, wall);+ break;+ }case Style.Templer:{var wall = Jitter(C(0.86f, 0.79f, 0.66f), ref rnd, 0.04f);@@ -1059,6 +1079,7 @@ namespace Statecraft.Game.Map.Kitsif (phase == Phase.Houses) target -= landmarksBefore;int attempts = target * 30;bool ring = s.Type == "moshav"; // Nahalal's ring of farmsteads round the public buildings+ bool kibbutz = s.Type == "kibbutz" && !mixed; // #32: a kibbutz's houses and farm shedsfor (int i = 0; i < attempts && placed < target; i++){// The disc grows slowly when the sea or a neighbour eats into it, so the count stays tied to the population.@@ -1071,7 +1092,8 @@ namespace Statecraft.Game.Map.Kits// A mixed locality (Nesher, owner ruling 2026-10-12): Arab village houses on its west side, Jewish ones on its// east, side by side.var a2 = mixed ? (p.x < centre.x ? Archetype.ArabTown : Archetype.Moshava) : arch;- var b = Pick(a2, t, ref rnd, m);+ var b = Pick(a2, t, ref rnd, m, kibbutz);+ if (kibbutz) b = KibbutzPlot(s, p - centre, t, b, m, LocalityLotK);if (!Free(p, b.lotR) || ground.OnRoute(p, b.lotR)) continue; // off the railways and roads too// A 1948 locality's house (only localities build houses with no ignoreCellsOf) keeps off the grid's edge midpoints.if (phase == Phase.Houses && ignoreCellsOf == null && ground.OnGridMark(p, b.lotR)) continue;@@ -1119,8 +1141,9 @@ namespace Statecraft.Game.Map.Kitsdefault: return 0;}case Archetype.Moshava:- return (Localities.LandmarkOf(s.Id) ?? Landmark.WaterTower) == Landmark.WaterTower- ? WaterTower(s.Id, At(heart + new Vector2(R * 0.35f, -R * 0.2f)), ground, km, lots, towerK) : 0;+ return ((Localities.LandmarkOf(s.Id) ?? Landmark.WaterTower) == Landmark.WaterTower+ ? WaterTower(s.Id, At(heart + new Vector2(R * 0.35f, -R * 0.2f)), ground, km, lots, towerK) : 0)+ + (s.Type == "kibbutz" ? DiningHall(s.Id, heart, R, ground, km, lots) : 0); // #32default: return 0;}}@@ -1177,8 +1200,12 @@ namespace Statecraft.Game.Map.Kitsreturn Mathf.Clamp(Mathf.RoundToInt(area * share / lot), 6, 900);}- /// <summary>A locality's building, by archetype (promo-villages).</summary>- static Spec Pick(Archetype arch, float t, ref KitRandom rnd, float m)+ /// <summary>A locality's lot over its building's half diagonal (Pick's moshava gap, 2.4, times 0.72).</summary>+ const float LocalityLotK = 2.4f * 0.72f;++ /// <summary>A locality's building, by archetype (promo-villages); a kibbutz's member's house when+ /// <paramref name="kibbutz"/> (#32), from the same draws.</summary>+ static Spec Pick(Archetype arch, float t, ref KitRandom rnd, float m, bool kibbutz = false){float w, d; int storeys;switch (arch)@@ -1202,6 +1229,7 @@ namespace Statecraft.Game.Map.Kitsw = rnd.Range(8f, 12f); d = rnd.Range(6.5f, 9f);storeys = rnd.Chance(0.15f) ? 2 : 1;if (rnd.Chance(0.06f)) { w = rnd.Range(18f, 28f); d = rnd.Range(8f, 10f); } // a barn, a dining hall, a packing house+ if (kibbutz) return KibbutzSpec(KibbutzPart.House, Mathf.InverseLerp(8f, 12f, w), Mathf.InverseLerp(6.5f, 9f, d), m, LocalityLotK);break;}float storeyM = 3.3f;@@ -1272,6 +1300,7 @@ namespace Statecraft.Game.Map.Kits}default:{+ if (b.part != KibbutzPart.None) return KibbutzBuilding(km, p, yaw, b, bottom, top, m, ref rnd);var wall = Jitter(C(0.92f, 0.89f, 0.82f), ref rnd, 0.04f);var roof = Jitter(C(0.74f, 0.31f, 0.20f), ref rnd, 0.08f);km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Village, m, roofed: true);diff --git a/unity/Assets/Tests/EditMode/KibbutzKitTests.cs b/unity/Assets/Tests/EditMode/KibbutzKitTests.csnew file mode 100644index 000000000..d88f895c8--- /dev/null+++ b/unity/Assets/Tests/EditMode/KibbutzKitTests.cs@@ -0,0 +1,77 @@+#nullable enable+using System.Collections.Generic;+using System.Linq;+using NUnit.Framework;+using Statecraft.Game.Map;+using Statecraft.Game.Map.Kits;+using UnityEditor.SceneManagement;+using UnityEngine;++/// <summary>The kibbutz kit (#32, SettlementKits.Kibbutz.cs): a kibbutz is told apart from a moshav or a moshava by its dining+/// hall at the heart and the farm sheds of its farm yard; the moshavim and moshavot keep their houses.</summary>+public class KibbutzKitTests+{+ [TearDown]+ public void Restore()+ {+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ VisualToggles.Clear();+ KitScale.Reset();+ }++ static MapScene OpenMap()+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();+ return map;+ }++ /// <summary>A kibbutz game settlement has at most one dining hall, near its heart (within 0.65 of the radius), and at least+ /// four of the five have one (a hall that finds no ground near the heart is left out, not pushed to the edge); no other game+ /// settlement has one: Nahalal (the moshav) and the moshavot have none.</summary>+ [Test]+ public void EveryKibbutzHasOneDiningHallAtItsHeart()+ {+ var map = OpenMap();+ TownCensusTests.Census(map, out var placed, out var g);+ var bad = new List<string>();+ int kibbutzim = 0, withHall = 0;+ foreach (var s in map.Settlements)+ {+ var halls = placed.Where(p => p.Id == s.Id && p.Kind == "dining_hall").ToList();+ if (s.Type != "kibbutz") { if (halls.Count > 0) bad.Add($"{s.Id} ({s.Type}): {halls.Count} dining halls"); continue; }+ kibbutzim++;+ if (halls.Count > 1) bad.Add($"{s.Id}: {halls.Count} dining halls");+ if (halls.Count != 1) { TestContext.WriteLine($"{s.Id}: no dining hall"); continue; }+ withHall++;+ var w = map.Frame.ToWorld(s.Lon, s.Lat, 0);+ float t = (halls[0].C - new Vector2(w.x, w.z)).magnitude / SettlementKits.FootprintRadiusM(s, g.HexSizeM);+ TestContext.WriteLine($"{s.Id}: dining hall at t={t:0.00}");+ if (t > 0.65f) bad.Add($"{s.Id}: the dining hall stands at {t:0.00} of the radius");+ }+ Assert.AreEqual(5, kibbutzim, "the five kibbutz game settlements");+ Assert.GreaterOrEqual(withHall, 4, "kibbutzim with a dining hall");+ CollectionAssert.IsEmpty(bad);+ }++ /// <summary>Over the whole map (the game settlements and the 1948 localities): nearly every kibbutz builds its dining hall,+ /// and the farm yards hold sheds. Logs one KIBBUTZ line.</summary>+ [Test]+ public void TheKibbutzimBuildTheirHallsAndFarmSheds()+ {+ var map = OpenMap();+ var g = new KitGround(map.Terrain, map.Frame, map.Hexes, HeightmapLoader.Load(Statecraft.Game.Paths.StreamingMap).meta.elev_min_m);+ foreach (var c in map.RouteCorridors) g.AddCorridor(c.line, c.halfWidth);+ foreach (var c in map.UnitClearings) g.AddCorridor(new List<Vector2> { c.centre, c.centre + Vector2.right }, c.radius);+ var localities = map.Localities.Select(p => p.Settlement).ToList();+ var built = SettlementKits.Build(map.Settlements, localities, new List<Localities.Area>(), g);+ foreach (var k in built.Towns) Object.DestroyImmediate(k.mesh);+ foreach (var t in built.Tiles) Object.DestroyImmediate(t.mesh);+ int kibbutzim = map.Settlements.Concat(localities).Count(s => s.Type == "kibbutz" && !Localities.IsMixed(s.Id));+ var line = $"KIBBUTZ kibbutzim={kibbutzim} halls={built.KibbutzHalls} sheds={built.FarmSheds}";+ TestContext.WriteLine(line); Debug.Log(line);+ Assert.LessOrEqual(built.KibbutzHalls, kibbutzim, "one dining hall per kibbutz at most");+ Assert.GreaterOrEqual(built.KibbutzHalls, kibbutzim - 2, "nearly every kibbutz builds its dining hall (6 of 8 measured)");+ Assert.GreaterOrEqual(built.FarmSheds, kibbutzim, "the farm yards hold sheds (9 measured for the 8 kibbutzim)");+ }+}diff --git a/unity/Assets/Tests/EditMode/KibbutzKitTests.cs.meta b/unity/Assets/Tests/EditMode/KibbutzKitTests.cs.metanew file mode 100644index 000000000..fc4600af6--- /dev/null+++ b/unity/Assets/Tests/EditMode/KibbutzKitTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 725c36f63e6c454e9ee40385173dc708