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 4 PR 4, plow fields: a plowed field adds 1 Food a turn in step 6 (refs #788) (#871)
Beri13a8c8a98ef9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 49a815f28..c44492f8b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -219,6 +219,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB`docs/rules/mvp.md`, as the owner decided Q-EVT-1 to Q-EVT-4 on 17 October 2026 (#784). Hard anchors always fire, atmost 3 soft events a turn in order of `from` then id, unanswered events are delegated, and no effect is delayed; nobehaviour changes and no golden moves. `EventSystem.OptionEffects` lists every effect of an option for the event card.+- Halutzim can plow fields (refs #788, #384; D-D10, Q-FIELD-1 to Q-FIELD-3, owner, #782): `PioneerWork(unit, plow_fields,+ site)` at a yishuv's field site, ready once that yishuv is built, takes 3 turns and IL 0.5m (R-FIELD-001). Each turn+ after the cities' production, every plowed field adds 1 unit of Food to the national stock, with no workers+ (R-FIELD-002). All three numbers are labelled design values in `rules.yaml`. The reference player plows the four+ fields once the yishuv sites are taken, before the camps, so `hash1950`, `hash1952` and `mvp-end` move (docs/determinism.md).- City and town pills start with their population tier, a gold disc with a number from 1 to 9 (refs #710). The tier isstatic: it comes from the city's 1948 people in `content/cities.yaml` (#821), not from the sim's live count (owner,15 October 2026). The scale is the design value proposed on #710 and not yet ruled: tiers double from 1,000, so underdiff --git a/content/rules.yaml b/content/rules.yamlindex 46d181636..508a0720f 100644--- a/content/rules.yaml+++ b/content/rules.yaml@@ -40,6 +40,12 @@ mvp:# them ("Accept 6 turns, IL 2m", 17 October 2026, #927); the Phase 7 balance pass (#813) may tune them.build_camp_turns: 6 # DESIGN VALUE: owner-set balance, not a historical figure (D-D5, Q-CAMP-3: turns a camp build takes)build_camp_cost: 2 # DESIGN VALUE: owner-set balance, not a historical figure (D-D5, Q-CAMP-3: IL millions, paid at the start)+ # Plow fields (R-FIELD-001, R-FIELD-002; D-D10). Proposed by an agent and taken by the owner with the plan's other+ # recommendations (Q-FIELD-3, owner, 17 October 2026, #782: "1 Food a turn"): the smallest whole yield, about 0.1% of a+ # month's national need; plowing takes the recruit-training pair, the smallest project-sized values in the code.+ plow_fields_turns: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-D10, Q-FIELD-3: turns plowing takes)+ plow_fields_cost: 0.5 # DESIGN VALUE: owner-set balance, not a historical figure (D-D10, Q-FIELD-3: IL millions, paid at the start)+ field_food_per_turn: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-D10, Q-FIELD-3: Food units a plowed field adds each turn)objective_points: 100 # DESIGN VALUE: owner-set balance, not a historical figure (D-B6: points per objective)objective_bonus_per_month: 5 # DESIGN VALUE: owner-set balance, not a historical figure (D-B2: points per month early)objective_bonus_cap: 60 # DESIGN VALUE: owner-set balance, not a historical figure (D-B2: the most bonus points)diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex e32c8c970..c833ace93 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -19,8 +19,8 @@ GitHub Releases page (and, from M4, on itch.io). Steps 1–3 are a normal pull r"$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -buildTarget WebGL -executeMethod Statecraft.Game.EditorTools.Build.Web -compression brotli -shareable -logFile "$PWD/unity-build-web-br.log"git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.assetuv run tools/web_check.py unity/Builds/Web-brotli --query "golden&smoke=5" \- --expect "GOLDEN OK 1950 38c8a4844a0d7cb25076c4286e05fea75f0df9294fd29943345bce57a0ddead3" \- --expect "GOLDEN OK 1952 1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4" \+ --expect "GOLDEN OK 1950 e4ebff9b317a02b908434cedb18674608ae820e5e60769ef78272493884590c4" \+ --expect "GOLDEN OK 1952 e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857f" \--expect "SMOKE OK 5 turns 1948-10-15 2436927c8b24f28c42be0e7b5a6fe30900f2f6c6a3ba77e4be943c1f50db57cc"bash scripts/oss/package_web.sh unity/Builds/Web-brotli unity/Builds/statecraft-israel-vX.Y.Z-web.zip```diff --git a/docs/determinism.md b/docs/determinism.mdindex c683b000f..e9cad7697 100644--- a/docs/determinism.md+++ b/docs/determinism.md@@ -28,9 +28,9 @@ final `GameState.Hash()` is pinned:| Run | Ends | Hash ||---|---|---|-| to 1950-01-01 (`Hash1950`) | 1950-01-15, turn 20 | `38c8a4844a0d7cb25076c4286e05fea75f0df9294fd29943345bce57a0ddead3` |-| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4` |-| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4` |+| to 1950-01-01 (`Hash1950`) | 1950-01-15, turn 20 | `e4ebff9b317a02b908434cedb18674608ae820e5e60769ef78272493884590c4` |+| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857f` |+| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857f` |`hash1952` stops at the first turn on or after 1 January 1952, which is the game's last turn, so it is the same run as`mvp-end` (`DeterminismTests.TheWholeGameToItsEndIsFixed`). Both names are kept (spec 2026-10-12 section 3 step 6): a@@ -45,8 +45,8 @@ Check every build with:```uv run tools/web_check.py unity/Builds/Web-<compression> --query "golden&smoke=5" \- --expect "GOLDEN OK 1950 38c8a4844a0d7cb25076c4286e05fea75f0df9294fd29943345bce57a0ddead3" \- --expect "GOLDEN OK 1952 1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4" \+ --expect "GOLDEN OK 1950 e4ebff9b317a02b908434cedb18674608ae820e5e60769ef78272493884590c4" \+ --expect "GOLDEN OK 1952 e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857f" \--expect "SMOKE OK 5 turns 1948-10-15 2436927c8b24f28c42be0e7b5a6fe30900f2f6c6a3ba77e4be943c1f50db57cc"```@@ -261,3 +261,6 @@ The hash reads the state keys, so it never sees a record outside its window. An| GDD Phase 4 PR 3 | 1950 | `38c8a484` | build a training camp (R-CAMP-001, #787): once the four yishuv sites are taken, the reference player's veteran group builds the camp sites in ordinal id order. At the end of the 1950 run (1950-01-15) Camp 80 is being built (`camp_80=b,1,4`), and the debt is IL 2m higher (was `ef765972`) || GDD Phase 4 PR 3 | 1952 | `1e21fcd3` | same; at 2 turns of progress a turn (R-VET-002) Camp 80 is built on 1950-03-15 and Tzrifin on 1950-06-15. The debt is IL 4m higher (2 x IL 2m). The reference player trains no group after the first, so the new facilities (a military camp each for Hadera and Rishon LeZion, owner "Both military" on #927) change nothing else (was `7b4bffe0`) || GDD Phase 4 PR 3 | mvp-end | `1e21fcd3` | same; the same run as hash1952 (was `7b4bffe0`) |+| GDD Phase 4 PR 4 | 1950 | `e4ebff9b` | plow fields (R-FIELD-001, R-FIELD-002, #788), rebased on the training camps (#927): once the four yishuv sites are taken, the reference player's veteran group plows their fields in ordinal id order, before any camp. At the end of the 1950 run (1950-01-15) Beit Kama's field is still being plowed (`beit_kama_field=b,1,1`) instead of Camp 80 being built, and the debt is IL 1.5m lower (IL 0.5m for the field instead of IL 2m for the camp) (was `38c8a484`) |+| GDD Phase 4 PR 4 | 1952 | `e0d8212a` | same; at 2 turns of progress a turn (R-VET-002) the fields are plowed on 1950-02-15 (Beit Kama), 1950-04-15 (Gilat), 1950-06-15 (Mefalsim) and 1950-08-15 (Re'im), so Camp 80 is built on 1950-11-15 (was 1950-03-15) and Tzrifin on 1951-02-15 (was 1950-06-15). The debt is IL 2m higher (4 x IL 0.5m), and the Food stock ends 4 units higher (2736, was 2732), which lifts food_supply and stability in the fourth decimal (was `1e21fcd3`) |+| GDD Phase 4 PR 4 | mvp-end | `e0d8212a` | same; the same run as hash1952 (was `1e21fcd3`) |diff --git a/docs/gdd/build-yishuv.md b/docs/gdd/build-yishuv.mdindex 780643b41..cdffdd14b 100644--- a/docs/gdd/build-yishuv.md+++ b/docs/gdd/build-yishuv.md@@ -8,7 +8,7 @@ As a player of the MVP, I want to send a group of halutzim to build a new yishuv- Building is allowed only at designated sites, listed with their sources in `content/sites.yaml`. The first slice had 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].- Since the GDD phase of pioneer sites (#785) the MVP has four yishuv sites: Mefalsim, Beit Kama (18 April 1949), Re'im (20 October 1949) and Gilat (4 December 1949) [S4][S6]. The owner took the plan's recommendation on #782 [S7]. The Re'im and Mefalsim records cover the founding only.-- Each site has one or more kinds: `yishuv`, `field`, `swamp`, `military_camp` or `hakhshara`. A pioneer action is accepted only at a site of its kind, so `build_yishuv` is refused at a field site (R-SITE-004). A camp site names the city it trains for. At most one `yishuv` site sits in a hex; a site of another kind may share it, as each yishuv's field site does (R-SITE-005). Plowing, draining and building camps come with later PRs of that phase.+- Each site has one or more kinds: `yishuv`, `field`, `swamp`, `military_camp` or `hakhshara`. A pioneer action is accepted only at a site of its kind, so `build_yishuv` is refused at a field site (R-SITE-004). A camp site names the city it trains for. At most one `yishuv` site sits in a hex; a site of another kind may share it, as each yishuv's field site does (R-SITE-005). Plowing is in [fields-and-swamps.md](fields-and-swamps.md); draining and building camps come with later PRs of that phase.- A site is available from the game's start. It may sit on an armistice line hex, as Mefalsim's hex does [S3].- The map roster supplements this slice: the owner approved Kiryat Shmona and Beit Shemesh as designated founding sites on 17 October 2026 ([#856](https://github.com/eyalgolan/statecraft-israel/pull/856#issuecomment-6233524779)). The owner's sensitivity sign-off for them is open (#782), so they join Phase four's site list only once it is given; until then the yishuv sites are the four above. They do not replace Mefalsim or its objective. Historical founding and opening dates in the roster are reference dates, not new automatic availability gates [S8].- Moving a location in the authoring tool must preserve its identity and reference evidence, update the authored site binding consistently, and surface dependent references before saving [S8][S9].diff --git a/docs/gdd/fields-and-swamps.md b/docs/gdd/fields-and-swamps.mdnew file mode 100644index 000000000..9737681e2--- /dev/null+++ b/docs/gdd/fields-and-swamps.md@@ -0,0 +1,44 @@+# Plow fields and dry swamps++## Player story++As a player of the MVP, I want to send a group of halutzim to plow the fields of a yishuv I have built, so that the land adds a little Food to the national stock every turn (GDD "Pioneer work", "Prepare agricultural land" [S1]; decision D-D10 [S2]).++## Rules++- Each of the four yishuv sites has one field site in its hex: Mefalsim, Beit Kama, Re'im and Gilat fields. They are design placements, not historical fields (`Q-FIELD-1`, the owner took the plan's recommendations on #782 [S3]).+- `PioneerWork(unit, plow_fields, site)` sends an idle halutz unit to plow a field site. It follows the build rules: one project per unit, one unit per site, paid in full at once with borrowing, and no Attention (R-FIELD-001, R-SITE-001).+- A field is ready only once the yishuv in its hex is built. Before that the order is refused with the state unchanged (R-FIELD-001).+- Plowing takes 3 turns, counting the turn of the order, and costs IL 0.5m. Both are design values the owner may override (`Q-FIELD-3` [S3]).+- When the plowing finishes, the field site is plowed on the turn's end date and the unit is idle again (R-FIELD-001).+- A plowed field needs no workers (`Q-FIELD-2` [S3]). Each turn, in the turn's sixth step, after the cities' production, it adds 1 unit of Food to the national stock, one population unit's food for a month (R-FIELD-002, `Q-FIELD-3` [S3]).+- The effect is small on purpose: the nation eats 650 to 1,400 units of Food a turn over the MVP, so one field is about 0.1% of a month's need (`Q-FIELD-3` [S3]). In a turn with imports the import only tops the stock up by less; the field shows in the stock when foreign currency is exhausted and nothing is imported.+- The reference player of the goldens plows the lowest-id ready field once every yishuv site is taken, before any camp site (D-A7).++## Data touched++- `rules.yaml` `mvp.plow_fields_turns`, `mvp.plow_fields_cost` and `mvp.field_food_per_turn`: labelled design values, required in the GDD loop.+- `content/sites.yaml`: the four field rows of #785, unchanged. The loader now refuses a field site that is also a yishuv site.+- `GameState.Sites` (a plowed field is a built field site, so the hash format is unchanged), `GameState.Food`, `Treasury` and debt.+- No save or scenario format change: `pioneer UNIT plow_fields SITE` uses the existing line.++## Done when++- `dotnet test sim/Statecraft.sln` passes, including `FieldsTests`, `ProjectsTests` and `ReferencePlayerTests`.+- `hash1950`, `hash1952` and `mvp-end` move and are re-pinned with history rows in `docs/determinism.md`; `smoke5` and the three scenarios do not move.++## Out of scope++- The swamp half: the Hula swamp site and `dry_swamp` (#789). The site waits for the owner on #785, and a drained swamp becomes a field site there (`Q-SWAMP-1`).+- A plow button and plowed fields on the map, and fields at places other than the yishuv sites. Unity's order check (`SimBridge`) still accepts only `build_yishuv`, so the game's UI cannot send `plow_fields` until that PR adds it.++## Sources++- [S1] The game design of record, docs/GDD.md+- [S2] GDD Phase 4 plan, PR 4 and the owner questions table, docs/superpowers/plans/2026-10-15-gdd-phase-4.md+- [S3] GDD Phase 4 owner answers, https://github.com/eyalgolan/statecraft-israel/issues/782, checked 2026-10-17++## Open questions++- The design values (1 Food a turn, 3 turns, IL 0.5m) stand until the owner overrides them.+- The swamp half of this section waits for the owner's answer on the Hula site (#785).diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 80fd186c2..527b56ecc 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -84,6 +84,10 @@ R-SITE-004: Every designated site has one or more kinds from a fixed list: `yishR-SITE-005: At most one `yishuv` site sits in a hex, so a hex shows at most one new yishuv. A site of another kind may share a hex with a yishuv site, as a yishuv's field site does (Q-SITE-3).+R-FIELD-001: `PioneerWork(unit, plow_fields, site)` plows a field at a site whose kinds include `field`, by R-SITE-001 to R-SITE-003's rules, with `plow_fields_turns` and `plow_fields_cost` (labelled design values, Q-FIELD-3, decided 17 October 2026). A field site in a yishuv site's hex is ready only once that yishuv is built; before that the order is refused with the state unchanged and the Attention refunded (Q-FIELD-1, decided 17 October 2026). Built, the field site is plowed. A field site is not also a yishuv site, so building a yishuv cannot plow it; the loader refuses a row that gives it both kinds.++R-FIELD-002: Each turn in step 6, after the cities' production and in ordinal site id order, every plowed field adds `field_food_per_turn` Food units to the national stock (R-FOOD-001), with no workers (Q-FIELD-2, decided 17 October 2026). A field being plowed adds nothing. The Food arrives before the nation eats in step 7, so in a turn with imports (R-FOOD-002) the import tops the stock up by that much less. `field_food_per_turn` is 1, a labelled design value (Q-FIELD-3: "1 Food a turn"), and required in the GDD loop.+## CampsR-CAMP-001: `PioneerWork(unit, build_camp, site)` builds a training camp at a site whose kinds include `military_camp` or `hakhshara`, by R-SITE-001 to R-SITE-003's rules, with `build_camp_turns` and `build_camp_cost` (labelled design values, required in the GDD loop). One action builds either facility, as the site's kind says (Q-CAMP-3, owner, 17 October 2026, #782). Built, on the turn's end date, the camp gives the site's city (Q-CAMP-1) the site's facility, with no capacity limit, so `Train` accepts that city for the matching track from the next turn (R-TRAIN-001). A camp being built gives nothing. The facility is read from the built site's record, so the state hash gains nothing beyond the site's own record. The MVP's camp sites are Camp 80 (for Hadera) and Tzrifin (for Rishon LeZion), both `military_camp` (Q-CAMP-2, owner, 17 October 2026, #785; "Both military", owner, 17 October 2026, #927).diff --git a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs b/sim/Statecraft.Sim.Tests/DesignValuesTests.csindex ef169e15b..979059b8f 100644--- a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs+++ b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs@@ -28,6 +28,9 @@ public class DesignValuesTests("rules.yaml", "mvp.build_yishuv_cost"),("rules.yaml", "mvp.build_camp_turns"),("rules.yaml", "mvp.build_camp_cost"),+ ("rules.yaml", "mvp.plow_fields_turns"),+ ("rules.yaml", "mvp.plow_fields_cost"),+ ("rules.yaml", "mvp.field_food_per_turn"),("rules.yaml", "mvp.objective_points"),("rules.yaml", "mvp.objective_bonus_per_month"),("rules.yaml", "mvp.objective_bonus_cap"),diff --git a/sim/Statecraft.Sim.Tests/FieldsTests.cs b/sim/Statecraft.Sim.Tests/FieldsTests.csnew file mode 100644index 000000000..d12835622--- /dev/null+++ b/sim/Statecraft.Sim.Tests/FieldsTests.cs@@ -0,0 +1,187 @@+using System;+using System.Collections.Generic;+using System.Linq;+using Statecraft.Sim;++/// <summary>Plow fields (GDD Phase 4 PR 4; D-D10, GDD "Prepare agricultural land"): PioneerWork(plow_fields) at a field site+/// (R-FIELD-001) and the Food a plowed field adds in step 6 (R-FIELD-002). The owner took the plan's recommendations on #782+/// (17 October 2026): a field in each yishuv's hex, ready once that yishuv is built (Q-FIELD-1), no ongoing labour+/// (Q-FIELD-2), 1 Food a turn (Q-FIELD-3).</summary>+public class FieldsTests+{+ /// <summary>The GDD fixture with site_a's field, site_a_field, in site_a's hex. Plowing takes plow_fields_turns 2 and+ /// costs IL 0.5m; a plowed field yields field_food_per_turn 7 (fixture values, so a yield cannot pass as 1 by chance).</summary>+ static Content Town(string fieldKinds = "[field]") => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>+ {+ ["sites.yaml"] = Fixture.GddSites + FieldSite(fieldKinds),+ })));++ static string FieldSite(string kinds) => Fixture.GddSites.Replace("sites:\n", "").Replace("site_a", "site_a_field")+ .Replace("Site A", "Site A fields").Replace("kinds: [yishuv]", "kinds: " + kinds).Replace(" founded: 1949-06-12\n", "");++ static StepResult Step(Content c, GameState s, params Command[] commands) => Simulation.Step(c, s, commands);++ static GameState WithHalutz(Content c, out int id)+ {+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ id = s.NextId++;+ s.Units.Add(id, new Unit(id, "halutz", 1, 0));+ return s;+ }++ static PioneerWork Plow(int unit, string site = "site_a_field") => new PioneerWork(unit, Projects.PlowFields, site);++ /// <summary>A state whose imports are cut (the fx crisis), so the stock shows the field's Food instead of an import+ /// topping it up to its cover (R-FOOD-002).</summary>+ static GameState NoImports(Content c)+ {+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.ActiveSituations.Add(EconomySystem.FxCrisis);+ s.FxReserves = -1000;+ s.Sites["site_a"] = SiteWork.Built("site_a", new DateTime(1948, 5, 15));+ return s;+ }++ // R-FIELD-002 (Review focus 4: a field yields only after it is plowed, by the stated amount)+ [Fact]+ public void APlowedFieldAddsFoodInStepSix()+ {+ var c = Town();+ var without = NoImports(c);+ var plowed = without.Clone();+ plowed.Sites["site_a_field"] = SiteWork.Built("site_a_field", new DateTime(1948, 5, 15));+ var plowing = without.Clone();+ plowing.Units.Add(99, new Unit(99, "halutz", 1, 0)); // a site being built names its unit (SiteWork, R-VET-002)+ plowing.Sites["site_a_field"] = new SiteWork("site_a_field", 99, 5, null); // still being plowed: no Food yet++ var a = Step(c, without).State;+ var b = Step(c, plowed);+ Assert.Equal(300 - 100, a.Food); // ate a month's need, imported nothing (PoolsTests)+ Assert.Equal(a.Food + 7, b.State.Food); // exactly the yield, once+ Assert.Equal(a.Food, Step(c, plowing).State.Food);+ Assert.Contains(b.Why, w => w.System == "economy" && w.Target == "food" && w.Delta == 7 && w.Message == "Site A fields: the plowed land yielded 7 units of Food");+ }++ // R-FIELD-002, D-A6: the field's Food reaches the stock before the nation eats (step 7), so it covers part of the need. Added+ // after eating, the same turn would leave all 100 units unmet and 7 in the stock. Production (step 6's jobs income) moves+ // only the Treasury, so the order against it shows only in the order of the causes.+ [Fact]+ public void FieldFoodComesBeforeTheNationEats()+ {+ var c = Town();+ var s = NoImports(c);+ s.Sites["site_a_field"] = SiteWork.Built("site_a_field", new DateTime(1948, 5, 15));+ s.Food = 0;+ var r = Step(c, s);+ Assert.Equal((0, 100 - 7), (r.State.Food, r.State.FoodUnmet));+ // After production: town_a's jobs income is listed before the field's Food.+ var paid = r.Why.ToList().FindIndex(w => w.System == "city" && w.Message.Contains("jobs paid"));+ Assert.InRange(paid, 0, r.Why.ToList().FindIndex(w => w.Message.StartsWith("Site A fields: the plowed land")) - 1);+ }++ // R-FIELD-001 (Q-FIELD-1): a field in a yishuv's hex is ready only once that yishuv is built.+ [Theory]+ [InlineData("no record")]+ [InlineData("being built")]+ public void AFieldBeforeItsYishuvIsRefused(string yishuv)+ {+ var c = Town();+ var s = WithHalutz(c, out var id);+ if (yishuv == "being built")+ {+ s.Units.Add(99, new Unit(99, "halutz", 1, 0)); // a site being built names its unit (SiteWork, R-VET-002)+ s.Sites["site_a"] = new SiteWork("site_a", 99, 2, null);+ }+ var r = Step(c, s, Plow(id));+ Assert.Equal("Site A fields can be plowed once Site A is built", Assert.Single(r.Rejected).Reason);+ Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());+ }++ // R-FIELD-001: plowing follows R-SITE-001 to R-SITE-003. It pays in full at the start and takes its turns, counting the+ // order's; built, the field is plowed and the unit is idle again. R-FIELD-002, D-A6: plowing ends in step 5, so the field+ // already yields in step 6 of the turn it is done (imports cut, so an import cannot hide the Food).+ [Fact]+ public void PlowingPaysAtTheStartAndIsDoneAfterItsTurns()+ {+ var c = Town();+ var s = NoImports(c);+ var id = s.NextId++;+ s.Units.Add(id, new Unit(id, "halutz", 1, 0));+ var r = Step(c, s, Plow(id));+ Assert.Empty(r.Rejected);+ Assert.Equal(("site_a_field", (int?)id, 1), (r.State.Sites["site_a_field"].Site, r.State.Sites["site_a_field"].Unit, r.State.Sites["site_a_field"].TurnsLeft));+ Assert.Equal(Step(c, s).State.Treasury - 0.5, r.State.Treasury, 9);+ Assert.Contains(r.Why, x => x.System == "map" && x.Message == "Site A fields: a group of halutzim began plowing, cost IL 0.5m");++ var done = Step(c, r.State);+ Assert.Equal(done.State.Date, done.State.Sites["site_a_field"].BuiltOn); // the end of the order's turn + 1+ Assert.False(Projects.IsBusy(done.State, id));+ Assert.Contains(done.Why, x => x.System == "map" && x.Message == "Site A fields plowed");+ Assert.DoesNotContain(done.Why, x => x.Message.Contains("founded"));+ var unplowed = r.State.Clone();+ unplowed.Sites.Remove("site_a_field");+ Assert.Equal(Step(c, unplowed).State.Food + 7, done.State.Food); // this turn's step 6, not the next turn's+ }++ // R-FIELD-001 follows R-SITE-002 (D-A3): a plow can be stopped; the progress is lost and the IL 0.5m is not returned.+ [Fact]+ public void StoppingAPlowFreesTheUnitAndTheFieldAndReturnsNoMoney()+ {+ var c = Town();+ var s = WithHalutz(c, out var id);+ s.Sites["site_a"] = SiteWork.Built("site_a", new DateTime(1948, 5, 15));+ var started = Step(c, s, Plow(id));+ var stopped = Step(c, started.State, new StopWork(id));+ Assert.Empty(stopped.Rejected);+ Assert.False(stopped.State.Sites.ContainsKey("site_a_field"));+ Assert.False(Projects.IsBusy(stopped.State, id));+ Assert.Equal(Step(c, started.State).State.Treasury, stopped.State.Treasury, 9); // the IL 0.5m paid stays paid+ Assert.Contains(stopped.Why, x => x.System == "map" && x.Message == "Site A fields: the halutzim stopped building; the Money spent is not returned");+ var again = Step(c, stopped.State, Plow(id)); // the field is available again, from the start+ Assert.Empty(again.Rejected);+ Assert.Equal(started.State.Sites["site_a_field"].TurnsLeft, again.State.Sites["site_a_field"].TurnsLeft);+ }++ // R-SITE-004, R-FIELD-001: each action only at its own kind of site.+ [Fact]+ public void PlowingIsRefusedAtAYishuvSite()+ {+ var c = Town();+ var s = WithHalutz(c, out var id);+ var r = Step(c, s, Plow(id, "site_a"));+ Assert.Equal("Site A is not a site for fields", Assert.Single(r.Rejected).Reason);+ Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());+ }++ // R-FIELD-001: a field site's built record is its plowed state, so a field site is not also a yishuv site (a built yishuv+ // on it would yield Food), and the field rules are required in the GDD loop, so a missing key is never read as 0.+ [Theory]+ [InlineData("kinds", "sites.yaml", "a field site cannot also be a yishuv site")]+ [InlineData("plow_fields_turns", "rules.yaml", "mvp.plow_fields_turns")]+ [InlineData("plow_fields_cost", "rules.yaml", "mvp.plow_fields_cost")]+ [InlineData("field_food_per_turn", "rules.yaml", "mvp.field_food_per_turn")]+ public void BadFieldContentFailsLoad(string what, string file, string message)+ {+ var files = Fixture.Gdd(new Dictionary<string, string> { ["sites.yaml"] = Fixture.GddSites + FieldSite(what == "kinds" ? "[field, yishuv]" : "[field]") });+ if (what != "kinds") files["rules.yaml"] = files["rules.yaml"].Replace(what switch+ {+ "plow_fields_turns" => " plow_fields_turns: 2\n",+ "plow_fields_cost" => " plow_fields_cost: 0.5\n",+ _ => " field_food_per_turn: 7\n",+ }, "");+ var e = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(files)));+ Assert.Equal(file, e.File);+ Assert.Contains(message, e.Message);+ }++ // The real content: every field site lies in a yishuv's hex (Q-FIELD-1), and the design values are those of Q-FIELD-3.+ [Fact]+ public void TheRealFieldsAreThePlannedOnes()+ {+ var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var m = c.Rules.Mvp!;+ Assert.Equal((1, 3, 0.5), (m.FieldFoodPerTurn!.Value, m.PlowFieldsTurns, m.PlowFieldsCost!.Value));+ foreach (var f in c.Sites.Where(x => x.Kinds.Contains(Projects.FieldKind)))+ Assert.Contains(c.Sites, y => y.Kinds.Contains(Projects.YishuvKind) && (y.Q, y.R) == (f.Q, f.R));+ }+}diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.csindex 6b70c9a4c..6536725d0 100644--- a/sim/Statecraft.Sim.Tests/Fixture.cs+++ b/sim/Statecraft.Sim.Tests/Fixture.cs@@ -224,6 +224,9 @@ mvp:build_yishuv_cost: 1.5build_camp_turns: 2build_camp_cost: 1+ plow_fields_turns: 2+ plow_fields_cost: 0.5+ field_food_per_turn: 7objective_points: 100objective_bonus_per_month: 5objective_bonus_cap: 60diff --git a/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs b/sim/Statecraft.Sim.Tests/ReferencePlayerTests.csindex 205f45a48..bdb56f9a0 100644--- a/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs+++ b/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs@@ -104,14 +104,27 @@ public class ReferencePlayerTestsAssert.Empty(Simulation.Step(Mvp, s, ReferencePlayer.Commands(Mvp, s)).Rejected);var oneLeft = s.Clone();+ oneLeft.Units.Add(9, new Unit(9, "halutz", -3, 19)); // a site being built names its unit (SiteWork, R-VET-002)+ oneLeft.NextId = 10;oneLeft.Sites["beit_kama"] = new SiteWork("beit_kama", 9, 3, null);oneLeft.Sites["gilat"] = SiteWork.Built("gilat", new DateTime(1949, 6, 15));oneLeft.Sites["mefalsim"] = SiteWork.Built("mefalsim", new DateTime(1949, 6, 15));- // One yishuv site left: the first group takes it, and the second builds the first camp site (R-CAMP-001).- var lastTwo = ReferencePlayer.Commands(Mvp, oneLeft).OfType<PioneerWork>().Select(b => (b.Unit, b.Action, b.Site));- Assert.Equal(new[] { (7, "build_yishuv", "reim"), (8, "build_camp", "camp_80") }, lastTwo);- var none = oneLeft.Clone(); // every yishuv and camp site taken: the idle group waits+ // One yishuv site left: the first group takes it, and the second plows the first ready field (R-FIELD-001).+ var last = ReferencePlayer.Commands(Mvp, oneLeft).OfType<PioneerWork>().ToList();+ Assert.Equal(new[] { (7, "build_yishuv", "reim"), (8, "plow_fields", "gilat_field") }, last.Select(b => (b.Unit, b.Action, b.Site)));+ var none = oneLeft.Clone();none.Sites["reim"] = new SiteWork("reim", 7, 3, null);+ // Every yishuv site taken: the idle group plows the first ready field, gilat_field (beit_kama is still being built,+ // so its field is not ready).+ var plow = Assert.Single(ReferencePlayer.Commands(Mvp, none).OfType<PioneerWork>());+ Assert.Equal((8, "plow_fields", "gilat_field"), (plow.Unit, plow.Action, plow.Site));+ Assert.Empty(Simulation.Step(Mvp, none, ReferencePlayer.Commands(Mvp, none)).Rejected);+ // Every ready field taken too: the idle group builds the first camp site (R-CAMP-001).+ none.Sites["gilat_field"] = SiteWork.Built("gilat_field", new DateTime(1949, 6, 15));+ none.Sites["mefalsim_field"] = SiteWork.Built("mefalsim_field", new DateTime(1949, 6, 15));+ var camp = Assert.Single(ReferencePlayer.Commands(Mvp, none).OfType<PioneerWork>());+ Assert.Equal((8, "build_camp", "camp_80"), (camp.Unit, camp.Action, camp.Site));+ // Every camp site taken as well: the idle group waits.none.Sites["camp_80"] = SiteWork.Built("camp_80", new DateTime(1949, 6, 15));none.Sites["tzrifin"] = SiteWork.Built("tzrifin", new DateTime(1949, 6, 15));Assert.DoesNotContain(ReferencePlayer.Commands(Mvp, none), x => x is PioneerWork);diff --git a/sim/Statecraft.Sim.Tests/golden/hash1950.txt b/sim/Statecraft.Sim.Tests/golden/hash1950.txtindex 2a2764e0f..fc301b8ca 100644--- a/sim/Statecraft.Sim.Tests/golden/hash1950.txt+++ b/sim/Statecraft.Sim.Tests/golden/hash1950.txt@@ -43,7 +43,7 @@ pop{veterans=667938.2378207468 [4124624479C3A414]sit[treasury=0 [0000000000000000]-debt=79.50032828298673 [4053E00560EB2C47]+debt=78.00032828298673 [4053800560EB2C47]fx=94.52989672613671 [4057A1E9D3F540F0]rung=2;cf=0;mob=0.05 [3FA999999999999A]@@ -118,7 +118,7 @@ units[1:veteran_halutz@-3,19/6site{beit_kama=done,1949-03-15- camp_80=b,1,4+ beit_kama_field=b,1,1gilat=done,1949-06-15mefalsim=done,1949-09-15reim=done,1949-12-15diff --git a/sim/Statecraft.Sim.Tests/golden/hash1952.txt b/sim/Statecraft.Sim.Tests/golden/hash1952.txtindex 1fe64b8aa..fa584b988 100644--- a/sim/Statecraft.Sim.Tests/golden/hash1952.txt+++ b/sim/Statecraft.Sim.Tests/golden/hash1952.txt@@ -1,6 +1,6 @@1952-01-15;1948;Historical;44;ind{- food_supply=0.8555155874508137 [3FEB606239AA391F]+ food_supply=0.8556115107122045 [3FEB612B6412E1DF]housing=0.43504947742483624 [3FDBD7D9C36B9EB6]intl_standing=0.7800000000000002 [3FE8F5C28F5C28F8]morale=0.5690955554429493 [3FE23607E1DDA540]@@ -44,11 +44,11 @@ pop{sit[fx_crisistreasury=0 [0000000000000000]-debt=180.89012071283815 [40669C7BDE6EE43A]+debt=182.89012071283815 [4066DC7BDE6EE43A]fx=-12.990431328096559 [C029FB19D0A63796]rung=2;cf=0;mob=0.05 [3FA999999999999A]-stab=0.5682965036166527 [3FE22F7C262EDE92]+stab=0.5682985020179316 [3FE22F8057110CC0]att=4 [4010000000000000]fired[altalena@@ -139,13 +139,17 @@ units[1:veteran_halutz@-3,19/6site{beit_kama=done,1949-03-15- camp_80=done,1950-03-15+ beit_kama_field=done,1950-02-15+ camp_80=done,1950-11-15gilat=done,1949-06-15+ gilat_field=done,1950-04-15mefalsim=done,1949-09-15+ mefalsim_field=done,1950-06-15reim=done,1949-12-15- tzrifin=done,1950-06-15+ reim_field=done,1950-08-15+ tzrifin=done,1951-02-15next=2obj{first_new_yishuv=1949-09-15score=100-food=2732,1390,0\ No newline at end of file+food=2736,1390,0\ No newline at end of filediff --git a/sim/Statecraft.Sim.Tests/golden/manifest.txt b/sim/Statecraft.Sim.Tests/golden/manifest.txtindex 50536ccac..0015c7378 100644--- a/sim/Statecraft.Sim.Tests/golden/manifest.txt+++ b/sim/Statecraft.Sim.Tests/golden/manifest.txt@@ -2,10 +2,10 @@# Tests read this file. To accept a deliberate change: STATECRAFT_UPDATE_GOLDEN=1 dotnet test sim/Statecraft.sln# rewrites this file, the snapshots and the GoldenRun.cs constants; then update docs/determinism.md and tools/web_check.py# (GoldenManifestTests names any place that is out of date) and add a row to the rebaseline history.-hash1950 38c8a4844a0d7cb25076c4286e05fea75f0df9294fd29943345bce57a0ddead3-hash1952 1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4+hash1950 e4ebff9b317a02b908434cedb18674608ae820e5e60769ef78272493884590c4+hash1952 e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857fsmoke5 2436927c8b24f28c42be0e7b5a6fe30900f2f6c6a3ba77e4be943c1f50db57ccscenario-reckless af7b2abd4c6e477cc78555700b09822030773e9fc6b856ffc0a7109bedc1e7ddscenario-cautious 28fd140536e326922fadf21571b64bdaae5125f97f2609b44b4baa5ca9bceda3scenario-mvp-absorb-first b16a87402c03324f6260b57b915a0b7767f12cc166420ace257a21b54b341dd4-mvp-end 1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4+mvp-end e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857fdiff --git a/sim/Statecraft.Sim.Tests/golden/mvp-end.txt b/sim/Statecraft.Sim.Tests/golden/mvp-end.txtindex 1fe64b8aa..fa584b988 100644--- a/sim/Statecraft.Sim.Tests/golden/mvp-end.txt+++ b/sim/Statecraft.Sim.Tests/golden/mvp-end.txt@@ -1,6 +1,6 @@1952-01-15;1948;Historical;44;ind{- food_supply=0.8555155874508137 [3FEB606239AA391F]+ food_supply=0.8556115107122045 [3FEB612B6412E1DF]housing=0.43504947742483624 [3FDBD7D9C36B9EB6]intl_standing=0.7800000000000002 [3FE8F5C28F5C28F8]morale=0.5690955554429493 [3FE23607E1DDA540]@@ -44,11 +44,11 @@ pop{sit[fx_crisistreasury=0 [0000000000000000]-debt=180.89012071283815 [40669C7BDE6EE43A]+debt=182.89012071283815 [4066DC7BDE6EE43A]fx=-12.990431328096559 [C029FB19D0A63796]rung=2;cf=0;mob=0.05 [3FA999999999999A]-stab=0.5682965036166527 [3FE22F7C262EDE92]+stab=0.5682985020179316 [3FE22F8057110CC0]att=4 [4010000000000000]fired[altalena@@ -139,13 +139,17 @@ units[1:veteran_halutz@-3,19/6site{beit_kama=done,1949-03-15- camp_80=done,1950-03-15+ beit_kama_field=done,1950-02-15+ camp_80=done,1950-11-15gilat=done,1949-06-15+ gilat_field=done,1950-04-15mefalsim=done,1949-09-15+ mefalsim_field=done,1950-06-15reim=done,1949-12-15- tzrifin=done,1950-06-15+ reim_field=done,1950-08-15+ tzrifin=done,1951-02-15next=2obj{first_new_yishuv=1949-09-15score=100-food=2732,1390,0\ No newline at end of file+food=2736,1390,0\ No newline at end of filediff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.csindex 684e60c6e..03561a9d6 100644--- a/sim/Statecraft.Sim/Content.cs+++ b/sim/Statecraft.Sim/Content.cs@@ -480,6 +480,14 @@ namespace Statecraft.Simpublic int? BuildCampTurns { get; set; }/// <summary>IL millions a "build camp" costs, paid in full when it starts (R-CAMP-001). Required in the GDD loop.</summary>public double? BuildCampCost { get; set; }+ /// <summary>Turns plowing a field takes, counting the turn it was ordered in (R-FIELD-001, as R-SITE-003).</summary>+ public int PlowFieldsTurns { get; set; }+ /// <summary>IL millions plowing a field costs, paid in full when it starts (R-FIELD-001, as R-SITE-001). Required in the+ /// GDD loop, so a missing key never makes plowing free.</summary>+ public double? PlowFieldsCost { get; set; }+ /// <summary>Food units a plowed field adds to the national stock each turn, in step 6 (R-FIELD-002; Q-FIELD-3). Required+ /// in the GDD loop, so a missing key is never read as 0.</summary>+ public int? FieldFoodPerTurn { get; set; }/// <summary>Points for each completed objective (R-OBJ-002; D-B6, #456).</summary>public int? ObjectivePoints { get; set; }/// <summary>Bonus points for each calendar month an objective is completed before its reference date's month (R-OBJ-002; D-B2, #456).</summary>diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex 94368e5a5..4d6c8e21a 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -1056,6 +1056,11 @@ namespace Statecraft.Simif (m.BuildCampTurns < 1) throw new ContentException(file, "mvp.build_camp_turns", "must be >= 1");if (m.BuildCampCost == null) throw new ContentException(file, "mvp.build_camp_cost", "required when eras.yaml systems.loop is gdd");if (!(m.BuildCampCost >= 0 && IsFinite(m.BuildCampCost.Value))) throw new ContentException(file, "mvp.build_camp_cost", "must be a finite number >= 0");+ if (m.PlowFieldsTurns < 1) throw new ContentException(file, "mvp.plow_fields_turns", "must be >= 1");+ if (m.PlowFieldsCost == null) throw new ContentException(file, "mvp.plow_fields_cost", "required when eras.yaml systems.loop is gdd");+ if (!(m.PlowFieldsCost >= 0 && IsFinite(m.PlowFieldsCost.Value))) throw new ContentException(file, "mvp.plow_fields_cost", "must be a finite number >= 0");+ if (m.FieldFoodPerTurn == null) throw new ContentException(file, "mvp.field_food_per_turn", "required when eras.yaml systems.loop is gdd");+ if (m.FieldFoodPerTurn < 0) throw new ContentException(file, "mvp.field_food_per_turn", "must be >= 0");// R-FOOD-001 to R-FOOD-003: required, so a missing key is never read as 0 (a stock term of 0, or no stock).if (m.KFood == null) throw new ContentException(file, "mvp.k_food", "required when eras.yaml systems.loop is gdd");if (!(m.KFood >= 0 && m.KFood <= 1)) throw new ContentException(file, "mvp.k_food", "must be between 0 and 1");@@ -1145,6 +1150,10 @@ namespace Statecraft.Simif (x.Kinds.Count == 0) throw new ContentException(sf, at + ".kinds", "required: one or more of " + string.Join(", ", SiteKinds));foreach (var k in x.Kinds)if (!SiteKinds.Contains(k)) throw new ContentException(sf, at + ".kinds", $"unknown kind '{k}' ({string.Join(", ", SiteKinds)})");+ // R-FIELD-001: a field site's built record is its plowed state, so a built yishuv on it would yield Food. Only that+ // pair is refused; other kinds may share a field site (a drained swamp is PR 5's question, Q-SWAMP-1).+ if (x.Kinds.Contains(Projects.FieldKind) && x.Kinds.Contains(Projects.YishuvKind))+ throw new ContentException(sf, at + ".kinds", "a field site cannot also be a yishuv site (its built record is its plowed state)");if (x.Kinds.Contains(Projects.YishuvKind)){// R-SITE-005 (Q-SITE-3): one yishuv per hex, so SettlementPlacer keeps one kit per hex; other kinds may share it.diff --git a/sim/Statecraft.Sim/GoldenRun.cs b/sim/Statecraft.Sim/GoldenRun.csindex 2ad552c2a..462c46537 100644--- a/sim/Statecraft.Sim/GoldenRun.cs+++ b/sim/Statecraft.Sim/GoldenRun.cs@@ -15,13 +15,13 @@ namespace Statecraft.Sim/// <summary>Final hash of Play(content, Until1950). Changing it is a deliberate rules or content change: the value/// is pinned in sim/Statecraft.Sim.Tests/golden/manifest.txt, and STATECRAFT_UPDATE_GOLDEN=1 dotnet test rewrites/// both (docs/determinism.md). Say why in the commit message.</summary>- public const string Hash1950 = "38c8a4844a0d7cb25076c4286e05fea75f0df9294fd29943345bce57a0ddead3";+ public const string Hash1950 = "e4ebff9b317a02b908434cedb18674608ae820e5e60769ef78272493884590c4";public static readonly DateTime Until1950 = new DateTime(1950, 1, 1);/// <summary>Final hash of Play(content, Until1952): the M3 content range (to 31 December 1951). The GDD game ends on/// 15 January 1952 (R-LOOP-004), the first turn on or after Until1952, so this is also the mvp-end run.</summary>- public const string Hash1952 = "1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4";+ public const string Hash1952 = "e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857f";public static readonly DateTime Until1952 = new DateTime(1952, 1, 1);diff --git a/sim/Statecraft.Sim/Pools.cs b/sim/Statecraft.Sim/Pools.csindex c4d0dfe83..170a073e0 100644--- a/sim/Statecraft.Sim/Pools.cs+++ b/sim/Statecraft.Sim/Pools.cs@@ -1,5 +1,6 @@using System;using System.Collections.Generic;+using System.Linq;namespace Statecraft.Sim{@@ -30,6 +31,21 @@ namespace Statecraft.Sim/// <summary>The nation's need for one turn: its head count in population units, rounded half away from zero.</summary>static int Need(GameState s, MvpRules r) => (int)Math.Round(s.TotalPopulation / r.PeoplePerUnit, MidpointRounding.AwayFromZero);+ /// <summary>R-FIELD-002, step 6 after the cities' production (D-A6): in ordinal site id order, every plowed field (a built+ /// field site, R-FIELD-001) adds field_food_per_turn to the stock, with no workers (Q-FIELD-2). It comes before the+ /// nation eats in step 7, so in a turn with imports the import only tops the stock up by less.</summary>+ public static void Harvest(Content c, GameState s, MvpRules r, List<Cause> why)+ {+ var yield = r.FieldFoodPerTurn!.Value; // the loader requires it in the GDD loop+ if (yield == 0) return;+ foreach (var f in c.Sites.Where(x => x.Kinds.Contains(Projects.FieldKind)).OrderBy(x => x.Id, StringComparer.Ordinal))+ {+ if (!(s.Sites.TryGetValue(f.Id, out var w) && w.BuiltOn != null)) continue;+ s.Food += yield;+ why.Add(new Cause("economy", "food", yield, FormattableString.Invariant($"{f.Name}: the plowed land yielded {yield} units of Food")));+ }+ }+/// <summary>R-FOOD-002, step 7: the nation eats the turn's need from the stock, as far as the stock goes (it stops at/// 0, and the rest is unmet), then the import brings the stock back to cover_months of the need, unless foreign/// currency is exhausted (the fx_crisis situation at the turn's start), when no Food is imported.</summary>diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.csindex 4e79be470..72aca8bfd 100644--- a/sim/Statecraft.Sim/Projects.cs+++ b/sim/Statecraft.Sim/Projects.cs@@ -26,6 +26,10 @@ namespace Statecraft.Sim/// <summary>Whether a unit of <paramref name="type"/> does pioneer work: a halutz, or a veteran one (R-SITE-001, R-VET-001).</summary>public static bool IsPioneer(string type) => type == "halutz" || type == VeteranType;+ /// <summary>The pioneer action that plows a field (GDD "Pioneer work": "Prepare agricultural land"; Phase 4 PR 4).</summary>+ public const string PlowFields = "plow_fields";+ /// <summary>The kind of site a field may be plowed at (sites.yaml kinds). Built, a field site is plowed (R-FIELD-001).</summary>+ public const string FieldKind = "field";/// <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);@@ -35,30 +39,36 @@ namespace Statecraft.Sim/// 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. R-CAMP-001: build_camp at a military_camp or hakhshara site follows the same- /// rules, with build_camp_turns and build_camp_cost.</summary>+ /// rules, with build_camp_turns and build_camp_cost. R-FIELD-001: plow_fields at a field site follows the same rules, with+ /// plow_fields_turns and plow_fields_cost, and is refused while a yishuv site in the field's hex is not built.</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 (!IsPioneer(u.Type)) 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 && action != BuildCamp) return "There is no such pioneer work";+ if (action != BuildYishuv && action != BuildCamp && action != PlowFields) 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";var camp = action == BuildCamp;- if (camp ? !IsCamp(place) : !place.Kinds.Contains(YishuvKind))- return camp ? $"{place.Name} is not a site for a training camp" : $"{place.Name} is not a site for a new yishuv";+ var plow = action == PlowFields;+ if (camp ? !IsCamp(place) : !place.Kinds.Contains(plow ? FieldKind : YishuvKind))+ return camp ? $"{place.Name} is not a site for a training camp"+ : plow ? $"{place.Name} is not a site for fields" : $"{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";+ if (plow && YishuvToBuildFirst(c, s, place) is Site first) return $"{place.Name} can be plowed once {first.Name} is 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.- var cost = camp ? r.BuildCampCost!.Value : r.BuildYishuvCost; // the loader requires build_camp_cost in the GDD loop- EconomySystem.PayOrBorrow(c, s, cost, camp ? "to build a training camp" : "to build a yishuv", why);+ var cost = camp ? r.BuildCampCost!.Value : plow ? r.PlowFieldsCost!.Value : r.BuildYishuvCost; // the loader requires both in the GDD loop+ EconomySystem.PayOrBorrow(c, s, cost, camp ? "to build a training camp" : plow ? "to plow fields" : "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, camp ? r.BuildCampTurns!.Value : r.BuildYishuvTurns, null);- why.Add(new Cause("map", site, 1, $"{place.Name}: a group of halutzim began building {(camp ? "a training camp" : "a yishuv")}, cost {PlayerText.Money(c, "treasury", cost)}"));+ s.Sites[site] = new SiteWork(site, unit, camp ? r.BuildCampTurns!.Value : plow ? r.PlowFieldsTurns : r.BuildYishuvTurns, null);+ why.Add(plow+ ? new Cause("map", site, 1, $"{place.Name}: a group of halutzim began plowing, cost {PlayerText.Money(c, "treasury", cost)}")+ : new Cause("map", site, 1, $"{place.Name}: a group of halutzim began building {(camp ? "a training camp" : "a yishuv")}, cost {PlayerText.Money(c, "treasury", cost)}"));return null;}@@ -66,6 +76,12 @@ namespace Statecraft.Sim/// (R-CAMP-001). Built, its city gains those facilities (Training.HasFacility).</summary>public static bool IsCamp(Site site) => site.Kinds.Contains("military_camp") || site.Kinds.Contains("hakhshara");+ /// <summary>R-FIELD-001 (Q-FIELD-1): the yishuv site in <paramref name="field"/>'s hex while it is not built yet, so the+ /// field cannot be plowed; null when the field is ready (its yishuv is built, or it has none in its hex).</summary>+ public static Site? YishuvToBuildFirst(Content c, GameState s, Site field) =>+ c.Sites.FirstOrDefault(y => y.Kinds.Contains(YishuvKind) && y.Q == field.Q && y.R == field.R+ && !(s.Sites.TryGetValue(y.Id, out var w) && w.BuiltOn != 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>@@ -83,7 +99,8 @@ namespace Statecraft.Sim/// built has one turn less to go, or veteran_progress less with a veteran (R-VET-002). One that reaches 0 is built on/// <paramref name="next"/>, the turn's end date, and its unit is idle again. No city is founded (Phase 1). Then the/// unit, a halutz, gains a turn of service, and at veteran_halutz_service becomes a veteran_halutz (R-VET-001). A built- /// camp site gives its city the facility from the next turn (R-CAMP-001, Training.HasFacility).</summary>+ /// camp site gives its city the facility from the next turn (R-CAMP-001, Training.HasFacility). A built field site is+ /// plowed (R-FIELD-001), and yields from this turn's step 6 on (R-FIELD-002).</summary>public static void Advance(Content c, GameState s, DateTime next, List<Cause> why){var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop, the only loop TurnResolver runs this in@@ -96,7 +113,7 @@ namespace Statecraft.Sim{s.Sites[w.Site] = SiteWork.Built(w.Site, next);var place = c.Sites.First(x => x.Id == w.Site); // a site being built is always in sites.yaml (Start)- why.Add(new Cause("map", w.Site, 1, $"{place.Name} {(IsCamp(place) ? "built" : "founded")}"));+ why.Add(new Cause("map", w.Site, 1, $"{place.Name} {(IsCamp(place) ? "built" : place.Kinds.Contains(FieldKind) ? "plowed" : "founded")}"));}// R-VET-001: the project progressed this turn, so a halutz serves a turn; a veteran counts no further.if (u.Type != "halutz") continue;diff --git a/sim/Statecraft.Sim/Reference/ReferencePlayer.cs b/sim/Statecraft.Sim/Reference/ReferencePlayer.csindex a36e59990..5952a9fd3 100644--- a/sim/Statecraft.Sim/Reference/ReferencePlayer.cs+++ b/sim/Statecraft.Sim/Reference/ReferencePlayer.cs@@ -6,8 +6,8 @@ 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 sends each idle halutz- /// unit to the first available yishuv site (then to the first available camp site), then, when there is no halutz and none- /// in training, trains one halutz group in+ /// unit to the first available yishuv site (then to the first ready field, then to the first available camp 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 goldens (#394; GoldenRun); no game mode or UI may reach it/// (ReferencePlayerTests.NoGameModeOrUiReachesIt).</summary>public static class ReferencePlayer@@ -42,7 +42,9 @@ namespace Statecraft.Sim.Reference}/// <summary>Sends each idle halutz unit, veterans too, in id order, to the first yishuv site without a record, in ordinal id order,- /// and once every yishuv site has one, to build the first camp site without a record (R-CAMP-001), while the turn's Attention lasts. Pioneer work borrows, so the Treasury does not hold it back.</summary>+ /// and once every yishuv site has one, to plow the first ready field site without a record (R-FIELD-001), and when there+ /// is none, to build the first camp site without a record (R-CAMP-001), 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);@@ -52,6 +54,12 @@ namespace Statecraft.Sim.Referencevar site = c.Sites.Where(x => x.Kinds.Contains(Projects.YishuvKind) && !taken.Contains(x.Id)).OrderBy(x => x.Id, StringComparer.Ordinal).FirstOrDefault();var action = Projects.BuildYishuv;if (site == null)+ {+ site = c.Sites.Where(x => x.Kinds.Contains(Projects.FieldKind) && !taken.Contains(x.Id) && Projects.YishuvToBuildFirst(c, s, x) == null)+ .OrderBy(x => x.Id, StringComparer.Ordinal).FirstOrDefault();+ action = Projects.PlowFields;+ }+ if (site == null){site = c.Sites.Where(x => Projects.IsCamp(x) && !taken.Contains(x.Id)).OrderBy(x => x.Id, StringComparer.Ordinal).FirstOrDefault();action = Projects.BuildCamp;diff --git a/sim/Statecraft.Sim/TurnResolver.cs b/sim/Statecraft.Sim/TurnResolver.csindex df38471e4..3698a927d 100644--- a/sim/Statecraft.Sim/TurnResolver.cs+++ b/sim/Statecraft.Sim/TurnResolver.cs@@ -18,6 +18,7 @@ namespace Statecraft.SimTraining.Progress(c, s, why); // 4. trainingProjects.Advance(c, s, next, why); // 5. constructionCities.Produce(c, s, r, yearFraction, why); // 6. production+ Pools.Harvest(c, s, r, why); // and the plowed fields' Food (R-FIELD-002)Pools.Consume(c, s, r, why); // 7. consumption: the nation eats, then imports (R-FOOD-002)Cities.House(c, s, why); // 8. housing; Social cohesion is morale, which the effects web moves after the resolutionCities.Arrive(c, s, r, next, why); // 9. arrivalsdiff --git a/tools/web_check.py b/tools/web_check.pyindex dcfe1daa4..e00ae757b 100644--- a/tools/web_check.py+++ b/tools/web_check.py@@ -8,7 +8,7 @@ fail on a failure line or a timeout. Uses Chrome for Testing from the Playwright--enable-logging=stderr --v=1 as INFO:CONSOLE... "text", source: ...Usage (from the repo root):- uv run tools/web_check.py unity/Builds/Web-disabled --query "golden" --expect "GOLDEN OK 1950 38c8a4844a0d7cb25076c4286e05fea75f0df9294fd29943345bce57a0ddead3" --expect "GOLDEN OK 1952 1e21fcd3e5d99159b7bf2c803e8c92ca78ec52c36445aa511edbfeac082514f4"+ uv run tools/web_check.py unity/Builds/Web-disabled --query "golden" --expect "GOLDEN OK 1950 e4ebff9b317a02b908434cedb18674608ae820e5e60769ef78272493884590c4" --expect "GOLDEN OK 1952 e0d8212a1f6ea8af9211166aa52b76c741c739807d4326b6b6664a5c5d26857f"Options: --query Q (page URL query, without '?'), --expect TEXT (repeatable), --fail REGEX (default: GOLDEN FAIL|SMOKE FAIL|BOOT FAIL),--timeout SECONDS (default 300), --stall SECONDS (fail when no console message arrives for that long; 0 = off),--swiftshader (software WebGL when there is no GPU), --dpr N (default 1), --shots DIR (reassemble the player's