Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

sim: GDD Phase 1 PR 5, build yishuv at one designated site (Mefalsim) (refs #378) (#566)

Eyal Golan8ef9778b9f04
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 35aee37af..7cec4a6bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,15 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
records an explicit Cc-by-sa-4.0 file as `CC-BY-SA-4.0`, verified only with a named artist and a `NOTICE` entry, with a
share-alike note; `PortraitImport` accepts CC BY-SA 4.0. Kaplan, Gruenbaum, Bernstein, Zisling, Rosen and Sheetrit stay
on GPO photographs for now.
+- GDD v0.1 Phase 1, build yishuv at one designated site (refs #378), behind the `systems.loop` switch: `content/sites.yaml`
+ holds Mefalsim (founded 12 June 1949; Gvati's settlement list and Yad Ben-Zvi), read only by the GDD loop.
+ `PioneerWork(build_yishuv)` sends an idle halutz unit to build there, paid at once; `StopWork` frees the
+ unit and the site and keeps the Money spent (D-A3). Construction is step 5 of the GDD turn (D-A6) (R-SITE-001 to
+ R-SITE-003). The build turns and cost are placeholders in `MvpSlice.Overlay`, never under `content/`; both orders cost 0
+ Attention (D-A6: unit orders free). By the owner's decision "Allow borrowing" (15 October 2026), `PioneerWork` and
+ `Train` borrow what the Treasury lacks, as map actions do. `mvp-slice` moves (the reference player builds Mefalsim by
+ 15 March 1949, and the golden now runs to that date); the legacy goldens and `scenario-mvp-absorb-first` do not.
+ The Unity order queue (`SimBridge`) takes both orders, one per unit.
- Desktop release builds from the Mac (refs #54; Phases 0-1 of the plan in PR #482): `Build.LinuxMono` and
`Build.WindowsMono` build the Linux and Windows x64 players on Mono (decisions O7, O8) and put the committed IL2CPP
setting back afterwards, and
@@ -38,7 +47,8 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
at 32:9; a portrait window never shows it); one draw call, no shadow pass, no golden moves.
- GDD v0.1 Phase 1, training (refs #377), behind the `systems.loop` switch: `Train` sends a city's civilians without work
to basic training in a military camp (recruits, a count) or pioneer training in a Hakhshara (halutzim, movable units at
- the city's hex), paid from the Treasury without borrowing; `CancelTraining` returns the people but not the Money (D-A3).
+ the city's hex), paid from the Treasury, with any shortfall borrowed as debt (owner decision, 15 October 2026);
+ `CancelTraining` returns the people but not the Money (D-A3).
Cohorts progress as step 4 of the GDD turn (D-A6) (R-TRAIN-001 to R-TRAIN-003). One camp and one Hakhshara at the start
is a labelled design assumption (D-D5); training turns, costs and Attention costs are placeholders in `MvpSlice.Overlay`,
never under `content/`. `mvp-slice` moves (the reference player trains one halutz group); the legacy goldens and
diff --git a/content/sites.yaml b/content/sites.yaml
new file mode 100644
index 000000000..a218c3dc0
--- /dev/null
+++ b/content/sites.yaml
@@ -0,0 +1,31 @@
+# GDD v0.1 designated sites (docs/GDD.md "Pioneer work": building is allowed only at designated spots, and a new yishuv
+# takes its site's name). Phase 1 has one site (owner decision D-A4; the owner chose Mefalsim on #378, 14 October 2026).
+# Sourced facts only: the build turns and cost are balance values, set in MvpSlice.Overlay until the owner sets them
+# (ruling 2). The loader reads this file only when eras.yaml systems.loop is gdd. Research: #459,
+# research_notes/GDD objectives/designated-site-1.md.
+sites:
+ - id: mefalsim
+ name: Mefalsim
+ name_he: מפלסים
+ # The hex of the present kibbutz: 31.5019 N, 34.5644 E (Wikidata; the Hebrew and English Wikipedia coordinates, about
+ # 240 m apart, fall in the same hex). The 1949 site was on a kurkar hill facing the Gaza Strip; the kibbutz moved to its
+ # present site about a year later, in 1950, because of fire from Gaza (Yad Ben-Zvi). No coordinates were found for the
+ # 1949 site (#378, question 3). The hex is an Egypt-Israel armistice line hex in map/armistice_hexes_1949.yaml (display
+ # only); a site may sit on one (#378, question 2).
+ q: -10
+ r: 27
+ kinds: [yishuv]
+ # The ceremony of going onto the land, 12 June 1949 (#378, question 5). Gvati's list gives 12.6.49; the Yad Ben-Zvi page
+ # gives the ceremony on Jewish National Fund land on 12 June 1949. An advance party arrived on 8 June 1949 (one source,
+ # not used). Gaps: no 1949 newspaper was read, and the check for a depopulated locality rests on Wikipedia naming none;
+ # a gazetteer check comes before the PR 6 card text is written (#378, question 7).
+ founded: 1949-06-12
+ sources:
+ # Haim Gvati, 100 Years of Settlement, vol. 2, list of all Jewish rural settlements: Mefalsim, South, 12.6.49.
+ - { url: "https://benyehuda.org/read/14684", checked: 2026-10-14 }
+ # Yad Ben-Zvi, "Israel Revealed to the Eye", Kibbutz Mefalsim: the ceremony on 12 June 1949, the Dror garin from
+ # Latin America, the move in 1950.
+ - { url: "https://israelalbum.org.il/mercazim/%D7%A7%D7%99%D7%91%D7%95%D7%A5-%D7%9E%D7%A4%D7%9C%D7%A1%D7%99%D7%9D/", checked: 2026-10-14 }
+ # Wikidata Q2890190: the names (Mefalsim, מפלסים) and the coordinates the hex is computed from (tools/hexgrid.py).
+ - { url: "https://www.wikidata.org/wiki/Q2890190", checked: 2026-10-14 }
+ status: fact-checked
diff --git a/docs/determinism.md b/docs/determinism.md
index 43f262afd..b9dea2803 100644
--- a/docs/determinism.md
+++ b/docs/determinism.md
@@ -70,9 +70,10 @@ later era makes, so they move only when a 1948 rule or event does.
**MVP goldens (GDD v0.1, before cutover).** `mvp-slice` plays `MvpSlice.Load`, the real content with the loop switch on and
monthly turns (spec 2026-10-12 section 2.1, R-LOOP-003), from the golden seed in Historical mode with the reference player until
-`MvpGolden.Until` (15 January 1949, eight monthly turns). The reference player (`Statecraft.Sim.Reference.ReferencePlayer`, decision
-D-A7) is a stated test policy, not game AI and not history: `HistoricalAI`'s orders, then each city's jobs filled, then one
-halutz group trained when there is none and none in training. No game mode or UI
+`MvpGolden.Until` (15 March 1949, ten monthly turns). The reference player (`Statecraft.Sim.Reference.ReferencePlayer`, decision
+D-A7) is a stated test policy, not game AI and not history: `HistoricalAI`'s orders, then each city's jobs filled, then each
+idle halutz group sent to the first available designated site, then one halutz group trained when there is none and none in
+training. Both orders borrow what the Treasury lacks, so Money never holds them back. No game mode or UI
reaches it (`ReferencePlayerTests`). `MvpGoldenTests` checks it against the manifest line `mvp-slice` and the
snapshot `golden/mvp-slice.txt`, and the update command re-pins it like the others. It is not shown in this file's table or in
`tools/web_check.py`, because the players run only the legacy goldens until cutover. A Phase 1 PR that adds a GDD rule the slice
@@ -197,3 +198,4 @@ The hash reads the state keys, so it never sees a record outside its window. An
| Issue #2 | 1952 | `62f8ec61` | sourced Yosef food-supply/rationing responsibility from 8 October 1951 replaces a vacancy and changes late-1951 rationing competence; 1950 and five-turn smoke unchanged |
| GDD Phase 1 PR 3 | mvp-slice | `f6931e24` | the slice gains its city (placeholder values) and the GDD turn: Money from jobs, housing, Social cohesion and arrivals, with the reference player filling the jobs (was `0451920a`); the legacy goldens do not move |
| GDD Phase 1 PR 4 | mvp-slice | `6343eee8` | training runs in the slice (step 4 of the GDD turn) and the reference player trains one halutz group on the first turn: it becomes a unit at Tel Aviv's hex on the fourth, its IL 0.5m adds to the debt, and the civilian it took frees a place that one more refugee is housed in (was `f6931e24`); the legacy goldens and `scenario-mvp-absorb-first` do not move |
+| GDD Phase 1 PR 5 | mvp-slice | `ec6f8c80` | owner decision "Allow borrowing" (15 October 2026): training and pioneer work borrow what the Treasury lacks. The reference player's halutz group, ready on 15 September 1948, starts Mefalsim that turn (its IL 2m adds to the debt) and builds it on 15 March 1949; `MvpGolden.Until` moves from 15 January to 15 March 1949 (ten monthly turns) so the build finishes inside the run (was `6343eee8`); the legacy goldens and `scenario-mvp-absorb-first` do not move |
diff --git a/docs/gdd/build-yishuv.md b/docs/gdd/build-yishuv.md
new file mode 100644
index 000000000..23021d5d3
--- /dev/null
+++ b/docs/gdd/build-yishuv.md
@@ -0,0 +1,43 @@
+# Build yishuv: one designated site
+
+## Player story
+
+As a player of the MVP, I want to send a group of halutzim to build a new yishuv at a designated site, so that the place is founded under its historical name (GDD "Pioneer work" [S1]; decisions D-A3, D-A4, D-D6 [S2]).
+
+## Rules
+
+- Building is allowed only at designated sites, listed with their sources in `content/sites.yaml`. The slice has one: Mefalsim, founded on 12 June 1949, the day of the ceremony of going onto the land [S4][S5]. The owner chose it on #378 [S3].
+- A site is available from the game's start. It may sit on an armistice line hex, as Mefalsim's hex does [S3].
+- `PioneerWork(unit, build_yishuv, site)` sends an idle halutz unit to build. It costs IL 2m, a placeholder paid in full at once, borrowing what the Treasury lacks (owner decision on #378 [S3]), and no Attention, because unit orders are free (D-A6). The unit works from where it stands (R-SITE-001).
+- It is refused, with the state unchanged, for an unknown unit, a unit that is not a halutz or already has a project (one project per unit, D-D6), an unknown action or site, a site being built or built (one unit per site), or the legacy loop (R-SITE-001).
+- `StopWork(unit)` ends the build. The site is available again; the progress and the Money paid are lost (D-A3) (R-SITE-002).
+- Construction resolves after training and before production in each turn (D-A6). A build ordered this turn counts this turn: it takes 6 turns, a placeholder (R-SITE-003).
+- When the build finishes, the site is marked built on the turn's end date and the unit is idle again. It stays a halutz unit. Nothing else changes yet: no city, housing, jobs, population or Social cohesion. The objective and its card come with the objective PR (R-SITE-003).
+
+## Data touched
+
+- `content/sites.yaml` (new; sourced facts: id, names, hex, kinds, founding date, sources, status). The loader reads it only in the GDD loop, so the legacy content hash does not move.
+- `rules.yaml` `mvp.build_yishuv_turns` and `mvp.build_yishuv_cost`, and `attention_cost.pioneer_work` and `stop_work`: supplied by `MvpSlice.Overlay`, never under `content/` (ruling 2 [S3]).
+- `GameState.Sites`, hashed as `site{...}` when there are some; `Treasury`.
+- Save files: the `pioneer UNIT ACTION SITE` and `stop UNIT` lines. Scenarios: `pioneer_work` and `stop_work`.
+
+## Done when
+
+- `dotnet test sim/Statecraft.sln` passes, including `ProjectsTests`, `SitesContentTests`, `GddStateTests` and `ReferencePlayerTests`.
+- `hash1950`, `hash1952`, `smoke5`, `scenario-cautious`, `scenario-reckless` and `scenario-mvp-absorb-first` do not move.
+
+## Out of scope
+
+- The objective, its card and the score (PR 6), the build button and the built yishuv on the map (PRs 7 and 8), movement (Phase 5), other pioneer work and other kinds of site, and more sites.
+
+## Sources
+
+- [S1] The game design of record, docs/GDD.md
+- [S2] GDD v0.1 impact analysis and phased plan, section 5, docs/superpowers/specs/2026-10-12-gdd-v0.1-impact-and-plan.md
+- [S3] GDD Phase 1 plan for PR 5 and the owner's decisions, https://github.com/eyalgolan/statecraft-israel/issues/378, checked 2026-10-14
+- [S4] Haim Gvati, 100 Years of Settlement, vol. 2, list of all Jewish rural settlements, https://benyehuda.org/read/14684, checked 2026-10-14
+- [S5] Yad Ben-Zvi, "Israel Revealed to the Eye", Kibbutz Mefalsim, https://israelalbum.org.il/mercazim/%D7%A7%D7%99%D7%91%D7%95%D7%A5-%D7%9E%D7%A4%D7%9C%D7%A1%D7%99%D7%9D/, checked 2026-10-14
+
+## Open questions
+
+- The placeholder values (6 turns, IL 2m) wait for the owner.
diff --git a/docs/gdd/training.md b/docs/gdd/training.md
index bf9a96dcf..73ee81079 100644
--- a/docs/gdd/training.md
+++ b/docs/gdd/training.md
@@ -7,8 +7,8 @@ As a player of the MVP, I want to send Tel Aviv's civilians without work to basi
## Rules
- One military camp and one Hakhshara exist in Tel Aviv at the start. This is a design assumption, not a claim about the city, and pioneers will build more in Phase 4 (D-D5 [S2]). The GDD leaves training capacity open, so there is no capacity limit (unitless).
-- `Train(city, track, n)` takes civilians without a job into training as recruits (military camp) or halutzim (Hakhshara). It costs 1 Attention and IL 0.5m per group, both placeholders, paid at once and never borrowed (R-TRAIN-001).
-- It is refused, with the state unchanged, for fewer than 1 group (unitless), more than the city's civilians without a job, an unknown city or track, a city without the facility, a Treasury short of the cost, or the legacy loop (R-TRAIN-001).
+- `Train(city, track, n)` takes civilians without a job into training as recruits (military camp) or halutzim (Hakhshara). It costs 1 Attention and IL 0.5m per group, both placeholders, paid at once. A short Treasury borrows the rest, as map actions do (owner decision on #468) (R-TRAIN-001).
+- It is refused, with the state unchanged, for fewer than 1 group (unitless), more than the city's civilians without a job, an unknown city or track, a city without the facility, or the legacy loop (R-TRAIN-001).
- People in training are neither civilians nor recruits: they hold no job and are not counted by housing or Social cohesion while they train.
- `CancelTraining(cohort)` returns the people as civilians without a job; the Money spent is not returned (D-A3 [S2]). It costs 0.5 Attention, a placeholder (R-TRAIN-002).
- Training resolves before production in each turn, in the order the owner approved (D-A6, #456 [S2][S3]). A cohort ordered this turn counts this turn: basic training takes 3 turns and pioneer training 4 turns, both placeholders (R-TRAIN-003).
@@ -39,7 +39,6 @@ As a player of the MVP, I want to send Tel Aviv's civilians without work to basi
## Open questions
- The placeholder values (training turns, cost per group, the two Attention costs) wait for the owner.
-- Whether training may borrow from the Treasury, as map actions do. This PR refuses it.
- Whether people in training, and recruits, take up the city's housing. Housing counts civilians only (R-CITY-004), so a group in training frees a place that a waiting refugee then takes.
- Whether the turn of the order counts as a training turn. This is the plan's reading of D-A6, not part of the owner's ruling. The other reading adds a turn.
- Social cohesion's employed share rises while civilians without work are in training, because they leave the civilians (R-CITY-005).
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 737a09f7c..582f13d2d 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -38,8 +38,18 @@ R-CITY-005: Social cohesion is `clamp(0, 1, cohesion_housing_weight * housed + c
Training is step 4 of the turn in the approved order (§2.3, D-A6): it runs before production. One military camp and one Hakhshara exist in the slice's city at the start, a labelled design assumption (D-D5); pioneers will build more.
-R-TRAIN-001: `Train(city, track, n)` takes `n` of the city's civilians without a job into a cohort that trains as `track` (a unit type with a `facility`: `recruit` in a military camp, `halutz` in a Hakhshara) for the type's `training_turns`, counting the turn it was ordered in. The Treasury pays `n * training_cost` at once and training does not borrow. The trainees leave the civilians at once; the cohort takes the next id, which units share. It is refused, with the state unchanged and the Attention refunded, when the city or track is unknown, `n` is below 1, the city lacks the facility, it has fewer civilians without a job, or the Treasury holds less than the cost. The legacy loop refuses it before charging Attention.
+R-TRAIN-001: `Train(city, track, n)` takes `n` of the city's civilians without a job into a cohort that trains as `track` (a unit type with a `facility`: `recruit` in a military camp, `halutz` in a Hakhshara) for the type's `training_turns`, counting the turn it was ordered in. The Treasury pays `n * training_cost` at once. When the Treasury holds less, the shortfall is borrowed, as for map actions: it is added to the debt and the Treasury stops at 0 (owner decision "Allow borrowing", 15 October 2026). The trainees leave the civilians at once; the cohort takes the next id, which units share. It is refused, with the state unchanged and the Attention refunded, when the city or track is unknown, `n` is below 1, the city lacks the facility, or it has fewer civilians without a job. The legacy loop refuses it before charging Attention.
R-TRAIN-002: `CancelTraining(cohort)` returns the cohort's people to its city as civilians without a job and refunds none of the Money paid (D-A3). A cohort that does not exist, or has finished, is refused with the state unchanged.
R-TRAIN-003: Each turn, in ascending id, every cohort has one turn less to go. A cohort that reaches 0 ends: recruits are added to the city's count of recruits (a count until Phase 5), and halutzim become one movable unit per group at the city's settlement hex, taking the next ids in turn. A city's recruits and the cohorts are written into the state hash only when there are some.
+
+## Sites
+
+Construction is step 5 of the turn in the approved order (§2.3, D-A6): after training, before production. The designated sites are sourced facts in `content/sites.yaml`; Phase 1 has one, Mefalsim (owner decision on #378). The answers below are the plan's recommendations, which the owner took on 14 October 2026 (#378).
+
+R-SITE-001: `PioneerWork(unit, build_yishuv, site)` starts building a yishuv at a designated site whose kinds include `yishuv` and which is neither being built nor built, with a halutz unit that has no other project (D-D6: one project per unit). The Treasury pays `build_yishuv_cost` at once. When the Treasury holds less, the shortfall is borrowed, as for map actions: it is added to the debt and the Treasury stops at 0 (owner decision "Allow borrowing", 15 October 2026). The site has `build_yishuv_turns` to go, counting the turn of the order. The unit does not move. It is refused, with the state unchanged and the Attention refunded, for an unknown unit, a unit that is not a halutz or is busy, an unknown action or site, a site that is not for a yishuv, or a site being built or built (one unit per site). The legacy loop refuses it before charging Attention. Its Attention cost is 0 (D-A6: unit orders are free).
+
+R-SITE-002: `StopWork(unit)` ends the unit's build: the site is available again, the unit is idle, and the progress and the Money paid are lost (D-A3). A unit that does not exist or is not building is refused with the state unchanged. Its Attention cost is 0.
+
+R-SITE-003: Each turn, in ordinal site id order, every site being built has one turn less to go. A site that reaches 0 is built, on the turn's end date, and its unit is idle again. The unit stays a halutz unit, and no city, housing, job, population or Social cohesion changes. Sites being built or built are written into the state hash only when there are some.
diff --git a/docs/superpowers/plans/2026-10-12-gdd-phase-1.md b/docs/superpowers/plans/2026-10-12-gdd-phase-1.md
index cb861ef6f..a270d4757 100644
--- a/docs/superpowers/plans/2026-10-12-gdd-phase-1.md
+++ b/docs/superpowers/plans/2026-10-12-gdd-phase-1.md
@@ -956,7 +956,9 @@ Tests: a recruit cohort of 3 groups completes after exactly `training_turns` tur
## PR 5: one designated site and "build yishuv"
-> **Waits for the owner (ruling 1):** D-D6 (and D-A6). The site's name, place, date and sources are sourced facts and go in `content/sites.yaml`; the build turns and cost are overlay text (ruling 2). Ruling 4: the public-domain question on Yeruham's 1951 PikiWiki photographs (Werner Braun, tagged PD-author) goes to the owner and is recorded in this PR's notes.
+> **Decided by the owner on 2026-10-14 (#378):** the site is Mefalsim (#459), and every other open question takes the recommendation of the rewritten PR 5 plan posted on #378, which replaces the draft tasks below. D-D6 and D-A6 were decided in #456. Ruling 4 is moot with Mefalsim (its photograph is CC BY 4.0); the recommendation is to refuse the Yeruham photographs as tagged. On 2026-10-15 the owner answered question 13 (and #468's question 1), "Allow borrowing": training and pioneer work borrow what the Treasury lacks, as map actions do.
+>
+> The site's name, place, date and sources are sourced facts and go in `content/sites.yaml`; the build turns and cost are overlay text (ruling 2).
### Task 5.0: choose and source the site (before any code)
diff --git a/sim/Statecraft.Sim.Tests/CitiesContentTests.cs b/sim/Statecraft.Sim.Tests/CitiesContentTests.cs
index 4eb69ae08..d6277328b 100644
--- a/sim/Statecraft.Sim.Tests/CitiesContentTests.cs
+++ b/sim/Statecraft.Sim.Tests/CitiesContentTests.cs
@@ -67,7 +67,7 @@ public class CitiesContentTests
const string City = " - { id: town_a, housing_capacity: 12, job_slots: 8, civilians: 10, employed: 6, facilities: [] }\n";
static string Cities(string row) => "cities:\n" + row;
- static string Rules(string mvp) => Fixture.Files["rules.yaml"].Replace("map_action: 1 }", "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1 }") + mvp;
+ static string Rules(string mvp) => Fixture.Files["rules.yaml"].Replace("map_action: 1 }", Fixture.GddCosts) + mvp;
static string Types(string row) => "types:\n - { id: civilian, kind: population }\n" + row;
public static IEnumerable<object[]> BadRows() => new List<object[]>
diff --git a/sim/Statecraft.Sim.Tests/CitiesTests.cs b/sim/Statecraft.Sim.Tests/CitiesTests.cs
index 0c794f7fc..2a1fb6587 100644
--- a/sim/Statecraft.Sim.Tests/CitiesTests.cs
+++ b/sim/Statecraft.Sim.Tests/CitiesTests.cs
@@ -170,7 +170,7 @@ public class CitiesTests
static Content Unequal() => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>
{
["cities.yaml"] = "cities:\n - { id: town_a, housing_capacity: 12, job_slots: 20, civilians: 10, employed: 6, facilities: [] }\n",
- ["rules.yaml"] = Fixture.Files["rules.yaml"].Replace("map_action: 1 }", "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1 }")
+ ["rules.yaml"] = Fixture.Files["rules.yaml"].Replace("map_action: 1 }", Fixture.GddCosts)
+ Fixture.GddRules.Replace("cohesion_housing_weight: 0.5", "cohesion_housing_weight: 0.8").Replace("cohesion_jobs_weight: 0.5", "cohesion_jobs_weight: 0.2"),
})));
diff --git a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs b/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
index b6ce683b8..2e585fb5d 100644
--- a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
+++ b/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
@@ -21,6 +21,8 @@ public class CommandGuardTests
[typeof(AssignWorkers)] = new AssignWorkers("tel_aviv", "job", 1),
[typeof(Train)] = new Train("tel_aviv", "halutz", 1),
[typeof(CancelTraining)] = new CancelTraining(1),
+ [typeof(PioneerWork)] = new PioneerWork(1, "build_yishuv", "mefalsim"),
+ [typeof(StopWork)] = new StopWork(1),
};
static IEnumerable<Type> CommandTypes() =>
diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.cs
index db48aaa21..4d07826b4 100644
--- a/sim/Statecraft.Sim.Tests/Fixture.cs
+++ b/sim/Statecraft.Sim.Tests/Fixture.cs
@@ -203,14 +203,18 @@ series:
var o = new Dictionary<string, string>
{
["eras.yaml"] = Files["eras.yaml"] + " systems: { loop: gdd }\n",
- ["rules.yaml"] = Files["rules.yaml"].Replace("map_action: 1 }", "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1 }") + GddRules,
+ ["rules.yaml"] = Files["rules.yaml"].Replace("map_action: 1 }", GddCosts) + GddRules,
["cities.yaml"] = GddCities,
["unit_types.yaml"] = GddUnitTypes,
+ ["sites.yaml"] = GddSites,
};
if (extra != null) foreach (var kv in extra) o[kv.Key] = kv.Value;
return o;
}
+ /// <summary>The fixture's attention_cost line with the GDD command kinds added (replaces "map_action: 1 }").</summary>
+ public const string GddCosts = "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1, pioneer_work: 0, stop_work: 0 }";
+
public const string GddRules = @"
mvp:
people_per_unit: 10
@@ -218,6 +222,8 @@ mvp:
cohesion_housing_weight: 0.5
cohesion_jobs_weight: 0.5
arrivals_city: town_a
+ build_yishuv_turns: 3
+ build_yishuv_cost: 1.5
";
public const string GddCities = @"
@@ -233,6 +239,21 @@ types:
- { id: halutz, kind: unit, facility: hakhshara, training_turns: 3, training_cost: 0.25 }
";
+ /// <summary>One designated site on a land hex next to town_a, with no settlement on it. Fixture values, not history.</summary>
+ public const string GddSites = @"
+sites:
+ - id: site_a
+ name: Site A
+ name_he: אתר א
+ q: 2
+ r: 0
+ kinds: [yishuv]
+ founded: 1949-06-12
+ sources:
+ - { url: ""https://example.org/site_a"", checked: 2026-10-14 }
+ status: fact-checked
+";
+
public static string Write(Dictionary<string, string>? overrides = null, Dictionary<string, string>? events = null)
{
var dir = Path.Combine(Path.GetTempPath(), "statecraft-fixture-" + Guid.NewGuid().ToString("N"));
diff --git a/sim/Statecraft.Sim.Tests/GddStateTests.cs b/sim/Statecraft.Sim.Tests/GddStateTests.cs
index eccd6ac97..45089f7d3 100644
--- a/sim/Statecraft.Sim.Tests/GddStateTests.cs
+++ b/sim/Statecraft.Sim.Tests/GddStateTests.cs
@@ -20,7 +20,7 @@ public class GddStateTests
public void AnEmptyStateWritesNoNewSection()
{
var text = new GameState().Describe();
- foreach (var label in new[] { "city{", "coh=", "units[", "train[", "next=", "obj{", "score=" }) Assert.DoesNotContain(label, text);
+ foreach (var label in new[] { "city{", "coh=", "units[", "train[", "site{", "next=", "obj{", "score=" }) Assert.DoesNotContain(label, text);
Assert.EndsWith("over=", text);
}
@@ -48,6 +48,7 @@ public class GddStateTests
("city{", x => x.Cities["tel_aviv"] = new City("tel_aviv", 10, 4, 6, 3, 2)),
("units[", x => x.Units.Add(1, new Unit(1, "halutz", -3, 19))),
("train[", x => x.Cohorts.Add(2, new Cohort(2, "recruit", "tel_aviv", 3, 2))),
+ ("site{", x => x.Sites["mefalsim"] = new SiteWork("mefalsim", 1, 5, null)),
("next=", x => x.NextId = 2),
("obj{", x => x.Objectives["first_new_yishuv"] = new DateTime(1949, 3, 15)),
("score=", x => x.Score = 5),
@@ -76,6 +77,35 @@ public class GddStateTests
var cohorts = new[] { new Cohort(1, "recruit", "a", 1, 1), new Cohort(2, "recruit", "a", 1, 1), new Cohort(1, "halutz", "a", 1, 1),
new Cohort(1, "recruit", "b", 1, 1), new Cohort(1, "recruit", "a", 2, 1), new Cohort(1, "recruit", "a", 1, 2) };
Assert.Equal(cohorts.Length, new HashSet<string>(Array.ConvertAll(cohorts, K)).Count);
+ string W(SiteWork w) { var s = new GameState(); s.Sites[w.Site] = w; return s.Hash(); }
+ var works = new[] { new SiteWork("a", 1, 1, null), new SiteWork("b", 1, 1, null), new SiteWork("a", 2, 1, null), new SiteWork("a", 1, 2, null),
+ SiteWork.Built("a", new DateTime(1949, 1, 15)), SiteWork.Built("a", new DateTime(1949, 2, 15)), SiteWork.Built("b", new DateTime(1949, 1, 15)) };
+ Assert.Equal(works.Length, new HashSet<string>(Array.ConvertAll(works, W)).Count);
+ }
+
+ // R-LOOP-002, R-SITE-001, R-SITE-003: a site being built and a built site, as the hash writes them.
+ [Fact]
+ public void ASiteIsHashedAsBuildingOrBuilt()
+ {
+ Assert.Equal("mefalsim=b,4,5", new SiteWork("mefalsim", 4, 5, null).Canonical());
+ Assert.Equal("mefalsim=done,1949-06-15", SiteWork.Built("mefalsim", new DateTime(1949, 6, 15)).Canonical());
+ }
+
+ // R-SITE-003: a built site holds no unit. Unit ids start at 0, so "no unit" is null, never 0: unit 0 is free once its
+ // site is built, and a record cannot be built and have a unit, or be building without one.
+ [Fact]
+ public void ABuiltSiteHoldsNoUnitNotUnitZero()
+ {
+ var built = SiteWork.Built("mefalsim", new DateTime(1949, 3, 15));
+ Assert.Null(built.Unit);
+ var s = new GameState();
+ s.Units.Add(0, new Unit(0, "halutz", -3, 19));
+ s.Sites["mefalsim"] = new SiteWork("mefalsim", 0, 1, null);
+ Assert.True(Projects.IsBusy(s, 0));
+ s.Sites["mefalsim"] = built;
+ Assert.False(Projects.IsBusy(s, 0));
+ Assert.Throws<ArgumentException>(() => new SiteWork("mefalsim", null, 1, null));
+ Assert.Throws<ArgumentException>(() => new SiteWork("mefalsim", 0, 0, new DateTime(1949, 3, 15)));
}
// R-LOOP-002, R-TRAIN-003: a city's recruits reach the hash, and a city with none hashes as it did before PR 4, so
@@ -96,13 +126,14 @@ public class GddStateTests
a.Cities["x"] = new City("x", 1, 1, 1, 0, 0);
a.Units.Add(1, new Unit(1, "halutz", 0, 0));
a.Cohorts.Add(2, new Cohort(2, "recruit", "x", 1, 1));
+ a.Sites["s"] = new SiteWork("s", 1, 1, null);
a.Objectives["o"] = new DateTime(1949, 1, 1);
a.NextId = 2; a.Score = 3;
var before = a.Hash();
var b = a.Clone();
- b.Cities["y"] = a.Cities["x"]; b.Units.Add(2, a.Units[1]); b.Cohorts.Clear(); b.Objectives.Clear(); b.NextId = 9; b.Score = 9;
+ b.Cities["y"] = a.Cities["x"]; b.Units.Add(2, a.Units[1]); b.Cohorts.Clear(); b.Sites.Clear(); b.Objectives.Clear(); b.NextId = 9; b.Score = 9;
Assert.Equal(before, a.Hash());
- Assert.Single(a.Cities); Assert.Single(a.Units); Assert.Single(a.Cohorts); Assert.Single(a.Objectives);
+ Assert.Single(a.Cities); Assert.Single(a.Units); Assert.Single(a.Cohorts); Assert.Single(a.Sites); Assert.Single(a.Objectives);
}
[Fact]
diff --git a/sim/Statecraft.Sim.Tests/MvpGoldenTests.cs b/sim/Statecraft.Sim.Tests/MvpGoldenTests.cs
index 33ce219db..29019c12c 100644
--- a/sim/Statecraft.Sim.Tests/MvpGoldenTests.cs
+++ b/sim/Statecraft.Sim.Tests/MvpGoldenTests.cs
@@ -10,8 +10,11 @@ public class MvpGoldenTests
public void TheSliceMatchesItsGolden()
{
var s = MvpGolden.Play(Mvp);
- Assert.Equal(new DateTime(1949, 1, 15), s.Date);
- Assert.Equal(8, s.Turn);
+ Assert.Equal(new DateTime(1949, 3, 15), s.Date);
+ Assert.Equal(10, s.Turn);
+ // R-SITE-001, R-SITE-003: the reference player's halutz group is ready on 15 September 1948, starts Mefalsim that turn
+ // (borrowing the cost) and builds it at the end of the sixth turn, on 15 March 1949: the last turn the golden plays.
+ Assert.Equal(new DateTime(1949, 3, 15), s.Sites["mefalsim"].BuiltOn);
var expected = GoldenManifest.UpdateRequested ? GoldenManifest.Read().GetValueOrDefault("mvp-slice", "") : GoldenManifest.Expected("mvp-slice");
GoldenSnapshot.Check("mvp-slice", s, expected);
}
diff --git a/sim/Statecraft.Sim.Tests/MvpSliceTests.cs b/sim/Statecraft.Sim.Tests/MvpSliceTests.cs
index 42f6cdac2..990a80b66 100644
--- a/sim/Statecraft.Sim.Tests/MvpSliceTests.cs
+++ b/sim/Statecraft.Sim.Tests/MvpSliceTests.cs
@@ -29,7 +29,8 @@ public class MvpSliceTests
Assert.Equal(Real.Rules.Start, Mvp.Rules.Start);
// The slice adds the GDD command kinds' costs (placeholders) and keeps every other cost.
Assert.Equal(Real.Rules.AttentionCost.Append(new KeyValuePair<string, double>("assign_workers", 0.5))
- .Append(new KeyValuePair<string, double>("train", 1)).Append(new KeyValuePair<string, double>("cancel_training", 0.5)).OrderBy(kv => kv.Key, StringComparer.Ordinal),
+ .Append(new KeyValuePair<string, double>("train", 1)).Append(new KeyValuePair<string, double>("cancel_training", 0.5))
+ .Append(new KeyValuePair<string, double>("pioneer_work", 0)).Append(new KeyValuePair<string, double>("stop_work", 0)).OrderBy(kv => kv.Key, StringComparer.Ordinal),
Mvp.Rules.AttentionCost.OrderBy(kv => kv.Key, StringComparer.Ordinal));
Assert.Equal(Real.Rules.BudgetStart, Mvp.Rules.BudgetStart);
Assert.Equal(Real.Rules.CapitalInflowPerYear, Mvp.Rules.CapitalInflowPerYear);
diff --git a/sim/Statecraft.Sim.Tests/ProjectsTests.cs b/sim/Statecraft.Sim.Tests/ProjectsTests.cs
new file mode 100644
index 000000000..cc8525539
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/ProjectsTests.cs
@@ -0,0 +1,284 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>The GDD slice's pioneer work (Phase 1 PR 5): PioneerWork(build_yishuv) (R-SITE-001) and StopWork (R-SITE-002) at a
+/// designated site, and construction in TurnResolver (R-SITE-003, step 5 of spec 2026-10-12 section 2.3, D-A6). The answers to
+/// #378's questions are the plan's recommendations, which the owner took on 14 October 2026.</summary>
+public class ProjectsTests
+{
+ static readonly Content Mvp = MvpSlice.Load(RealContentTests.ContentRoot());
+
+ /// <summary>The GDD fixture: town_a at (1, 0) and site_a at (2, 0). A build takes 3 turns and costs IL 1.5m.</summary>
+ static Content Town(Dictionary<string, string>? extra = null) => ContentLoader.Load(Fixture.Write(Fixture.Gdd(extra)));
+
+ static StepResult Step(Content c, GameState s, params Command[] commands) => Simulation.Step(c, s, commands);
+
+ /// <summary>A new game on <paramref name="c"/> with one idle halutz group at town_a's hex; its id is returned.</summary>
+ static GameState WithHalutz(Content c, out int id, string type = "halutz")
+ {
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ id = s.NextId++;
+ s.Units.Add(id, new Unit(id, type, 1, 0));
+ return s;
+ }
+
+ static PioneerWork Build(int unit, string site = "site_a") => new PioneerWork(unit, Projects.BuildYishuv, site);
+
+ // R-SITE-001
+ [Fact]
+ public void StartingTheBuildCommitsTheUnitAndPays()
+ {
+ var c = Town();
+ var s = WithHalutz(c, out var id);
+ var r = Step(c, s, Build(id));
+ Assert.Empty(r.Rejected);
+ var work = r.State.Sites["site_a"];
+ Assert.Equal(("site_a", (int?)id, 2, (DateTime?)null), (work.Site, work.Unit, work.TurnsLeft, work.BuiltOn)); // 3 turns, one of them this one
+ Assert.True(Projects.IsBusy(r.State, id));
+ Assert.Equal(Step(c, s).State.Treasury - 1.5, r.State.Treasury, 9); // paid in full at the start (question 12)
+ Assert.Equal((1, 0), (r.State.Units[id].Q, r.State.Units[id].R)); // the unit works from where it stands (question 9)
+ Assert.Contains(r.Why, x => x.System == "map" && x.Message == "Site A: a group of halutzim began building a yishuv, cost IL 1.5m");
+ }
+
+ public static IEnumerable<object[]> Refusals() => new List<object[]>
+ {
+ new object[] { "unknown unit", "There is no such unit" },
+ new object[] { "not a halutz", "Only halutzim do pioneer work" },
+ new object[] { "busy", "That group of halutzim is already building Site B" },
+ new object[] { "unknown action", "There is no such pioneer work" },
+ new object[] { "unknown site", "There is no such site" },
+ new object[] { "not a yishuv site", "Site B is not a site for a new yishuv" },
+ new object[] { "being built", "Site A is already being built" },
+ new object[] { "built", "Site A is already built" },
+ };
+
+ /// <summary>Site B, on (3, 0), for the refusals that need a second site; <paramref name="kinds"/> its kinds.</summary>
+ static string TwoSites(string kinds = "[yishuv]") => Fixture.GddSites + Fixture.GddSites.Replace("sites:\n", "")
+ .Replace("site_a", "site_b").Replace("Site A", "Site B").Replace("q: 2", "q: 3").Replace("kinds: [yishuv]", "kinds: " + kinds);
+
+ // R-SITE-001: each refusal leaves the state as a step with no order would, so Attention is refunded too.
+ [Theory]
+ [MemberData(nameof(Refusals))]
+ public void TheLimitsAreRefusedAndChangeNothing(string limit, string reason)
+ {
+ var c = Town(new Dictionary<string, string> { ["sites.yaml"] = TwoSites(limit == "not a yishuv site" ? "[]" : "[yishuv]") });
+ var s = WithHalutz(c, out var id, limit == "not a halutz" ? "recruit" : "halutz");
+ var other = s.NextId++;
+ s.Units.Add(other, new Unit(other, "halutz", 1, 0));
+ Command order = Build(id);
+ switch (limit)
+ {
+ case "unknown unit": order = Build(999); break;
+ case "busy": s.Sites["site_b"] = new SiteWork("site_b", id, 2, null); break;
+ case "unknown action": order = new PioneerWork(id, "build_road", "site_a"); break;
+ case "unknown site": order = Build(id, "nowhere"); break;
+ case "not a yishuv site": order = Build(id, "site_b"); break;
+ case "being built": s.Sites["site_a"] = new SiteWork("site_a", other, 2, null); break; // question 15: one unit per site
+ case "built": s.Sites["site_a"] = SiteWork.Built("site_a", new DateTime(1948, 8, 15)); break;
+ }
+ var r = Step(c, s, order);
+ Assert.Equal(reason, Assert.Single(r.Rejected).Reason);
+ Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());
+ }
+
+ // R-SITE-001: a short Treasury borrows the shortfall, as map actions do (question 13, owner decision "Allow borrowing",
+ // 2026-10-15); a Treasury of exactly the cost borrows nothing.
+ [Fact]
+ public void AShortTreasuryBorrowsTheShortfall()
+ {
+ var c = Town();
+ var s = WithHalutz(c, out var id);
+ s.Treasury = 1.4;
+ s.Debt = 3;
+ var why = new List<Cause>();
+ Assert.Null(Projects.Start(c, s, id, Projects.BuildYishuv, "site_a", why));
+ Assert.Equal(0, s.Treasury);
+ Assert.Equal(3.1, s.Debt, 9);
+ Assert.Single(s.Sites);
+ Assert.Contains(why, x => x.System == "economy" && x.Target == "debt" && x.Message == "Borrowed IL 0.1m to build a yishuv");
+
+ var exact = WithHalutz(c, out var other);
+ exact.Treasury = 1.5;
+ exact.Debt = 3;
+ var none = new List<Cause>();
+ Assert.Null(Projects.Start(c, exact, other, Projects.BuildYishuv, "site_a", none));
+ Assert.Equal((0.0, 3.0), (exact.Treasury, exact.Debt));
+ Assert.DoesNotContain(none, x => x.System == "economy");
+ }
+
+ // R-SITE-001, R-SITE-002
+ [Fact]
+ public void TheLegacyLoopRefusesBothOrdersAndRefundsAttention()
+ {
+ var c = ContentLoader.Load(RealContentTests.ContentRoot());
+ var s = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);
+ var r = Step(c, s, new PioneerWork(1, Projects.BuildYishuv, "mefalsim"), new StopWork(1));
+ Assert.Equal(2, r.Rejected.Count);
+ Assert.All(r.Rejected, x => Assert.Equal("That order is not available in this game", x.Reason));
+ Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());
+ }
+
+ // R-SITE-002 (D-A3, question 14: the progress is lost and no Money is returned)
+ [Fact]
+ public void StoppingFreesTheUnitAndTheSiteAndReturnsNoMoney()
+ {
+ var c = Town();
+ var started = Step(c, WithHalutz(c, out var id), Build(id)).State;
+ var stopped = Step(c, started, new StopWork(id));
+ Assert.Empty(stopped.Rejected);
+ Assert.Empty(stopped.State.Sites);
+ Assert.False(Projects.IsBusy(stopped.State, id));
+ Assert.Equal(Step(c, started).State.Treasury, stopped.State.Treasury, 9); // the IL 1.5m paid stays paid
+ Assert.Contains(stopped.Why, x => x.System == "map" && x.Message == "Site A: the halutzim stopped building; the Money spent is not returned");
+ var again = Step(c, stopped.State, Build(id)); // the site is available again, from the start
+ Assert.Empty(again.Rejected);
+ Assert.Equal(2, again.State.Sites["site_a"].TurnsLeft);
+ }
+
+ // R-SITE-002
+ [Fact]
+ public void StoppingAUnitWithNoWorkIsRefusedAndChangesNothing()
+ {
+ var c = Town();
+ var s = WithHalutz(c, out var id);
+ foreach (var (unit, reason) in new[] { (999, "There is no such unit"), (id, "That group of halutzim is not building anything") })
+ {
+ var r = Step(c, s, new StopWork(unit));
+ Assert.Equal(reason, Assert.Single(r.Rejected).Reason);
+ Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());
+ }
+ var built = s.Clone();
+ built.Sites["site_a"] = SiteWork.Built("site_a", new DateTime(1948, 8, 15)); // a finished build holds no unit
+ Assert.Equal("That group of halutzim is not building anything", Assert.Single(Step(c, built, new StopWork(id)).Rejected).Reason);
+ }
+
+ // R-SITE-001, R-SITE-002
+ [Fact]
+ public void BothOrdersSurviveASave()
+ {
+ var c = Town();
+ var g = GameSession.New(c, 1, Mode.Historical);
+ g.Step(new Command[] { new Train("town_a", "halutz", 1) });
+ g.Step(new Command[0]);
+ g.Step(new Command[0]); // the fixture's halutz trains for 3 turns
+ var id = Assert.Single(g.State.Units.Keys);
+ g.Step(new Command[] { Build(id) });
+ g.Step(new Command[] { new StopWork(id) });
+ g.Step(new Command[] { Build(id) });
+ var text = g.Save.Write();
+ Assert.Contains($"\npioneer {id} build_yishuv site_a\n", text);
+ Assert.Contains($"\nstop {id}\n", text);
+ var loaded = GameSession.Load(c, text, out _).State;
+ Assert.Equal(g.State.Hash(), loaded.Hash());
+ Assert.Single(loaded.Sites);
+ }
+
+ // ---- construction in the resolver (R-SITE-003, step 5 of section 2.3) ----
+
+ // R-SITE-003
+ [Fact]
+ public void TheYishuvIsBuiltOnTheExactTurnWithTheTurnsEndDate()
+ {
+ var c = Town();
+ var s = Step(c, WithHalutz(c, out var id), Build(id)).State; // the end of turn T
+ s = Step(c, s).State; // T+1
+ Assert.Equal(1, s.Sites["site_a"].TurnsLeft);
+ Assert.True(Projects.IsBusy(s, id));
+ var r = Step(c, s); // T+2: built
+ var work = r.State.Sites["site_a"];
+ Assert.Equal(r.State.Date, work.BuiltOn); // the turn's end date
+ Assert.False(Projects.IsBusy(r.State, id)); // the unit is idle again (question 10: it stays a halutz unit)
+ Assert.Equal("halutz", r.State.Units[id].Type);
+ Assert.Contains(r.Why, x => x.System == "map" && x.Message == "Site A founded");
+ Assert.Equal("Site A is already built", Assert.Single(Step(c, r.State, Build(id)).Rejected).Reason);
+ }
+
+ /// <summary>The timing rule, the same reading of D-A6 as training's (R-TRAIN-003): the turn of the order is the first build
+ /// turn, so with build_yishuv_turns 6 an order on turn T is built at the end of turn T+5.</summary>
+ // R-SITE-001, R-SITE-003
+ [Fact]
+ public void AnOrderOnTurnTWithSixTurnsIsBuiltAtTheEndOfTurnTPlusFive()
+ {
+ Assert.Equal(6, Mvp.RulesAt(Mvp.Eras[0].From).Mvp!.BuildYishuvTurns);
+ var s = Simulation.NewGame(Mvp, GoldenRun.Seed, Mode.Historical);
+ var id = s.NextId++;
+ s.Units.Add(id, new Unit(id, "halutz", -3, 19));
+ s = Step(Mvp, s, Build(id, "mefalsim")).State; // the end of turn T
+ for (int turn = 1; turn <= 4; turn++) s = Step(Mvp, s).State; // T+1 to T+4
+ Assert.Null(s.Sites["mefalsim"].BuiltOn);
+ var built = Step(Mvp, s).State; // T+5
+ Assert.Equal(built.Date, built.Sites["mefalsim"].BuiltOn);
+ }
+
+ // R-SITE-003, R-TRAIN-003: training (step 4) runs in the resolver, after the orders, so a halutz group that finishes
+ // training on turn T is a unit from the end of T and can be ordered on T+1, not on T.
+ [Fact]
+ public void AHalutzTrainedThisTurnCanBeOrderedNextTurn()
+ {
+ var c = Town();
+ var s = Step(c, Simulation.NewGame(c, 1, Mode.Historical), new Train("town_a", "halutz", 1)).State;
+ var id = s.NextId; // the cohort took an id; the unit takes the next one when it finishes
+ s = Step(c, s).State;
+ Assert.Empty(s.Units);
+ var last = Step(c, s, Build(id)); // the turn it finishes: there is no unit yet when the order is read
+ Assert.Equal("There is no such unit", Assert.Single(last.Rejected).Reason);
+ Assert.Equal(id, Assert.Single(last.State.Units.Keys));
+ Assert.Empty(Step(c, last.State, Build(id)).Rejected);
+ }
+
+ // R-SITE-003: sites advance in ordinal id order; two that finish on the same turn are founded in that order.
+ [Fact]
+ public void TwoSitesAdvanceInIdOrder()
+ {
+ var c = Town(new Dictionary<string, string> { ["sites.yaml"] = TwoSites() });
+ var s = WithHalutz(c, out var a);
+ var b = s.NextId++;
+ s.Units.Add(b, new Unit(b, "halutz", 1, 0));
+ s = Step(c, s, Build(a, "site_b"), Build(b, "site_a")).State;
+ s = Step(c, s).State;
+ var why = Step(c, s).Why.Where(x => x.Message.EndsWith(" founded", StringComparison.Ordinal)).Select(x => x.Message);
+ Assert.Equal(new[] { "Site A founded", "Site B founded" }, why);
+ }
+
+ // R-SITE-003 (D-A6): construction is step 5, after training (4) and before production (6).
+ [Fact]
+ public void ConstructionRunsAfterTrainingAndBeforeProduction()
+ {
+ var c = Town();
+ var s = WithHalutz(c, out var id);
+ s = Step(c, s, Build(id), new Train("town_a", "halutz", 1)).State; // both end on T+2
+ var why = Step(c, Step(c, s).State).Why.Select(x => x.Message).ToList();
+ var trained = why.FindIndex(m => m.Contains("finished pioneer training"));
+ var founded = why.IndexOf("Site A founded");
+ var paid = why.FindIndex(m => m.Contains("jobs paid"));
+ Assert.True(trained >= 0 && founded > trained && paid > founded, string.Join(" | ", why));
+ }
+
+ // R-SITE-003 (question 11): in Phase 1 a built site is only marked built. No city, housing, jobs, people or Money change.
+ [Fact]
+ public void BuildingChangesNoCity()
+ {
+ var c = Town();
+ var start = WithHalutz(c, out var id);
+ var built = start; var idle = start;
+ built = Step(c, built, Build(id)).State; idle = Step(c, idle).State;
+ for (int i = 0; i < 2; i++) { built = Step(c, built).State; idle = Step(c, idle).State; }
+ Assert.NotNull(built.Sites["site_a"].BuiltOn);
+ Assert.Equal(idle.Cities.Values.Select(x => x.Canonical()), built.Cities.Values.Select(x => x.Canonical()));
+ Assert.Equal(idle.Units.Values.Select(x => x.Canonical()), built.Units.Values.Select(x => x.Canonical()));
+ Assert.Equal(idle.Cohesion, built.Cohesion);
+ Assert.Equal(idle.Treasury - 1.5, built.Treasury, 9); // only the cost paid at the start: founding adds no Money
+ Assert.Equal(idle.Debt, built.Debt);
+ }
+
+ [Fact]
+ public void TheResolverBuildsNothingInTheLegacyLoop()
+ {
+ var c = ContentLoader.Load(RealContentTests.ContentRoot());
+ var s = Step(c, Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical)).State;
+ Assert.Empty(s.Sites);
+ Assert.DoesNotContain("site{", s.Describe());
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs b/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs
index 9102b6f7b..6d6d32378 100644
--- a/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs
+++ b/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@@ -27,9 +28,9 @@ public class ReferencePlayerTests
}
// R-TRAIN-001: the stated policy trains a halutz group only when there is none, none in training, a civilian without
- // work, and the Treasury and Attention to pay.
+ // work, and the Attention to pay. Training borrows, so Money does not hold it back (owner decision, 2026-10-15).
[Fact]
- public void ItTrainsNoHalutzWhenOneExistsOrTrainsOrNobodyIsFreeOrMoneyIsShort()
+ public void ItTrainsNoHalutzWhenOneExistsOrTrainsOrNobodyIsFreeButDoesWithNoMoney()
{
var s = Simulation.NewGame(Mvp, GoldenRun.Seed, Mode.Historical);
var training = Simulation.Step(Mvp, s, ReferencePlayer.Commands(Mvp, s)).State;
@@ -47,8 +48,77 @@ public class ReferencePlayerTests
busy.Cities["tel_aviv"] = busy.Cities["tel_aviv"].WithCounts(90, 80, 0); // 90 jobs: all of them filled
Assert.DoesNotContain(ReferencePlayer.Commands(Mvp, busy), x => x is Train);
var poor = s.Clone();
- poor.Treasury = 0.4;
- Assert.DoesNotContain(ReferencePlayer.Commands(Mvp, poor), x => x is Train);
+ poor.Treasury = 0; // training borrows (owner decision, 2026-10-15): an empty Treasury does not hold it back
+ Assert.Contains(ReferencePlayer.Commands(Mvp, poor), x => x is Train);
+ }
+
+ // R-SITE-001: the stated policy sends each idle halutz group, in id order, to the first available yishuv site in id order.
+ // Pioneer work borrows (question 13, owner decision 2026-10-15), so an empty Treasury does not hold it back.
+ [Fact]
+ public void ItSendsAnIdleHalutzToTheFirstAvailableSite()
+ {
+ var s = Simulation.NewGame(Mvp, GoldenRun.Seed, Mode.Historical);
+ s.Units.Add(7, new Unit(7, "halutz", -3, 19));
+ s.Units.Add(8, new Unit(8, "halutz", -3, 19));
+ s.NextId = 9;
+ s.Treasury = 10;
+ var build = Assert.Single(ReferencePlayer.Commands(Mvp, s).OfType<PioneerWork>()); // one site: the second group waits
+ Assert.Equal((7, "build_yishuv", "mefalsim"), (build.Unit, build.Action, build.Site));
+ Assert.Empty(Simulation.Step(Mvp, s, ReferencePlayer.Commands(Mvp, s)).Rejected);
+
+ var building = s.Clone();
+ building.Sites["mefalsim"] = new SiteWork("mefalsim", 7, 3, null);
+ Assert.DoesNotContain(ReferencePlayer.Commands(Mvp, building), x => x is PioneerWork);
+ var built = s.Clone();
+ built.Sites["mefalsim"] = SiteWork.Built("mefalsim", new DateTime(1949, 6, 15));
+ Assert.DoesNotContain(ReferencePlayer.Commands(Mvp, built), x => x is PioneerWork);
+ var poor = s.Clone();
+ poor.Treasury = 0;
+ Assert.Contains(ReferencePlayer.Commands(Mvp, poor), x => x is PioneerWork);
+ }
+
+ /// <summary>The GDD fixture with two yishuv sites, site_a on (2, 0) and site_b on (3, 0), and pioneer_work priced at
+ /// <paramref name="cost"/> Attention.</summary>
+ static Content TwoSites(int cost) => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>
+ {
+ ["sites.yaml"] = Fixture.GddSites + Fixture.GddSites.Replace("sites:\n", "").Replace("site_a", "site_b").Replace("Site A", "Site B").Replace("q: 2", "q: 3"),
+ ["rules.yaml"] = Fixture.Files["rules.yaml"].Replace("map_action: 1 }", Fixture.GddCosts.Replace("pioneer_work: 0", "pioneer_work: " + cost)) + Fixture.GddRules,
+ })));
+
+ static GameState TwoHalutzim(Content c)
+ {
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ for (int i = 0; i < 2; i++) { var id = s.NextId++; s.Units.Add(id, new Unit(id, "halutz", 1, 0)); }
+ return s;
+ }
+
+ // R-SITE-001: a busy unit is not sent again, even when another site is free; the idle one takes it.
+ [Fact]
+ public void ItSendsNoBusyUnit()
+ {
+ var c = TwoSites(0);
+ var s = TwoHalutzim(c);
+ var (busy, idle) = (s.Units.Keys[0], s.Units.Keys[1]);
+ s.Sites["site_a"] = new SiteWork("site_a", busy, 2, null);
+ var build = Assert.Single(ReferencePlayer.Commands(c, s).OfType<PioneerWork>());
+ Assert.Equal((idle, "site_b"), (build.Unit, build.Site));
+ }
+
+ // R-SITE-001: the policy sends builds only while the turn's Attention lasts (the slice prices them at 0; this fixture at 1).
+ [Fact]
+ public void ItSendsNoMoreBuildsThanAttentionPays()
+ {
+ var c = TwoSites(1);
+ var s = TwoHalutzim(c);
+ s.Cities["town_a"] = s.Cities["town_a"].WithCounts(8, 8, 0); // the jobs are filled: no AssignWorkers takes Attention
+ var history = HistoricalAI.Commands(c, s).Sum(x => AttentionSystem.Cost(c, s, x.Kind));
+ var price = AttentionSystem.Cost(c, s, Projects.PioneerKind);
+ Assert.True(price > 0);
+ s.Attention = history + price * 1.5; // one build, not two
+ var build = Assert.Single(ReferencePlayer.Commands(c, s).OfType<PioneerWork>());
+ Assert.Equal((s.Units.Keys[0], "site_a"), (build.Unit, build.Site));
+ s.Attention = history + price * 0.5;
+ Assert.DoesNotContain(ReferencePlayer.Commands(c, s), x => x is PioneerWork);
}
[Fact]
diff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
index 1d8011b84..8da46f85c 100644
--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs
+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
@@ -29,7 +29,8 @@ public class SaveGameTests
new Command[] { new SetPolicy("odd id with spaces%", 0.5), new MapAction("transit_camp", 4, 0) },
new Command[] { new AssignWorkers("town_a", "job", 1) }, // a GDD order: the legacy fixture refuses it
new Command[] { new Train("town_a", "halutz", 1), new CancelTraining(1) }, // GDD orders too
- new Command[] { new SecurityOrder(1) }, new Command[0], new Command[0],
+ new Command[] { new PioneerWork(1, "build_yishuv", "site_a"), new StopWork(1) },
+ new Command[] { new SecurityOrder(1) }, new Command[0],
};
foreach (var o in orders) g.Step(o);
return g;
diff --git a/sim/Statecraft.Sim.Tests/SitesContentTests.cs b/sim/Statecraft.Sim.Tests/SitesContentTests.cs
new file mode 100644
index 000000000..cceacdd12
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/SitesContentTests.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using Statecraft.Sim;
+using YamlDotNet.Serialization;
+
+/// <summary>The designated sites (Phase 1 PR 5, Task 5.1): content/sites.yaml holds sourced facts only (the site, its names,
+/// hex, founding date and sources); the build turns and cost are placeholders in MvpSlice.Overlay or test fixtures (ruling 2).
+/// The loader reads sites.yaml only when systems.loop is gdd, so the legacy content hash does not move.</summary>
+public class SitesContentTests
+{
+ static Content Load(Dictionary<string, string>? extra = null) => ContentLoader.Load(Fixture.Write(Fixture.Gdd(extra)));
+
+ [Fact]
+ public void TheGddFixtureLoadsItsSiteAndBuildRules()
+ {
+ var c = Load();
+ var site = Assert.Single(c.Sites);
+ Assert.Equal(("site_a", "Site A", "אתר א", 2, 0), (site.Id, site.Name, site.NameHe, site.Q, site.R));
+ Assert.Equal(new[] { "yishuv" }, site.Kinds);
+ Assert.Equal(new DateTime(1949, 6, 12), site.Founded);
+ Assert.Equal("fact-checked", site.Status);
+ Assert.Equal(new DateTime(2026, 10, 14), Assert.Single(site.Sources).Checked);
+ var mvp = c.RulesAt(c.Eras[0].From).Mvp!;
+ Assert.Equal((3, 1.5), (mvp.BuildYishuvTurns, mvp.BuildYishuvCost));
+ }
+
+ [Fact]
+ public void TheLegacyLoopReadsNoSites()
+ {
+ var c = ContentLoader.Load(RealContentTests.ContentRoot());
+ Assert.Empty(c.Sites);
+ }
+
+ /// <summary>Owner decision (#378, 14 October 2026): the Phase 1 site is Mefalsim, founded 12 June 1949 (the ceremony of
+ /// going onto the land, question 5), at the hex of its present coordinates (question 3), from the research in #459.</summary>
+ [Fact]
+ public void TheSliceHasMefalsimFromContent()
+ {
+ var c = MvpSlice.Load(RealContentTests.ContentRoot());
+ var site = Assert.Single(c.Sites);
+ Assert.Equal(("mefalsim", "Mefalsim", "מפלסים", -10, 27), (site.Id, site.Name, site.NameHe, site.Q, site.R));
+ Assert.Equal(new[] { "yishuv" }, site.Kinds);
+ Assert.Equal(new DateTime(1949, 6, 12), site.Founded);
+ Assert.Equal("fact-checked", site.Status);
+ Assert.Contains(site.Sources, s => s.Url == "https://benyehuda.org/read/14684");
+ Assert.Contains(site.Sources, s => s.Url.StartsWith("https://israelalbum.org.il/", StringComparison.Ordinal));
+ Assert.All(site.Sources, s => Assert.NotEqual(default, s.Checked));
+ var mvp = c.RulesAt(c.Eras[0].From).Mvp!;
+ Assert.Equal((6, 2.0), (mvp.BuildYishuvTurns, mvp.BuildYishuvCost)); // PLACEHOLDER: owner sets (MvpSlice.Overlay)
+ Assert.Equal(0, c.Rules.AttentionCost["pioneer_work"]); // D-A6: unit orders are free
+ Assert.Equal(0, c.Rules.AttentionCost["stop_work"]);
+ }
+
+ /// <summary>Question 2 (#378, the recommendation the owner took): a designated site may sit on an armistice line hex.
+ /// Mefalsim's hex is an Egypt-Israel line hex in armistice_hexes_1949.yaml, a display-only file the sim never reads, and the
+ /// slice still loads.</summary>
+ [Fact]
+ public void ASiteOnAnArmisticeLineHexIsAllowed()
+ {
+ var root = RealContentTests.ContentRoot();
+ var map = new DeserializerBuilder().Build().Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(root, "map", "armistice_hexes_1949.yaml")));
+ var lineHexes = ((List<object>)map["line_hexes"]).Cast<List<object>>().Select(x => (int.Parse((string)x[0], CultureInfo.InvariantCulture), int.Parse((string)x[1], CultureInfo.InvariantCulture)));
+ var site = Assert.Single(MvpSlice.Load(root).Sites);
+ Assert.Contains((site.Q, site.R), lineHexes);
+ }
+
+ [Fact]
+ public void NoBalanceValueIsUnderContent()
+ {
+ var root = RealContentTests.ContentRoot();
+ var sites = File.ReadAllText(Path.Combine(root, "sites.yaml"));
+ Assert.DoesNotMatch(@"(?m)^[^#\n]*\b\w*(turns|cost)\w*\s*:|build_yishuv", sites); // no such key outside a comment
+ var overrides = Directory.Exists(Path.Combine(root, "rules")) ? Directory.GetFiles(Path.Combine(root, "rules"), "*.yaml") : new string[0];
+ foreach (var f in new[] { "rules.yaml" }.Concat(overrides.Select(x => "rules/" + Path.GetFileName(x))))
+ Assert.DoesNotMatch(@"build_yishuv|pioneer_work|stop_work", File.ReadAllText(Path.Combine(root, f)));
+ }
+
+ static string Site(string replace, string with) => Fixture.GddSites.Replace(replace, with);
+ static string Rules(string mvp) => Fixture.Files["rules.yaml"].Replace("map_action: 1 }", Fixture.GddCosts) + mvp;
+
+ public static IEnumerable<object[]> BadRows() => new List<object[]>
+ {
+ new object[] { "sites.yaml", Fixture.GddSites + Fixture.GddSites.Replace("sites:\n", ""), "sites[site_a].id", "duplicate id" },
+ new object[] { "sites.yaml", Site("name: Site A", "name: ' '"), "sites[site_a].name", "required" },
+ new object[] { "sites.yaml", Site("name_he: אתר א", "name_he: ''"), "sites[site_a].name_he", "required" },
+ new object[] { "sites.yaml", Site("q: 2", "q: 0"), "sites[site_a].q", "hex q=0 r=0 is not a land hex" },
+ new object[] { "sites.yaml", Site("q: 2", "q: 9"), "sites[site_a].q", "hex q=9 r=0 is not a land hex" },
+ new object[] { "sites.yaml", Site("q: 2", "q: 1"), "sites[site_a].q", "hex q=1 r=0 holds the 1948 settlement town_a" },
+ new object[] { "sites.yaml", Site("kinds: [yishuv]", "kinds: [yishuv, airfield]"), "sites[site_a].kinds", "unknown kind 'airfield'" },
+ new object[] { "sites.yaml", Site("founded: 1949-06-12", "founded: 1948-05-14"), "sites[site_a].founded", "between 15 May 1948 and 31 December 1951" },
+ new object[] { "sites.yaml", Site("founded: 1949-06-12", "founded: 1952-01-01"), "sites[site_a].founded", "between 15 May 1948 and 31 December 1951" },
+ new object[] { "sites.yaml", Site(" founded: 1949-06-12\n", ""), "sites[site_a].founded", "between 15 May 1948 and 31 December 1951" },
+ new object[] { "sites.yaml", Site(" sources:\n - { url: \"https://example.org/site_a\", checked: 2026-10-14 }\n", ""), "sites[site_a].sources", "required" },
+ new object[] { "sites.yaml", Site(", checked: 2026-10-14", ""), "sites[site_a].sources[0]", "url and checked date" },
+ new object[] { "sites.yaml", Site("url: \"https://example.org/site_a\"", "url: ''"), "sites[site_a].sources[0]", "url and checked date" },
+ new object[] { "sites.yaml", Site("status: fact-checked", "status: done"), "sites[site_a].status", "unknown status 'done'" },
+ new object[] { "rules.yaml", Rules(Fixture.GddRules.Replace("build_yishuv_turns: 3", "build_yishuv_turns: 0")), "mvp.build_yishuv_turns", "must be >= 1" },
+ new object[] { "rules.yaml", Rules(Fixture.GddRules.Replace("build_yishuv_cost: 1.5", "build_yishuv_cost: -1")), "mvp.build_yishuv_cost", "must be a finite number >= 0" },
+ new object[] { "rules.yaml", Rules(Fixture.GddRules.Replace("build_yishuv_cost: 1.5", "build_yishuv_cost: .nan")), "mvp.build_yishuv_cost", "must be a finite number >= 0" },
+ new object[] { "rules.yaml", Rules(Fixture.GddRules).Replace(", pioneer_work: 0", ""), "attention_cost.pioneer_work", "missing cost" },
+ new object[] { "rules.yaml", Rules(Fixture.GddRules).Replace(", stop_work: 0", ""), "attention_cost.stop_work", "missing cost" },
+ };
+
+ [Theory]
+ [MemberData(nameof(BadRows))]
+ public void ABadValueFailsNamingTheFileAndField(string file, string text, string field, string message)
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(new Dictionary<string, string> { [file] = text }));
+ Assert.Equal(file, ex.File);
+ Assert.Equal(field, ex.Field);
+ Assert.Contains(message, ex.Message);
+ }
+
+ [Fact]
+ public void TheGddLoopNeedsTheSitesFile()
+ {
+ var o = Fixture.Gdd();
+ o.Remove("sites.yaml");
+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(o)));
+ Assert.Equal("sites.yaml", ex.File);
+ Assert.Contains("missing file", ex.Message);
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/TrainingTests.cs b/sim/Statecraft.Sim.Tests/TrainingTests.cs
index bc8a86e65..033b7444d 100644
--- a/sim/Statecraft.Sim.Tests/TrainingTests.cs
+++ b/sim/Statecraft.Sim.Tests/TrainingTests.cs
@@ -77,20 +77,27 @@ public class TrainingTests
Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());
}
- // R-TRAIN-001: no borrowing for training (a choice flagged for the owner).
+ // R-TRAIN-001: training borrows the shortfall, as map actions do (owner decision "Allow borrowing", 2026-10-15, #468).
[Fact]
- public void AShortTreasuryRefusesAndChangesNothing()
+ public void AShortTreasuryBorrowsTheShortfall()
{
var c = Town();
var s = Simulation.NewGame(c, 1, Mode.Historical);
s.Treasury = 1.4;
- var r = Step(c, s, new Train("town_a", "recruit", 3));
- Assert.Equal("Training costs IL 1.5m and the Treasury holds IL 1.4m", Assert.Single(r.Rejected).Reason);
- Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());
- Assert.Empty(Step(c, s, new Train("town_a", "recruit", 2)).Rejected); // IL 1.0m is affordable
+ s.Debt = 3;
+ var after = s.Clone();
+ var why = new List<Cause>();
+ Assert.Null(Training.Start(c, after, "town_a", "recruit", 3, why));
+ Assert.Equal(0, after.Treasury);
+ Assert.Equal(3.1, after.Debt, 9); // the IL 0.1m the Treasury lacked
+ Assert.Single(after.Cohorts);
+ Assert.Contains(why, x => x.System == "economy" && x.Target == "debt" && x.Message == "Borrowed IL 0.1m for training");
+ var none = s.Clone();
+ none.Treasury = 0;
+ Assert.Empty(Step(c, none, new Train("town_a", "recruit", 3)).Rejected); // an empty Treasury trains too
}
- // R-TRAIN-001: refused only when the Treasury holds less than the cost, so a Treasury of exactly the cost pays it.
+ // R-TRAIN-001: a Treasury of exactly the cost pays it in full, with nothing borrowed.
[Fact]
public void ATreasuryOfExactlyTheCostPaysIt()
{
@@ -100,6 +107,7 @@ public class TrainingTests
var after = s.Clone();
Assert.Null(Training.Start(c, after, "town_a", "recruit", 3, new List<Cause>()));
Assert.Equal(0, after.Treasury);
+ Assert.Equal(s.Debt, after.Debt); // nothing borrowed
Assert.Single(after.Cohorts);
}
diff --git a/sim/Statecraft.Sim.Tests/golden/manifest.txt b/sim/Statecraft.Sim.Tests/golden/manifest.txt
index 04e18d3ed..7cf7ad6aa 100644
--- a/sim/Statecraft.Sim.Tests/golden/manifest.txt
+++ b/sim/Statecraft.Sim.Tests/golden/manifest.txt
@@ -7,5 +7,5 @@ hash1952 62f8ec61a14acff4eab503381994a7c94d7a2f786dcfde5c4c19439ac8b4c5e8
smoke5 d3fdd459ddb876bd8d775c20edd1202cf56ca7134a8ad06f873d4d92034aa5b6
scenario-reckless c0bd12bc481a9f2dbeea19aebc981d5347caa1e1cf2e6fd5a5acdf107f2f9045
scenario-cautious 1d5b8d7126160021963537f2a198e377b27d478f522e8c6be63babe9e1b8f482
-mvp-slice 6343eee818634ebcf60684507d7785251bc8c9ad01648f211202acad795518a2
+mvp-slice ec6f8c8039ddb276487c80e72397c0f7127b18875b5b81fc865b90eb3e851742
scenario-mvp-absorb-first 59ea3181e219ef3facbe6b5b76910b96d5c3feced0beeecd29d932295511f9fe
diff --git a/sim/Statecraft.Sim.Tests/golden/mvp-slice.txt b/sim/Statecraft.Sim.Tests/golden/mvp-slice.txt
index 9531f711c..44d2f6a5f 100644
--- a/sim/Statecraft.Sim.Tests/golden/mvp-slice.txt
+++ b/sim/Statecraft.Sim.Tests/golden/mvp-slice.txt
@@ -1,28 +1,28 @@
-1949-01-15;1948;Historical;8;
+1949-03-15;1948;Historical;10;
ind{
food_supply=0.4 [3FD999999999999A]
- housing=0.42228343009948727 [3FDB06B1147AE147]
- intl_standing=0.53 [3FE0F5C28F5C28F6]
- morale=0.6085614645767212 [3FE37955E47ECFEA]
- security=0.48869177246093765 [3FDF46B9DB22D0E8]
+ housing=0.4258016169309616 [3FDB40556CD35A85]
+ intl_standing=0.56 [3FE1EB851EB851EC]
+ morale=0.6429967672448158 [3FE4936DF4D801B4]
+ security=0.5103316220092775 [3FE054A2FB549F96]
pol{
border_settlement=0.2 [3FC999999999999A]
housing_construction=0.3 [3FD3333333333333]
maabarot=0 [0000000000000000]
rationing=0 [0000000000000000]
eff{
- border_villages_secure=0.033691772460937505 [3FA1400C49BA5E36]
- building_houses=0.0722834300994873 [3FB2812AB851EB85]
- homes_lift_morale=0.06197826633453369 [3FAFBB9D85F06F69]
+ border_villages_secure=0.03533162200927735 [3FA216FC8216C616]
+ building_houses=0.0758016169309616 [3FB367BC19B3D07C]
+ homes_lift_morale=0.06315223190546035 [3FB02ABEA2B40F66]
rationing_feeds=0 [0000000000000000]
rationing_grates=0 [0000000000000000]
- safety_lifts_morale=0.04658319824218751 [3FA7D9C0C1FC8F34]
+ safety_lifts_morale=0.049844535339355484 [3FA9853912556D1C]
shift{
food_supply=0 [0000000000000000]
housing=0 [0000000000000000]
- intl_standing=0.030000000000000027 [3F9EB851EB851EC0]
- morale=-0.050000000000000044 [BFA99999999999A0]
- security=0.15500000000000014 [3FC3D70A3D70A3DC]
+ intl_standing=0.06000000000000005 [3FAEB851EB851EC0]
+ morale=-0.020000000000000018 [BF947AE147AE1480]
+ security=0.17500000000000016 [3FC666666666666C]
bud{
agriculture_minister=0.07 [3FB1EB851EB851EC]
defense_minister=0.45 [3FDCCCCCCCCCCCCD]
@@ -33,23 +33,25 @@ bud{
labour_minister=0.1 [3FB999999999999A]
prime_minister=0.15 [3FC3333333333333]
pop{
- africa=9739.110001692712 [40C3058E1489145A]
- america_oceania=535.0499244151753 [4080B8663EC59399]
- asia=7512.155402122331 [40BD5827C86EF924]
- europe=81633.61444656934 [40F3EE19D4C5ED07]
- unknown=12145.947428858311 [40C7B8F945594CDE]
- veterans=656752.739703733 [41240AE17ABA729C]
+ africa=16110.114738040149 [40CF770EAFBC7106]
+ america_oceania=766.5856652505514 [4087F4AF71434C2D]
+ asia=19124.004078920254 [40D2AD0042D43B46]
+ europe=101592.86638564836 [40F8CD8DDCB73297]
+ unknown=13102.557782002037 [40C9974765669086]
+ veterans=658603.8958591067 [41241957CAAE0B7A]
sit[
treasury=0 [0000000000000000]
-debt=23.248732976636184 [40373FACF6E016D2]
-fx=80.85238326859616 [4054368D728D91CC]
-rung=5;cf=40;
+debt=37.47911574995227 [4042BD53AA368592]
+fx=87.53820941589427 [4055E27205E7EA92]
+rung=5;cf=32;
mob=0.8 [3FE999999999999A]
-stab=0.6151384263401847 [3FE3AF36C7F49BA2]
+stab=0.5886393017596533 [3FE2D62216C655E7]
att=4 [4010000000000000]
fired[
altalena
+ armistice_egypt
bernadotte_assassination
+ elections_1949
first_truce
idf_founding
jerusalem_ceasefire
@@ -61,16 +63,18 @@ fired[
second_truce
ten_days
pending[
- operation_horev
+ armistice_egypt
chosen{
altalena=enforce
bernadotte_assassination=outlaw
+ elections_1949=hold
first_truce=accept
idf_founding=one_army
jerusalem_ceasefire=sign
jerusalem_military_government=military_government
latrun_proposal=accept_vote
operation_hiram=launch
+ operation_horev=launch
operation_yoav=stop_at_ceasefire
second_truce=comply
ten_days=central_front
@@ -80,8 +84,10 @@ map[
mapturn=0001-01-01:0;
over=
city{
- tel_aviv=120,90,120,90,90
-coh=0.685880829015544 [3FE5F2BC5A326776]
+ tel_aviv=120,90,120,90,128
+coh=0.6358695652173914 [3FE4590B21642C86]
units[
1:halutz@-3,19
+site{
+ mefalsim=done,1949-03-15
next=2
\ No newline at end of file
diff --git a/sim/Statecraft.Sim/AttentionSystem.cs b/sim/Statecraft.Sim/AttentionSystem.cs
index 1473917bc..b8d72bc46 100644
--- a/sim/Statecraft.Sim/AttentionSystem.cs
+++ b/sim/Statecraft.Sim/AttentionSystem.cs
@@ -7,11 +7,11 @@ namespace Statecraft.Sim
public static class AttentionSystem
{
static readonly HashSet<string> Kinds = new HashSet<string>
- { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training" };
+ { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work" };
/// <summary>The kinds only the GDD v0.1 loop runs. Rules price them only when systems.loop is gdd, and the legacy loop
/// refuses them before charging Attention.</summary>
- static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training" };
+ static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work" };
public static IReadOnlyCollection<string> CommandKinds => Kinds;
diff --git a/sim/Statecraft.Sim/Commands.cs b/sim/Statecraft.Sim/Commands.cs
index ff9f769e9..2202d9417 100644
--- a/sim/Statecraft.Sim/Commands.cs
+++ b/sim/Statecraft.Sim/Commands.cs
@@ -85,6 +85,24 @@ namespace Statecraft.Sim
public CancelTraining(int cohort) { Cohort = cohort; }
}
+ /// <summary>Sends halutz unit <see cref="Unit"/> to do pioneer work <see cref="Action"/> (build_yishuv) at designated site
+ /// <see cref="Site"/> (Projects.Start, R-SITE-001). GDD v0.1 loop only.</summary>
+ public sealed class PioneerWork : Command
+ {
+ public override string Kind => Projects.PioneerKind;
+ public int Unit { get; } public string Action { get; } public string Site { get; }
+ public PioneerWork(int unit, string action, string site) { Unit = unit; Action = action; Site = site; }
+ }
+
+ /// <summary>Stops unit <see cref="Unit"/>'s pioneer work: the site is available again, and the progress and the Money spent
+ /// are lost (Projects.Stop, R-SITE-002, D-A3). GDD v0.1 loop only.</summary>
+ public sealed class StopWork : Command
+ {
+ public override string Kind => Projects.StopKind;
+ public int Unit { get; }
+ public StopWork(int unit) { Unit = unit; }
+ }
+
public sealed class Rejection
{
public Command Command { get; } public string Reason { get; }
@@ -116,6 +134,8 @@ namespace Statecraft.Sim
case AssignWorkers w: Text(w.City, "City"); Text(w.Role, "Role"); break;
case Train t: Text(t.City, "City"); Text(t.Track, "Track"); break;
case CancelTraining _: break;
+ case PioneerWork p: Text(p.Action, "Action"); Text(p.Site, "Site"); break;
+ case StopWork _: break;
case SetMobilization _: case SecurityOrder _: break;
default: throw new ArgumentException("unknown command type " + cmd.GetType().Name, "commands");
}
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index ee861e435..be6d6533c 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -324,6 +324,27 @@ namespace Statecraft.Sim
public double CohesionJobsWeight { get; set; }
/// <summary>The city every arrival lands in (Phase 1 has one city; R-CITY-003).</summary>
public string ArrivalsCity { get; set; } = "";
+ /// <summary>Turns a "build yishuv" takes, counting the turn it was ordered in (R-SITE-003).</summary>
+ public int BuildYishuvTurns { get; set; }
+ /// <summary>IL millions a "build yishuv" costs, paid in full when it starts (R-SITE-001).</summary>
+ public double BuildYishuvCost { get; set; }
+ }
+
+ /// <summary>A designated site (sites.yaml; docs/GDD.md "Pioneer work": building is allowed only at designated spots, and a
+ /// new yishuv takes its site's name). Sourced facts only: the balance values of building are rules (MvpRules).</summary>
+ public sealed class Site
+ {
+ public string Id { get; set; } = "";
+ public string Name { get; set; } = "";
+ public string NameHe { get; set; } = "";
+ public int Q { get; set; }
+ public int R { get; set; }
+ /// <summary>What pioneers may build here (yishuv).</summary>
+ public List<string> Kinds { get; set; } = new List<string>();
+ /// <summary>The historical founding date: the objective card's reference date (PR 6).</summary>
+ public DateTime Founded { get; set; }
+ public List<Source> Sources { get; set; } = new List<Source>();
+ public string Status { get; set; } = "";
}
/// <summary>A city's start values (cities.yaml, GDD "Cities and construction"). Counts are population units (D-A1).</summary>
@@ -577,6 +598,8 @@ namespace Statecraft.Sim
public List<CityStart> Cities = new List<CityStart>();
/// <summary>The GDD population and unit types (unit_types.yaml). Empty in the legacy loop.</summary>
public List<UnitType> UnitTypes = new List<UnitType>();
+ /// <summary>The GDD designated sites (sites.yaml), in file order. Empty in the legacy loop.</summary>
+ public List<Site> Sites = new List<Site>();
/// <summary>SHA-256 (lowercase hex) over every file the loader read, in read order, with CRLF read as LF. A save
/// records it; loading a save made with other content shows a warning (spec section 7).</summary>
public string Hash = "";
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index 3c621735e..f1ad850ac 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -47,6 +47,7 @@ namespace Statecraft.Sim
sealed class SettlementHexesFile { public List<SettlementHex> Settlements { get; set; } = new List<SettlementHex>(); }
sealed class CitiesFile { public List<CityStart> Cities { get; set; } = new List<CityStart>(); }
sealed class UnitTypesFile { public List<UnitType> Types { get; set; } = new List<UnitType>(); }
+ sealed class SitesFile { public List<Site> Sites { get; set; } = new List<Site>(); }
public const string HexesFile = "map/hexes.json";
public const string SettlementHexesFileName = "map/settlement_hexes.yaml";
@@ -258,6 +259,7 @@ namespace Statecraft.Sim
// the legacy content needs neither file.
c.Cities = Read<CitiesFile>(readFile, "cities.yaml").Cities;
c.UnitTypes = Read<UnitTypesFile>(readFile, "unit_types.yaml").Types;
+ c.Sites = Read<SitesFile>(readFile, "sites.yaml").Sites; // sourced facts (Phase 1 PR 5)
ValidateGdd(c, settlementIds);
}
c.BuildWindows();
@@ -905,6 +907,44 @@ namespace Statecraft.Sim
if (Math.Abs(m.CohesionHousingWeight + m.CohesionJobsWeight - 1) > 1e-9)
throw new ContentException(file, "mvp.cohesion_jobs_weight", "the two cohesion weights must sum to 1");
if (!cities.Contains(m.ArrivalsCity)) throw new ContentException(file, "mvp.arrivals_city", $"'{m.ArrivalsCity}' is not a city in cities.yaml");
+ if (m.BuildYishuvTurns < 1) throw new ContentException(file, "mvp.build_yishuv_turns", "must be >= 1");
+ if (!(m.BuildYishuvCost >= 0 && IsFinite(m.BuildYishuvCost))) throw new ContentException(file, "mvp.build_yishuv_cost", "must be a finite number >= 0");
+ }
+ ValidateSites(c);
+ }
+
+ /// <summary>What a designated site may be built as (sites.yaml kinds). Phase 1 has "build yishuv" only.</summary>
+ static readonly string[] SiteKinds = { Projects.YishuvKind };
+
+ /// <summary>The designated sites (sites.yaml, Phase 1 PR 5): sourced facts on a land hex that holds no 1948 settlement,
+ /// founded inside the MVP's years (D-B1). The armistice line hexes are not checked: that file is display only, and a
+ /// site may sit on a line hex (#378, question 2).</summary>
+ static void ValidateSites(Content c)
+ {
+ const string sf = "sites.yaml";
+ Unique(sf, "sites", c.Sites.Select(x => x.Id));
+ var from = new DateTime(1948, 5, 15);
+ var to = new DateTime(1952, 1, 1);
+ foreach (var x in c.Sites)
+ {
+ var at = $"sites[{x.Id}]";
+ Named(sf, at + ".name", x.Name);
+ Named(sf, at + ".name_he", x.NameHe);
+ var hex = c.HexAt(x.Q, x.R);
+ if (hex == null || !hex.Land)
+ throw new ContentException(sf, at + ".q", FormattableString.Invariant($"hex q={x.Q} r={x.R} is not a land hex in {HexesFile}"));
+ var settled = c.SettlementHexes.FirstOrDefault(h => h.Q == x.Q && h.R == x.R);
+ if (settled != null)
+ throw new ContentException(sf, at + ".q", FormattableString.Invariant($"hex q={x.Q} r={x.R} holds the 1948 settlement {settled.Id} ({SettlementHexesFileName})"));
+ foreach (var k in x.Kinds)
+ if (!SiteKinds.Contains(k)) throw new ContentException(sf, at + ".kinds", $"unknown kind '{k}' (yishuv)");
+ if (x.Founded < from || x.Founded >= to)
+ throw new ContentException(sf, at + ".founded", "required, between 15 May 1948 and 31 December 1951 (the MVP's years, D-B1)");
+ if (x.Sources.Count == 0) throw new ContentException(sf, at + ".sources", "required: a designated site is a historical fact");
+ for (int i = 0; i < x.Sources.Count; i++)
+ if (x.Sources[i] == null || string.IsNullOrWhiteSpace(x.Sources[i].Url) || x.Sources[i].Checked == default)
+ throw new ContentException(sf, FormattableString.Invariant($"{at}.sources[{i}]"), "needs a url and checked date");
+ Status(sf, at + ".status", x.Status);
}
}
diff --git a/sim/Statecraft.Sim/EconomySystem.cs b/sim/Statecraft.Sim/EconomySystem.cs
index c3511d144..772b46aa7 100644
--- a/sim/Statecraft.Sim/EconomySystem.cs
+++ b/sim/Statecraft.Sim/EconomySystem.cs
@@ -34,6 +34,18 @@ namespace Statecraft.Sim
/// the one rule Flows and the Defence screen both use (M3 final review M5).</summary>
public static double MobilizationCost(Content c, DateTime date, double level, double yearFraction = 1.0) => c.RulesAt(date).MobilizationCostPerYear * level * yearFraction;
+ /// <summary>Pays <paramref name="cost"/> from the Treasury, borrowing what it lacks: the shortfall goes to Debt and the
+ /// Treasury stops at 0, as for map actions and the deficit. <paramref name="purpose"/> ends the cause ("for training").
+ /// The GDD orders pay through it (owner decision "Allow borrowing", 2026-10-15; R-TRAIN-001, R-SITE-001).</summary>
+ public static void PayOrBorrow(Content c, GameState s, double cost, string purpose, List<Cause> why)
+ {
+ s.Treasury -= cost;
+ if (s.Treasury >= 0) return;
+ s.Debt += -s.Treasury;
+ why.Add(new Cause("economy", "debt", -s.Treasury, $"borrowed {PlayerText.Money(c, "debt", -s.Treasury)} {purpose}"));
+ s.Treasury = 0;
+ }
+
public static void Apply(Content c, GameState s, double yearFraction, List<Cause> why)
{
var r = c.RulesAt(s.Date); var pop = s.TotalPopulation;
diff --git a/sim/Statecraft.Sim/GameState.cs b/sim/Statecraft.Sim/GameState.cs
index 5fc161ad7..17992d481 100644
--- a/sim/Statecraft.Sim/GameState.cs
+++ b/sim/Statecraft.Sim/GameState.cs
@@ -65,6 +65,8 @@ namespace Statecraft.Sim
public SortedList<int, Unit> Units = new SortedList<int, Unit>();
/// <summary>The groups in training by id (R-TRAIN-001). A cohort leaves when it finishes or is cancelled.</summary>
public SortedList<int, Cohort> Cohorts = new SortedList<int, Cohort>();
+ /// <summary>The designated sites being built or built, by site id (ordinal; R-SITE-001). An available site has no record.</summary>
+ public SortedDictionary<string, SiteWork> Sites = new SortedDictionary<string, SiteWork>(StringComparer.Ordinal);
/// <summary>The next id a new unit or training cohort takes (they share it). Ids are never reused.</summary>
public int NextId;
/// <summary>The date each completed objective was completed, by objective id (ordinal).</summary>
@@ -93,6 +95,7 @@ namespace Statecraft.Sim
c.Cities = new SortedDictionary<string, City>(Cities, StringComparer.Ordinal);
c.Units = new SortedList<int, Unit>(Units);
c.Cohorts = new SortedList<int, Cohort>(Cohorts);
+ c.Sites = new SortedDictionary<string, SiteWork>(Sites, StringComparer.Ordinal);
c.Objectives = new SortedDictionary<string, DateTime>(Objectives, StringComparer.Ordinal);
return c;
}
@@ -187,6 +190,7 @@ namespace Statecraft.Sim
}
if (Units.Count > 0) Section("units", '[', ']', Units.Values.Select(x => x.Canonical()));
if (Cohorts.Count > 0) Section("train", '[', ']', Cohorts.Values.Select(x => x.Canonical()));
+ if (Sites.Count > 0) Section("site", '{', '}', Sites.Values.Select(x => x.Canonical()));
if (NextId != 0) { Sep(); Nl(); sb.Append("next=").Append(NextId.ToString(CultureInfo.InvariantCulture)); }
if (Objectives.Count > 0)
Section("obj", '{', '}', Objectives.Select(kv => kv.Key + "=" + kv.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)));
diff --git a/sim/Statecraft.Sim/GddState.cs b/sim/Statecraft.Sim/GddState.cs
index d4afbb1b1..5007b1e09 100644
--- a/sim/Statecraft.Sim/GddState.cs
+++ b/sim/Statecraft.Sim/GddState.cs
@@ -1,3 +1,4 @@
+using System;
using System.Globalization;
namespace Statecraft.Sim
@@ -74,4 +75,36 @@ namespace Statecraft.Sim
/// <summary>The record as the state hash writes it.</summary>
public string Canonical() => string.Format(CultureInfo.InvariantCulture, "{0}:{1}@{2}x{3}/{4}", Id, Type, City, Count, TurnsLeft);
}
+
+ /// <summary>Pioneer work at a designated site (sites.yaml; R-SITE-001 to R-SITE-003): <see cref="Unit"/> building it with
+ /// <see cref="TurnsLeft"/> more turns to go, or, once <see cref="BuiltOn"/> is set, built on that date. Only sites being
+ /// built or built have a record; an available site has none. A unit is busy while a record names it (D-D6: one project per
+ /// unit), so Unit itself holds no order. Immutable; a change replaces the record.</summary>
+ public sealed class SiteWork
+ {
+ public string Site { get; }
+ /// <summary>The halutz unit building the site; null once it is built (unit ids start at 0, so 0 is a real unit).</summary>
+ public int? Unit { get; }
+ public int TurnsLeft { get; }
+ /// <summary>The end date of the turn the site was built on; null while it is being built.</summary>
+ public DateTime? BuiltOn { get; }
+
+ /// <summary>A site being built (<paramref name="builtOn"/> null) needs its unit; a built site has none.</summary>
+ public SiteWork(string site, int? unit, int turnsLeft, DateTime? builtOn)
+ {
+ if ((builtOn == null) != (unit != null)) throw new ArgumentException("a site being built has a unit, and a built site has none", nameof(unit));
+ Site = site; Unit = unit; TurnsLeft = turnsLeft; BuiltOn = builtOn;
+ }
+
+ /// <summary>The site built on <paramref name="on"/>, with no unit on it.</summary>
+ public static SiteWork Built(string site, DateTime on) => new SiteWork(site, null, 0, on);
+
+ /// <summary>The same work with <paramref name="turnsLeft"/> turns to go.</summary>
+ public SiteWork WithTurnsLeft(int turnsLeft) => new SiteWork(Site, Unit, turnsLeft, BuiltOn);
+
+ /// <summary>The record as the state hash writes it: "id=b,UNIT,TURNSLEFT" while building, "id=done,yyyy-MM-dd" once built.</summary>
+ public string Canonical() => BuiltOn is DateTime on
+ ? Site + "=done," + on.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
+ : string.Format(CultureInfo.InvariantCulture, "{0}=b,{1},{2}", Site, Unit, TurnsLeft);
+ }
}
diff --git a/sim/Statecraft.Sim/MvpGolden.cs b/sim/Statecraft.Sim/MvpGolden.cs
index 5e5f73a30..95949053a 100644
--- a/sim/Statecraft.Sim/MvpGolden.cs
+++ b/sim/Statecraft.Sim/MvpGolden.cs
@@ -8,8 +8,9 @@ namespace Statecraft.Sim
/// reference player (D-A7: HistoricalAI's orders, then the jobs filled), until Until.</summary>
public static class MvpGolden
{
- /// <summary>Eight monthly turns from 15 May 1948. A test choice, not a balance value.</summary>
- public static readonly DateTime Until = new DateTime(1949, 1, 15);
+ /// <summary>Ten monthly turns from 15 May 1948: long enough for the reference player's build at Mefalsim, started on
+ /// 15 September 1948, to finish on 15 March 1949 (GDD Phase 1 PR 5). A test choice, not a balance value.</summary>
+ public static readonly DateTime Until = new DateTime(1949, 3, 15);
public static GameState Play(Content c)
{
diff --git a/sim/Statecraft.Sim/MvpSlice.cs b/sim/Statecraft.Sim/MvpSlice.cs
index 713151087..922e6cb84 100644
--- a/sim/Statecraft.Sim/MvpSlice.cs
+++ b/sim/Statecraft.Sim/MvpSlice.cs
@@ -84,12 +84,17 @@ cities:
["cohesion_housing_weight"] = 0.5, // PLACEHOLDER (D-C1 open)
["cohesion_jobs_weight"] = 0.5, // PLACEHOLDER (D-C1 open; the two weights sum to 1)
["arrivals_city"] = "tel_aviv", // Phase 1 has one city: every arrival lands there
+ ["build_yishuv_turns"] = 6, // PLACEHOLDER: owner sets (D-A3: durations are the owner's)
+ ["build_yishuv_cost"] = 2, // PLACEHOLDER: owner sets (IL millions, paid at the start)
};
if (root.TryGetValue("attention_cost", out var ac) && ac is Dictionary<object, object> costs)
{
if (!costs.ContainsKey("assign_workers")) costs["assign_workers"] = 0.5; // PLACEHOLDER: owner sets
if (!costs.ContainsKey("train")) costs["train"] = 1; // PLACEHOLDER: owner sets
if (!costs.ContainsKey("cancel_training")) costs["cancel_training"] = 0.5; // PLACEHOLDER: owner sets
+ // D-A6 (#456): "unit orders free". The plan's reading of a decided answer, not a placeholder (#378).
+ if (!costs.ContainsKey("pioneer_work")) costs["pioneer_work"] = 0;
+ if (!costs.ContainsKey("stop_work")) costs["stop_work"] = 0;
}
return Writer.Serialize(root);
}
diff --git a/sim/Statecraft.Sim/PlayerText.cs b/sim/Statecraft.Sim/PlayerText.cs
index 52358a6e7..9c314af2d 100644
--- a/sim/Statecraft.Sim/PlayerText.cs
+++ b/sim/Statecraft.Sim/PlayerText.cs
@@ -38,6 +38,9 @@ namespace Statecraft.Sim
/// <summary>The display name of a settlement (map/settlements_1948.yaml name), such as a GDD city.</summary>
public static string Settlement(Content c, string id) => c.SettlementNames.TryGetValue(id, out var name) ? name : throw Unknown("settlement", id);
+ /// <summary>The display name of a designated site (sites.yaml name), never its id.</summary>
+ public static string Site(Content c, string id) => c.Sites.FirstOrDefault(x => x.Id == id)?.Name ?? throw Unknown("site", id);
+
/// <summary>The display name of what a cause changes: an indicator or policy (model.yaml names), or money
/// (model.yaml money).</summary>
public static string Target(Content c, string id) =>
diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.cs
new file mode 100644
index 000000000..72e6c70b9
--- /dev/null
+++ b/sim/Statecraft.Sim/Projects.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Statecraft.Sim
+{
+ /// <summary>The GDD v0.1 pioneer work (docs/GDD.md "Pioneer work"; Phase 1 PR 5): a halutz unit builds a yishuv at a
+ /// designated site (sites.yaml) over several turns (D-A3), one project per unit (D-D6). Runs only when eras.yaml
+ /// systems.loop is gdd. The answers to #378's open questions are the plan's recommendations, which the owner took on
+ /// 14 October 2026: the unit works from where it stands (9), stays a halutz unit when the yishuv is founded (10), the
+ /// founding changes no city (11), the cost is paid in full at the start (12), a short Treasury borrows (13, the owner's decision of 15 October 2026), stopping loses
+ /// the progress (14), and one unit builds a site (15). Its causes go to the "map" group of the Why screen ("Building").</summary>
+ public static class Projects
+ {
+ public const string PioneerKind = "pioneer_work";
+ public const string StopKind = "stop_work";
+ /// <summary>The one pioneer action Phase 1 has (GDD "Pioneer work": "Build yishuv").</summary>
+ public const string BuildYishuv = "build_yishuv";
+ /// <summary>The kind of site a yishuv may be built at (sites.yaml kinds).</summary>
+ public const string YishuvKind = "yishuv";
+
+ /// <summary>Whether a site being built names <paramref name="unit"/>: the unit has a project (D-D6).</summary>
+ public static bool IsBusy(GameState s, int unit) => s.Sites.Values.Any(w => w.BuiltOn == null && w.Unit == unit);
+
+ /// <summary>R-SITE-001: an idle halutz unit starts <paramref name="action"/> (build_yishuv) at a yishuv site that has no
+ /// record. The Treasury pays build_yishuv_cost now and borrows what it lacks; the site gets build_yishuv_turns to go; the unit
+ /// does not move. Refused, state untouched, for an unknown unit, a unit that is not a halutz or is busy, an unknown
+ /// action or site, a site that is not for a yishuv, or is being built or is built. Step
+ /// has already refused it in the legacy loop.</summary>
+ public static string? Start(Content c, GameState s, int unit, string action, string site, List<Cause> why)
+ {
+ if (!s.Units.TryGetValue(unit, out var u)) return "There is no such unit";
+ if (u.Type != "halutz") return "Only halutzim do pioneer work";
+ var busy = s.Sites.Values.FirstOrDefault(w => w.BuiltOn == null && w.Unit == unit);
+ if (busy != null) return $"That group of halutzim is already building {PlayerText.Site(c, busy.Site)}";
+ if (action != BuildYishuv) return "There is no such pioneer work";
+ var place = c.Sites.FirstOrDefault(x => x.Id == site);
+ if (place == null) return "There is no such site";
+ if (!place.Kinds.Contains(YishuvKind)) return $"{place.Name} is not a site for a new yishuv";
+ if (s.Sites.TryGetValue(site, out var work))
+ return work.BuiltOn == null ? $"{place.Name} is already being built" : $"{place.Name} is already built";
+ var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop
+ // Owner decision "Allow borrowing" (2026-10-15, #378 question 13): a short Treasury borrows, as map actions do.
+ EconomySystem.PayOrBorrow(c, s, r.BuildYishuvCost, "to build a yishuv", why);
+ // The same reading of D-A6 as training's: the turn of the order is the first build turn, so with
+ // build_yishuv_turns 6 an order on turn T is built at the end of T+5
+ // (ProjectsTests.AnOrderOnTurnTWithSixTurnsIsBuiltAtTheEndOfTurnTPlusFive).
+ s.Sites[site] = new SiteWork(site, unit, r.BuildYishuvTurns, null);
+ why.Add(new Cause("map", site, 1, $"{place.Name}: a group of halutzim began building a yishuv, cost {PlayerText.Money(c, "treasury", r.BuildYishuvCost)}"));
+ return null;
+ }
+
+ /// <summary>R-SITE-002 (D-A3): the unit's site loses its record, so it is available again and the unit is idle. The
+ /// progress and the Money spent are lost. Refused, state untouched, for an unknown unit or one with no work. Step has
+ /// already refused it in the legacy loop.</summary>
+ public static string? Stop(Content c, GameState s, int unit, List<Cause> why)
+ {
+ if (!s.Units.ContainsKey(unit)) return "There is no such unit";
+ var work = s.Sites.Values.FirstOrDefault(w => w.BuiltOn == null && w.Unit == unit);
+ if (work == null) return "That group of halutzim is not building anything";
+ s.Sites.Remove(work.Site);
+ why.Add(new Cause("map", work.Site, -1, $"{PlayerText.Site(c, work.Site)}: the halutzim stopped building; the Money spent is not returned"));
+ return null;
+ }
+
+ /// <summary>R-SITE-003, step 5 of the turn (spec 2026-10-12 section 2.3, D-A6): in ordinal site id order, each site being
+ /// built has one turn less to go. One that reaches 0 is built on <paramref name="next"/>, the turn's end date, and its
+ /// unit is idle again. Nothing else changes: the unit stays a halutz unit, and no city is founded (Phase 1).</summary>
+ public static void Advance(Content c, GameState s, DateTime next, List<Cause> why)
+ {
+ foreach (var w in s.Sites.Values.Where(x => x.BuiltOn == null).ToList())
+ {
+ if (w.TurnsLeft > 1) { s.Sites[w.Site] = w.WithTurnsLeft(w.TurnsLeft - 1); continue; }
+ s.Sites[w.Site] = SiteWork.Built(w.Site, next);
+ why.Add(new Cause("map", w.Site, 1, $"{PlayerText.Site(c, w.Site)} founded"));
+ }
+ }
+ }
+}
diff --git a/sim/Statecraft.Sim/Reference/ReferencePlayer.cs b/sim/Statecraft.Sim/Reference/ReferencePlayer.cs
index 3a9642f46..44b6979cf 100644
--- a/sim/Statecraft.Sim/Reference/ReferencePlayer.cs
+++ b/sim/Statecraft.Sim/Reference/ReferencePlayer.cs
@@ -5,9 +5,9 @@ using System.Linq;
namespace Statecraft.Sim.Reference
{
/// <summary>Test policy for the GDD goldens (D-A7): a stated simple policy, not game AI and not historical. It sends
- /// HistoricalAI's orders, then fills each city's jobs with as many civilians as there are jobs, then, when there is no
- /// halutz and none in training, trains one halutz group in the first city with a Hakhshara and a civilian left without
- /// work, while the turn's Attention and the Treasury last. It lives in Statecraft.Sim only so Unity can replay the MVP goldens (#394); no game mode or UI may reach it
+ /// HistoricalAI's orders, then fills each city's jobs with as many civilians as there are jobs, then sends each idle halutz
+ /// unit to the first available yishuv site, then, when there is no halutz and none in training, trains one halutz group in
+ /// the first city with a Hakhshara and a civilian left without work, while the turn's Attention lasts (both orders borrow). It lives in Statecraft.Sim only so Unity can replay the MVP goldens (#394); no game mode or UI may reach it
/// (ReferencePlayerTests.NoGameModeOrUiReachesIt).</summary>
public static class ReferencePlayer
{
@@ -25,9 +25,11 @@ namespace Statecraft.Sim.Reference
left -= cost;
}
var halutz = c.UnitTypes.FirstOrDefault(t => t.Id == "halutz");
- if (halutz == null || s.Units.Values.Any(u => u.Type == halutz.Id) || s.Cohorts.Values.Any(k => k.Type == halutz.Id)) return list;
+ if (halutz == null) return list;
+ Build(c, s, list, ref left);
+ if (s.Units.Values.Any(u => u.Type == halutz.Id) || s.Cohorts.Values.Any(k => k.Type == halutz.Id)) return list;
var trainCost = AttentionSystem.Cost(c, s, Training.TrainKind);
- if (trainCost > left + 1e-9 || halutz.TrainingCost > s.Treasury) return list;
+ if (trainCost > left + 1e-9) return list; // training borrows, so the Treasury does not hold it back
foreach (var city in s.Cities.Values)
{
var employed = list.OfType<AssignWorkers>().Where(a => a.City == city.Id).Select(a => a.Count).DefaultIfEmpty(city.Employed).Last();
@@ -37,5 +39,21 @@ namespace Statecraft.Sim.Reference
}
return list;
}
+
+ /// <summary>Sends each idle halutz unit, in id order, to the first yishuv site without a record, in ordinal id order,
+ /// while the turn's Attention lasts. Pioneer work borrows, so the Treasury does not hold it back.</summary>
+ static void Build(Content c, GameState s, List<Command> list, ref double left)
+ {
+ var cost = AttentionSystem.Cost(c, s, Projects.PioneerKind);
+ var taken = new HashSet<string>(s.Sites.Keys, StringComparer.Ordinal);
+ foreach (var u in s.Units.Values.Where(u => u.Type == "halutz" && !Projects.IsBusy(s, u.Id)))
+ {
+ var site = c.Sites.Where(x => x.Kinds.Contains(Projects.YishuvKind) && !taken.Contains(x.Id)).OrderBy(x => x.Id, StringComparer.Ordinal).FirstOrDefault();
+ if (site == null || cost > left + 1e-9) return;
+ list.Add(new PioneerWork(u.Id, Projects.BuildYishuv, site.Id));
+ taken.Add(site.Id);
+ left -= cost;
+ }
+ }
}
}
diff --git a/sim/Statecraft.Sim/SaveGame.cs b/sim/Statecraft.Sim/SaveGame.cs
index 3de9b4ad5..c45fa32fe 100644
--- a/sim/Statecraft.Sim/SaveGame.cs
+++ b/sim/Statecraft.Sim/SaveGame.cs
@@ -23,7 +23,7 @@ namespace Statecraft.Sim
/// turn starts the next turn's command list (one per Simulation.Step)
/// &lt;command&gt; ... policy ID LEVEL | budget OFFICE=SHARE,... | event ID OPTION | mobilize LEVEL |
/// security DELTA | appoint OFFICE PERSON | map ACTION Q R | work CITY ROLE N |
- /// train CITY TRACK N | untrain COHORT
+ /// train CITY TRACK N | untrain COHORT | pioneer UNIT ACTION SITE | stop UNIT
/// end &lt;hex&gt; GameState.Hash() after the last turn (checks the replay)
/// Doubles are IEEE bit patterns in hex, so replays are exact; strings are percent-escaped (Uri.EscapeDataString).
/// </summary>
@@ -105,6 +105,8 @@ namespace Statecraft.Sim
AssignWorkers w => $"work {Esc(w.City)} {Esc(w.Role)} {Int(w.Count)}",
Train t => $"train {Esc(t.City)} {Esc(t.Track)} {Int(t.Count)}",
CancelTraining t => $"untrain {Int(t.Cohort)}",
+ PioneerWork p => $"pioneer {Int(p.Unit)} {Esc(p.Action)} {Esc(p.Site)}",
+ StopWork w => $"stop {Int(w.Unit)}",
_ => throw new ArgumentException($"Cannot save command kind '{cmd.Kind}'", nameof(cmd)),
};
@@ -194,6 +196,8 @@ namespace Statecraft.Sim
case "work": Arity(4); return new AssignWorkers(Str(f[1]), Str(f[2]), I(f[3]));
case "train": Arity(4); return new Train(Str(f[1]), Str(f[2]), I(f[3]));
case "untrain": Arity(2); return new CancelTraining(I(f[1]));
+ case "pioneer": Arity(4); return new PioneerWork(I(f[1]), Str(f[2]), Str(f[3]));
+ case "stop": Arity(2); return new StopWork(I(f[1]));
default: throw new SaveException(line, $"unknown command '{f[0]}'");
}
}
diff --git a/sim/Statecraft.Sim/Scenario.cs b/sim/Statecraft.Sim/Scenario.cs
index 1f7dbb174..d3d134e34 100644
--- a/sim/Statecraft.Sim/Scenario.cs
+++ b/sim/Statecraft.Sim/Scenario.cs
@@ -22,7 +22,8 @@ namespace Statecraft.Sim
/// </code>
/// Kinds: set_policy (policy, level), allocate_budget (shares: {office: share}), choose_event_option (event, option),
/// set_mobilization (level), security_order (delta), appoint (office, person), map_action (action, q, r), assign_workers
- /// (city, role, count), train (city, track, count), cancel_training (cohort; GDD content only). A turn with no
+ /// (city, role, count), train (city, track, count), cancel_training (cohort), pioneer_work (unit, action, site), stop_work
+ /// (unit; GDD content only). A turn with no
/// scripted command passes; events nobody answered are delegated, as in the game. A command the sim rejects fails the run.</summary>
public sealed class Scenario
{
@@ -68,6 +69,7 @@ namespace Statecraft.Sim
["security_order"] = new[] { "delta" }, ["appoint"] = new[] { "office", "person" },
["map_action"] = new[] { "action", "q", "r" }, ["assign_workers"] = new[] { "city", "role", "count" },
["train"] = new[] { "city", "track", "count" }, ["cancel_training"] = new[] { "cohort" },
+ ["pioneer_work"] = new[] { "unit", "action", "site" }, ["stop_work"] = new[] { "unit" },
};
public static IReadOnlyCollection<string> Kinds => Allowed.Keys;
@@ -95,6 +97,8 @@ namespace Statecraft.Sim
case "assign_workers": return new AssignWorkers(Str(c, "city"), Str(c, "role"), Whole(c, "count"));
case "train": return new Train(Str(c, "city"), Str(c, "track"), Whole(c, "count"));
case "cancel_training": return new CancelTraining(Whole(c, "cohort"));
+ case "pioneer_work": return new PioneerWork(Whole(c, "unit"), Str(c, "action"), Str(c, "site"));
+ case "stop_work": return new StopWork(Whole(c, "unit"));
default: throw new InvalidDataException($"command kind '{kind}' has no builder");
}
}
@@ -133,6 +137,7 @@ namespace Statecraft.Sim
SetPolicy p => $"{p.Policy} {p.Level}", ChooseEventOption e => $"{e.EventId}/{e.OptionId}", SetMobilization m => m.Level.ToString(CultureInfo.InvariantCulture),
SecurityOrder o => o.Delta.ToString(CultureInfo.InvariantCulture), Appoint a => $"{a.Office} {a.Person}", MapAction m => $"{m.Action} {m.Q},{m.R}",
AssignWorkers w => $"{w.City} {w.Role} {w.Count}", Train t => $"{t.City} {t.Track} {t.Count}", CancelTraining t => t.Cohort.ToString(CultureInfo.InvariantCulture),
+ PioneerWork p => FormattableString.Invariant($"{p.Unit} {p.Action} {p.Site}"), StopWork w => w.Unit.ToString(CultureInfo.InvariantCulture),
_ => c.Kind,
};
}
diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.cs
index f78fe9fdc..ed8ff83c6 100644
--- a/sim/Statecraft.Sim/Simulation.cs
+++ b/sim/Statecraft.Sim/Simulation.cs
@@ -144,6 +144,10 @@ namespace Statecraft.Sim
return Training.Start(c, s, t.City, t.Track, t.Count, why);
case CancelTraining t:
return Training.Cancel(c, s, t.Cohort, why);
+ case PioneerWork p:
+ return Projects.Start(c, s, p.Unit, p.Action, p.Site, why);
+ case StopWork w:
+ return Projects.Stop(c, s, w.Unit, why);
case SecurityOrder o:
// long arithmetic: an extreme delta clamps to the ladder's end instead of wrapping around.
SecuritySystem.SetRung(c, s, (int)Math.Max(1L, Math.Min(5L, (long)s.Rung + o.Delta)), why);
diff --git a/sim/Statecraft.Sim/Training.cs b/sim/Statecraft.Sim/Training.cs
index fe251f75e..c7422720d 100644
--- a/sim/Statecraft.Sim/Training.cs
+++ b/sim/Statecraft.Sim/Training.cs
@@ -23,10 +23,10 @@ namespace Statecraft.Sim
static string Groups(int n) => n == 1 ? "1 group" : FormattableString.Invariant($"{n} groups");
/// <summary>R-TRAIN-001: <paramref name="count"/> of the city's civilians without work start training as
- /// <paramref name="track"/>, a unit type with a facility. The Treasury pays count * training_cost now; training does not
- /// borrow. The trainees leave the civilians at once, and the cohort takes the next id. Refused, state untouched, when the
- /// city or track is unknown, the count is below 1, the city has no such facility, it has fewer civilians without work,
- /// or the Treasury holds less than the cost. Step has already refused it in the legacy loop.</summary>
+ /// <paramref name="track"/>, a unit type with a facility. The Treasury pays count * training_cost now and borrows what it
+ /// lacks. The trainees leave the civilians at once, and the cohort takes the next id. Refused, state untouched, when the
+ /// city or track is unknown, the count is below 1, the city has no such facility, or it has fewer civilians without
+ /// work. Step has already refused it in the legacy loop.</summary>
public static string? Start(Content c, GameState s, string city, string track, int count, List<Cause> why)
{
if (!s.Cities.TryGetValue(city, out var x)) return "There is no such city";
@@ -38,10 +38,8 @@ namespace Statecraft.Sim
var idle = x.Civilians - x.Employed;
if (count > idle) return FormattableString.Invariant($"{name} has {idle} civilians without work");
var cost = count * type.TrainingCost;
- // PLACEHOLDER (owner question, #377): a short Treasury refuses training, where map actions borrow instead.
- if (cost > s.Treasury)
- return $"Training costs {PlayerText.Money(c, "treasury", cost)} and the Treasury holds {PlayerText.Money(c, "treasury", s.Treasury)}";
- s.Treasury -= cost;
+ // Owner decision "Allow borrowing" (2026-10-15, #468 question 1): a short Treasury borrows, as map actions do.
+ EconomySystem.PayOrBorrow(c, s, cost, "for training", why);
// PLACEHOLDER (owner question, #377): trainees leave the civilians, and housing (R-CITY-004) counts civilians only,
// so their places are free for waiting refugees while they train. Social cohesion (R-CITY-005) also moves: its
// employed share is employed over civilians, so it rises when civilians without work leave for training.
diff --git a/sim/Statecraft.Sim/TurnResolver.cs b/sim/Statecraft.Sim/TurnResolver.cs
index 132b2a43a..0a6b96c62 100644
--- a/sim/Statecraft.Sim/TurnResolver.cs
+++ b/sim/Statecraft.Sim/TurnResolver.cs
@@ -16,7 +16,7 @@ namespace Statecraft.Sim
var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop
// 1-3. Enemy orders, combat, capture: Phase 5.
Training.Progress(c, s, why); // 4. training
- // 5. Construction: PR 5.
+ Projects.Advance(c, s, next, why); // 5. construction
Cities.Produce(c, s, r, yearFraction, why); // 6. production
// 7. Consumption: Phase 2.
Cities.House(c, s, why); // 8. housing, then Social cohesion
diff --git a/tools/README.md b/tools/README.md
index 5c0eca4b9..f437f3129 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -71,7 +71,7 @@ Run from the repo root; this installs every pinned dependency (rasterio included
uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 --with pyproj==3.8.0 pytest tools/tests -q
```
-Expected: `722 passed, 4 skipped` (one waits for `content/sites.yaml`, two need skimage and scipy, and one is the headed browser check; add `--headed` and `--with websockets==15.0.1` to run it). Omitting a dependency (e.g. rasterio) silently drops tests or fails collection.
+Expected: `917 passed, 4 skipped` (two need skimage and scipy, and two are the headed browser checks; add `--headed` and `--with websockets==15.0.1` to run them). Omitting a dependency (e.g. rasterio) silently drops tests or fails collection.
## Required attribution (Copernicus DEM licence, modified data)
diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.cs
index 8ad350810..60cbc9643 100644
--- a/unity/Assets/Scripts/UI/SimBridge.cs
+++ b/unity/Assets/Scripts/UI/SimBridge.cs
@@ -9,7 +9,7 @@ namespace Statecraft.Game.UI
/// <summary>The UI's only door into the simulation (spec section 6). Holds the GameSession, collects this turn's
/// orders, runs End Turn and tells the screens to refresh. Orders take effect at End Turn, in the order given; each
/// order replaces an earlier one with the same key (one choice per event, one call-up level, one budget, one appointee
- /// per office, one policy level per policy, one build per hex).</summary>
+ /// per office, one policy level per policy, one build per hex, one pioneer order per unit).</summary>
public sealed class SimBridge
{
readonly List<Command> queue = new List<Command>();
@@ -51,6 +51,8 @@ namespace Statecraft.Game.UI
SetPolicy p => "policy:" + p.Policy,
Appoint a => "appoint:" + a.Office,
MapAction m => FormattableString.Invariant($"map:{m.Q},{m.R}"),
+ PioneerWork w => FormattableString.Invariant($"unit:{w.Unit}"),
+ StopWork w => FormattableString.Invariant($"unit:{w.Unit}"),
_ => c.Kind,
};
@@ -82,6 +84,11 @@ namespace Statecraft.Game.UI
foreach (var k in b.Shares.Keys) { var r = Unknown("budget line", k, Content.Rules.BudgetStart.Keys); if (r != null) return r; }
return null;
case SetMobilization _: case SecurityOrder _: return null;
+ // Pioneer work (#378): ids only; the sim refuses a busy unit, a built site or a short Treasury with its own reason.
+ case PioneerWork w:
+ return Unknown("unit", w.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)))
+ ?? Unknown("pioneer work", w.Action, new[] { Projects.BuildYishuv }) ?? Unknown("site", w.Site, Content.Sites.Select(x => x.Id));
+ case StopWork w: return Unknown("unit", w.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)));
default: return text["order.invalid"];
}
}
diff --git a/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs b/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs
new file mode 100644
index 000000000..8afc18604
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs
@@ -0,0 +1,61 @@
+#nullable enable
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+
+/// <summary>Pioneer work through the UI's queue (#378): PioneerWork and StopWork queue in the slice (MvpSlice) for a unit that
+/// exists, an id the content or state does not have is refused before End Turn, one order per unit, and the legacy loop's
+/// content queues neither.</summary>
+public class SimBridgeSiteTests
+{
+ static readonly Content Slice = MvpSlice.Load(Paths.Content);
+ static readonly Content Legacy = ContentLoader.Load(Paths.Content);
+ static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ static SimBridge Bridge(Content c) => new SimBridge(GameSession.New(c, GoldenRun.Seed, Mode.Historical), Text);
+
+ /// <summary>A slice bridge whose state holds one halutz unit, and its id. The unit is added to the state directly: in the
+ /// slice the Treasury is empty by the time a trained group is ready, and the queue only checks ids.</summary>
+ static (SimBridge bridge, int unit) WithAHalutz()
+ {
+ var b = Bridge(Slice);
+ var id = b.State.NextId++;
+ b.State.Units.Add(id, new Unit(id, "halutz", -3, 19));
+ return (b, id);
+ }
+
+ [Test]
+ public void BothOrdersQueueInTheSliceOnePerUnit()
+ {
+ var (b, id) = WithAHalutz();
+ Assert.IsNull(b.Queue(new PioneerWork(id, Projects.BuildYishuv, "mefalsim")));
+ Assert.IsNull(b.Queue(new StopWork(id))); // the same unit: replaces the build order
+ Assert.AreEqual(1, b.Queued.Count);
+ Assert.IsInstanceOf<StopWork>(b.Queued[0]);
+ }
+
+ [Test]
+ public void AnUnknownIdIsRefusedAndNothingIsQueued()
+ {
+ var t = Text;
+ var (b, id) = WithAHalutz();
+ Assert.AreEqual(t.Format("order.unknown", "unit", "99"), b.Queue(new PioneerWork(99, Projects.BuildYishuv, "mefalsim")));
+ Assert.AreEqual(t.Format("order.unknown", "pioneer work", "build_road"), b.Queue(new PioneerWork(id, "build_road", "mefalsim")));
+ Assert.AreEqual(t.Format("order.unknown", "site", "yeruham"), b.Queue(new PioneerWork(id, Projects.BuildYishuv, "yeruham")));
+ Assert.AreEqual(t.Format("order.unknown", "unit", "99"), b.Queue(new StopWork(99)));
+ Assert.AreEqual(0, b.Queued.Count);
+ }
+
+ [Test]
+ public void TheLegacyLoopQueuesNeither()
+ {
+ var t = Text;
+ var b = Bridge(Legacy);
+ Assert.AreEqual(t.Format("order.unknown", "unit", "1"), b.Queue(new PioneerWork(1, Projects.BuildYishuv, "mefalsim")));
+ Assert.AreEqual(t.Format("order.unknown", "unit", "1"), b.Queue(new StopWork(1)));
+ Assert.AreEqual(0, b.Queued.Count);
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs.meta b/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs.meta
new file mode 100644
index 000000000..0ddcf738c
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ea3a4789bcc145b8921b1ad29eb5ac39