A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
sim: the national Food stock, food_supply following its months of cover (R-FOOD-001 to R-FOOD-003, refs #382) (#712)
Eyal Golan0d0fd13509d4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ba1b82c75..4cadc9bba 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,12 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBThe checks file is now written in the bundle cache and copied beside the shipped bundles.### Changed+- Food is a national stock (refs #382, R-FOOD-001 to R-FOOD-003; maintainer, 16 October 2026, option (b)): the nation+ eats its head count each month, a monthly import keeps three months of cover, and the stock stops at 0. Food supply+ falls as the cover falls and further by any unmet share; rationing and events still act on top. The 1951 currency+ crisis now cuts the Food imports instead of Food supply directly. `k_food` (0.1) and `cover_months` (3) are new design+ values for the owner to set or accept. Every golden moves (a new `food=` line; the end of 1951 also moves Food supply+ slightly); the content hash moves too, so an older save loads with the "different game content" warning.- The first-new-yishuv card's source comment records the #706 gazetteer findings for places under 1,000 nearMefalsim (seven depopulated villages in the sweeps, none naming Mefalsim; the Bedouin-locality caveat), instead ofthe stale not-checked note (#654). Comment only; the card's text is unchanged.diff --git a/content/rules.yaml b/content/rules.yamlindex 84c8587ec..6b31aca16 100644--- a/content/rules.yaml+++ b/content/rules.yaml@@ -37,6 +37,15 @@ mvp: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)+ # The national Food stock (R-FOOD-001 to R-FOOD-003; D-C2; maintainer decision of 16 October 2026, #382, option (b)). One+ # unit of Food is one population unit's food for a month. The stock starts at, and the monthly import keeps it at,+ # cover_months of the nation's need; the foreign currency crisis cuts the import. food_supply carries the term+ # k_food * (stock - full) / full, minus the unmet share: an empty stock costs k_food, which with food_supply's base of+ # 0.40 is the food_crisis line (0.30, model.yaml), so an empty larder brings the country to the edge of a food crisis+ # and any unmet need tips it over. Three months' cover makes one month of the 1951 crisis cost a third of k_food,+ # about what the legacy direct cut (fx_crisis_food_per_year) took over the same weeks. Neither is a historical figure.+ k_food: 0.1 # DESIGN VALUE: owner-set balance, not a historical figure (D-C2: food_supply lost with an empty Food stock)+ cover_months: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-C2: months of need a full Food stock holds)# Coalition stability lost by replacing a minister (Cabinet.Appoint): a seat taken from the minister's party, or a# reshuffle within it.appoint_stability_cost_other_party: 0.06@@ -86,7 +95,8 @@ imports_per_capita_per_year: 0.00025# the turn covering 19 Oct (ending 1951-11-15), against $45m falling due; the first crisis is in the turn ending# 1951-12-15; reserves -13.0 at the game's end. The value was not retuned.capital_inflow_per_year: 200-# While reserves are exhausted, food imports are cut: food_supply falls by this much per year.+# While reserves are exhausted, food imports are cut: food_supply falls by this much per year. The legacy loop only: in the+# GDD loop the crisis cuts the Food stock's imports instead (R-FOOD-002, Q-POOL-4), and food_supply follows the stock.fx_crisis_food_per_year: -0.2mobilization_cost_per_year: 60# Derived from CBS table 2.1 (1949): (end-1949 1,013.9k - end-1948 758.7k - 1949 immigrants 239,954) / average 1949 population 901.0k.diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex a4487e6d7..23d887e88 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -19,9 +19,9 @@ 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 ad8067765007988a2ea52226a50622259b695cd72a5b735b298207e472b81504" \- --expect "GOLDEN OK 1952 0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2" \- --expect "SMOKE OK 5 turns 1948-10-15 85191d48688be4595726b17778ecdda0175eff8f6f0fa1d976dbe3b48b42823b"+ --expect "GOLDEN OK 1950 ca953c983faa2a85216efdf264bf1da9167c9787a06d21a73c76717dfab0f8b4" \+ --expect "GOLDEN OK 1952 b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915" \+ --expect "SMOKE OK 5 turns 1948-10-15 848969ce7236d5fb4b8af33c2e6a8445d0a437a002b93cb076d54450c3d79e0a"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 d725115c3..0c3abc781 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 | `ad8067765007988a2ea52226a50622259b695cd72a5b735b298207e472b81504` |-| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2` |-| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2` |+| to 1950-01-01 (`Hash1950`) | 1950-01-15, turn 20 | `ca953c983faa2a85216efdf264bf1da9167c9787a06d21a73c76717dfab0f8b4` |+| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915` |+| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915` |`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@@ -39,15 +39,15 @@ check `hash1950` and `hash1952`.A further value is pinned for the browser smoke run (`?smoke=5`: the golden seed, five turns played through the UI's ownbuttons, answering each event with its first option while the turn's Attention pays for it, the rest left to their-ministers): `SMOKE OK 5 turns 1948-10-15 85191d48688be4595726b17778ecdda0175eff8f6f0fa1d976dbe3b48b42823b`.+ministers): `SMOKE OK 5 turns 1948-10-15 848969ce7236d5fb4b8af33c2e6a8445d0a437a002b93cb076d54450c3d79e0a`.It depends on the UI path as well as the sim (which option is first, the turn grid), so re-record it when either changes.Check every build with:```uv run tools/web_check.py unity/Builds/Web-<compression> --query "golden&smoke=5" \- --expect "GOLDEN OK 1950 ad8067765007988a2ea52226a50622259b695cd72a5b735b298207e472b81504" \- --expect "GOLDEN OK 1952 0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2" \- --expect "SMOKE OK 5 turns 1948-10-15 85191d48688be4595726b17778ecdda0175eff8f6f0fa1d976dbe3b48b42823b"+ --expect "GOLDEN OK 1950 ca953c983faa2a85216efdf264bf1da9167c9787a06d21a73c76717dfab0f8b4" \+ --expect "GOLDEN OK 1952 b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915" \+ --expect "SMOKE OK 5 turns 1948-10-15 848969ce7236d5fb4b8af33c2e6a8445d0a437a002b93cb076d54450c3d79e0a"```**When a golden moves.** The test fails with the lines that changed, grouped by section (`[ind]`, `[pol]`, `[bud]`,@@ -224,3 +224,10 @@ The hash reads the state keys, so it never sees a record outside its window. An| GDD Phase 1 PR 6 | 1950 | `ad806776` | the first new yishuv objective (R-OBJ-001 to R-OBJ-003), rebased onto the cutover: the reference player builds Mefalsim on 15 June 1949, the month of its 12 June 1949 founding, so the objective completes on time for 100 points (`obj{first_new_yishuv=1949-06-15}`, `score=100`) and its card fires and is answered (`first_new_yishuv=continue`); no other event moves, so the card displaces nothing under the soft-event cap; `objective_points`, `objective_bonus_per_month` and `objective_bonus_cap` enter `rules.yaml` as design values (D-B6, D-B2) (was `f97e9f81`) || GDD Phase 1 PR 6 | 1952 | `0f54dc51` | same (was `75d38299`) || GDD Phase 1 PR 6 | mvp-end | `0f54dc51` | same; the same run as hash1952 (was `75d38299`); `smoke5` and the three scenarios do not move |+| GDD Phase 2 PR 3 | 1950 | `ca953c98` | the national Food stock (R-FOOD-001 to R-FOOD-003; maintainer decision of 16 October 2026, #382, option (b)): a new hashed line `food=stock,need,unmet`, written only when set. The stock starts at `cover_months` (3) of the need and the monthly import keeps it there, so its `food_supply` term is exactly 0 and nothing else in the run moves (`food=3003,1001,0`) (was `ad806776`) |+| GDD Phase 2 PR 3 | 1952 | `b42380ab` | same, and the 1951 currency crisis now cuts Food imports into the stock (Q-POOL-4) instead of shifting `food_supply` directly: the legacy cut is gone (`shift food_supply` 0.15, was 0.1167: the events' 0.15 less the cut's 0.0333 over the two crisis turns), the last turn imports nothing, the stock falls to 2732 against a full 4170 (`food=2732,1390,0`), and the stock term takes 0.0345 off, so `food_supply` ends at 0.8555 (was 0.8567); the voter groups read `food_supply`, so `stab` moves with it (0.5098, was 0.5095) (was `0f54dc51`) |+| GDD Phase 2 PR 3 | mvp-end | `b42380ab` | same; the same run as hash1952 (was `0f54dc51`) |+| GDD Phase 2 PR 3 | smoke5 | `848969ce` | the new `food=` line only; the five turns hold a full stock (was `85191d48`) |+| GDD Phase 2 PR 3 | scenario-cautious | `5553c31a` | the new `food=` line only (`food=2253,751,0`) (was `58eb01db`) |+| GDD Phase 2 PR 3 | scenario-reckless | `42041362` | the new `food=` line only (`food=2253,751,0`) (was `e2f409a5`) |+| GDD Phase 2 PR 3 | scenario-mvp-absorb-first | `e01bb37a` | the new `food=` line only (`food=2556,852,0`) (was `f8858f6e`) |diff --git a/docs/gdd/cutover-resource-layer.md b/docs/gdd/cutover-resource-layer.mdindex 62a67cbe2..35b908261 100644--- a/docs/gdd/cutover-resource-layer.md+++ b/docs/gdd/cutover-resource-layer.md@@ -12,6 +12,8 @@ As a player of the MVP, I want the real game to switch to the GDD loop with mont- Money is the Treasury, in IL millions, and every GDD cost and income moves it (the plan's Money PR [S2]). Debt and foreign currency stay internal, under Money, at least through the cutover, and are hidden if they confuse (D-C3, decided 15 October 2026 [S2]).- A GDD cost above the Treasury is still paid and the shortfall moves to debt: the owner allowed borrowing for training and pioneer work, and the plan reads this as applying to every GDD cost (D-C3, decided 15 October 2026 [S2]; proposed R-MONEY-003; the plan's reading [S2]).- Food and Arms are national pools, whole numbers (D-C2, decided 15 October 2026 [S2]). Arms comes from sourced arms-deal events and from Money, and training and attacks consume it (D-G6, decided 15 October 2026 [S2]).+- One unit of Food is one population unit's food for a month. The nation eats its head count in units each turn, and a monthly import keeps the stock at a set number of months of cover, except while foreign currency is exhausted, when nothing is imported. The stock never goes below zero, and the share left unmet is kept (`Q-POOL-2`, `Q-POOL-4` and `Q-POOL-5`, decided 15 October 2026 [S3]; R-FOOD-001 and R-FOOD-002).+- Food supply stays the zero-to-one level the screens and events read. It carries a term from the months of cover: none at a full stock, the most when the stock is empty, and the unmet share lowers it further; rationing and events still act on top (the maintainer's food rule, 16 October 2026 [S6]; R-FOOD-003). The two numbers, `k_food` and `cover_months`, are labelled design values.- Social cohesion is the `morale` indicator on its zero-to-one scale, shown to the player as Social cohesion, its thresholds as situations, and International Support is the `intl_standing` indicator on its zero-to-one scale, under its player name (D-C1, decided 15 October 2026 [S2]; proposed R-NAT-001 and R-NAT-003).- An event option's effects may target Money, Food, Arms, Social cohesion and International Support; any other target is a load error (proposed R-EFX-001 [S2]). An option tagged `holocaust`, `terror`, `massacre` or `war-casualties` cannot raise any of the five resources or foreign currency unless the same option carries a matching cost (the sensitive-option answer of 15 October 2026 [S2]; proposed R-EFX-002). The owner chose to add a real cost: the check is a net of zero or less across the five resources, with the cost falling on a different resource than the gain (owner, 15 October 2026 [S3]; the plan [S2]).- The historical run has at most six months without any event, and at most two months in wartime, the full-war level of the war state counting as wartime (owner, 15 October 2026 [S3] and [S4]; the gap rule, docs/m3-rulings.md). Five war event cards are rewritten as decisions taken during or after the event, and the first truce and Rhodes cards are accepted as arriving late (`Q-CUT-3`, "Mixed" [S2]). The Altalena card opens on 15 June 1948 without the Kfar Vitkin clause, and the Ten Days card is rewritten (the owner on #567, recorded in the plan [S2]). Cards whose text changed go back to `fact-checked` until the owner re-reviews them (`Q-CUT-4`, decided 15 October 2026 [S3]).@@ -47,6 +49,7 @@ As a player of the MVP, I want the real game to switch to the GDD loop with mont- [S3] The owner's phase answers announced on #375, 15 October 2026, https://github.com/eyalgolan/statecraft-israel/issues/375#issuecomment-6180592337, checked 2026-10-15- [S4] The owner's decisions recorded on #375, 15 October 2026, https://github.com/eyalgolan/statecraft-israel/issues/375#issuecomment-6183538544, checked 2026-10-15- [S5] The owner's answers on #375, 15 October 2026, https://github.com/eyalgolan/statecraft-israel/issues/375#issuecomment-6178976670, checked 2026-10-15+- [S6] The maintainer's food rule on #382, 16 October 2026 (option (b)), https://github.com/eyalgolan/statecraft-israel/issues/382#issuecomment-6213237277, checked 2026-10-16## Open questionsdiff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 21bb729cf..631cacfcf 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -83,3 +83,13 @@ R-MONEY-001: The GDD's Money is the Treasury (`model.yaml` money `treasury`, inR-MONEY-003: A GDD cost above the Treasury is paid, and the shortfall moves to debt, as map actions do: the Treasury stops at 0, and a cause names what the shortfall was borrowed for (Q-MONEY-3, owner decision "Allow borrowing", 15 October 2026, for training and pioneer work; the Phase 2 plan applies it to every GDD cost). It covers the deficit, map actions, training (R-TRAIN-001), pioneer work (R-SITE-001) and an event option's Treasury cost.The top bar shows the net position, Treasury minus debt (`HudModel.From`), so it reads below 0 once anything is borrowed.++## Food++The national Food pool (D-C2, "National pools", decided 15 October 2026), built on the maintainer's food rule of 16 October 2026 (#382, option (b): "food_supply adds a stock term: it rises and falls with months of cover (new design values `k_food`, `cover_months`), rationing and events still act on top, and the unmet share lowers it further").++R-FOOD-001: Food is a national stock of whole units (`GameState.Food`); one unit is one population unit's food for one month, and there is no storage cap (Q-POOL-2, decided 15 October 2026). A new game starts the stock at `cover_months` of the start's need, the need being the national head count in population units (`people_per_unit`), rounded half away from zero. `k_food` and `cover_months` are required in the GDD loop (`rules.yaml` `mvp:`, labelled design values); a missing or out-of-range value is a load error.++R-FOOD-002: In step 7 the nation eats the turn's need from the stock as far as it goes: the stock stops at 0, and the rest is the unmet share, kept in the state with the need (Q-POOL-5, decided 15 October 2026). Then a monthly 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 nothing is imported (Q-POOL-4, decided 15 October 2026). Imports are already paid for in foreign currency per head (`imports_per_capita_per_year`), so they are not charged again. In the GDD loop the crisis cuts the imports, not `food_supply` directly: `fx_crisis_food_per_year` acts in the legacy loop only.++R-FOOD-003: `food_supply` stays the 0 to 1 level the UI, the situations and the events read (Q-POOL-3, decided 15 October 2026), with a stock term inside its effect sum: `k_food * (stock - full) / full - unmet / need`, where `full` is `cover_months` of the last need. The term is exactly 0 at a full stock, `-k_food` when the stock is empty, and the unmet share lowers it further; rationing, the other effects and event shifts act on top as before, and the level's clamp to 0..1 bounds the result. The GDD loop requires the `food_supply` indicator.diff --git a/docs/superpowers/plans/2026-10-14-gdd-phase-2.md b/docs/superpowers/plans/2026-10-14-gdd-phase-2.mdindex 0758b76c2..b47d1460f 100644--- a/docs/superpowers/plans/2026-10-14-gdd-phase-2.md+++ b/docs/superpowers/plans/2026-10-14-gdd-phase-2.md@@ -324,6 +324,8 @@ Spec §3: "`hash1950`, `hash1952`, `mvp-end`: the reference player over the full>> **Decided by the owner on 15 October 2026 (#375):** Q-POOL-2, Q-POOL-4 and Q-POOL-5's Food-shortfall part as recommended ("Recommended answers" below; "Take all recommendations", #375).>+> **Decided by the maintainer on 16 October 2026 ([#382](https://github.com/eyalgolan/statecraft-israel/issues/382#issuecomment-6213237277)), the food rule:** "option (b). food_supply adds a stock term: it rises and falls with months of cover (new design values `k_food`, `cover_months`), rationing and events still act on top, and the unmet share lowers it further. This keeps the 1951 currency-crisis food cut (Q-POOL-4) while the stock stops at 0 (Q-POOL-5)." The stock starts at, and the import keeps it at, `cover_months` of the need, so the start stock needs no number of its own.+>> **Still open (owner):** none; the start stocks are labelled design values. **Waits for:** PR 1.**Goal:** Food and Arms exist as national integer stocks in the state (spec §2.2: `int Arms; int Food`), with start values, Food consumption in step 7, and the existing `food_supply` level derived from the Food stock. Arms comes from events (PR 5) and from Money, and recruit training consumes it (D-G6); attacks consume it in Phase 5.diff --git a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs b/sim/Statecraft.Sim.Tests/DesignValuesTests.csindex 0fa1eff6f..e7e752dfa 100644--- a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs+++ b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs@@ -31,6 +31,8 @@ public class DesignValuesTests("rules.yaml", "mvp.objective_points"),("rules.yaml", "mvp.objective_bonus_per_month"),("rules.yaml", "mvp.objective_bonus_cap"),+ ("rules.yaml", "mvp.k_food"),+ ("rules.yaml", "mvp.cover_months"),("cities.yaml", "cities[tel_aviv].housing_capacity"),("cities.yaml", "cities[tel_aviv].job_slots"),("cities.yaml", "cities[tel_aviv].civilians"),diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.csindex 076853ab6..4a4e0de1d 100644--- a/sim/Statecraft.Sim.Tests/Fixture.cs+++ b/sim/Statecraft.Sim.Tests/Fixture.cs@@ -227,6 +227,8 @@ mvp:objective_points: 100objective_bonus_per_month: 5objective_bonus_cap: 60+ k_food: 0.1+ cover_months: 3";public const string GddCities = @"diff --git a/sim/Statecraft.Sim.Tests/PoolsTests.cs b/sim/Statecraft.Sim.Tests/PoolsTests.csnew file mode 100644index 000000000..97727da9a--- /dev/null+++ b/sim/Statecraft.Sim.Tests/PoolsTests.cs@@ -0,0 +1,210 @@+using System;+using System.Collections.Generic;+using System.Linq;+using Statecraft.Sim;++/// <summary>The national Food pool (GDD Phase 2 PR 3; D-C2 "National pools"): the stock, the turn's eating and imports in+/// step 7, and food_supply derived from it (maintainer decision of 16 October 2026, option (b), #382: a stock term from+/// months of cover, rationing and events on top, the unmet share lowering it further; the stock stops at 0).</summary>+public class PoolsTests+{+ static readonly Content Real = ContentLoader.Load(RealContentTests.ContentRoot());++ /// <summary>The GDD fixture: 1000 people in units of 10 eat 100 units a month; k_food 0.1, cover_months 3.</summary>+ static Content Gdd(string mvpExtra = " k_food: 0.1\n cover_months: 3\n", string? model = null, string rulesExtra = "")+ {+ var files = Fixture.Gdd();+ files["rules.yaml"] = files["rules.yaml"].Replace(" k_food: 0.1\n cover_months: 3\n", "").Replace("mvp:\n", "mvp:\n" + mvpExtra) + rulesExtra;+ if (model != null) files["model.yaml"] = model;+ return ContentLoader.Load(Fixture.Write(files));+ }++ static GameState Step(Content c, GameState s) => Simulation.Step(c, s, Array.Empty<Command>()).State;+ static StepResult StepWithWhy(Content c, GameState s) => Simulation.Step(c, s, Array.Empty<Command>());++ // R-FOOD-001+ [Fact]+ public void TheStockStartsAtItsMonthsOfCover()+ {+ var c = Gdd();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ Assert.Equal(100, s.FoodNeed); // 1000 people / 10 per unit, one unit of Food per unit a month+ Assert.Equal(3 * 100, s.Food); // cover_months of the start's need+ Assert.Equal(0, s.FoodUnmet);++ var r = Simulation.NewGame(Real, GoldenRun.Seed, Mode.Historical);+ var m = Real.Rules.Mvp!;+ Assert.Equal((int)Math.Round(r.TotalPopulation / m.PeoplePerUnit, MidpointRounding.AwayFromZero), r.FoodNeed);+ Assert.Equal(m.CoverMonths!.Value * r.FoodNeed, r.Food);+ }++ // R-FOOD-003+ [Fact]+ public void AFullStockLeavesFoodSupplyWhereItWas()+ {+ // The stock term is exactly 0 at cover_months of cover, so the start's food_supply is the indicator's base.+ var s = Simulation.NewGame(Gdd(), 1, Mode.Historical);+ Assert.Equal(0.4, s.Indicators["food_supply"]);+ Assert.Equal(0.0, Pools.FoodTerm(Gdd(), s));+ }++ // R-FOOD-002+ [Fact]+ public void ImportsKeepTheStockAtItsCoverInANormalTurn()+ {+ var c = Gdd();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ var next = Step(c, s);+ Assert.Equal(next.FoodNeed * 3, next.Food);+ Assert.Equal(0, next.FoodUnmet);+ Assert.Equal(0.4, next.Indicators["food_supply"]);+ }++ // R-FOOD-002 (Q-POOL-4: the fx crisis cuts the imports, not food_supply directly)+ [Fact]+ public void ACurrencyCrisisCutsTheImportsSoTheStockFalls()+ {+ var c = Gdd(rulesExtra: "fx_crisis_food_per_year: -0.4\n"); // the legacy loop's direct cut, set so its absence shows+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.ActiveSituations.Add(EconomySystem.FxCrisis);+ s.FxReserves = -1000; // stays exhausted through the step+ var r = StepWithWhy(c, s);+ Assert.Equal(300 - 100, r.State.Food); // ate a month's need, imported nothing+ Assert.Equal(0, r.State.FoodUnmet);+ Assert.Contains(r.Why, w => w.System == "economy" && w.Target == "food" && w.Message.Contains("foreign currency crisis"));+ // The legacy direct cut does not also act in the GDD loop: the only change is the stock term.+ Assert.Equal(0.0, r.State.IndicatorShifts["food_supply"]);+ }++ // R-FOOD-002 (Q-POOL-5: the stock stops at 0, and the unmet share is counted)+ [Fact]+ public void TheStockStopsAtZero()+ {+ var c = Gdd();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.ActiveSituations.Add(EconomySystem.FxCrisis);+ s.FxReserves = -1000;+ s.Food = 40; // less than the 100 the nation eats this turn+ var r = StepWithWhy(c, s);+ Assert.Equal(0, r.State.Food);+ Assert.Equal(100 - 40, r.State.FoodUnmet);+ Assert.Contains(r.Why, w => w.System == "economy" && w.Message.Contains("60 of 100"));+ var again = Step(c, r.State); // still no imports: nothing to eat, never below 0+ Assert.Equal(0, again.Food);+ Assert.Equal(again.FoodNeed, again.FoodUnmet);+ }++ // R-FOOD-003+ [Fact]+ public void FoodSupplyFollowsTheStock()+ {+ var c = Gdd();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ double Level(int food, int unmet)+ {+ var x = s.Clone(); x.Food = food; x.FoodUnmet = unmet;+ EffectsSystem.Apply(c, x, new List<Cause>());+ return x.Indicators["food_supply"];+ }+ Assert.Equal(0.4, Level(300, 0), 12); // three months: no term+ Assert.Equal(0.4 - 0.1 / 3, Level(200, 0), 12); // two months: a third of k_food off+ Assert.Equal(0.4 - 0.1, Level(0, 0), 12); // empty: all of k_food off+ Assert.Equal(0.4 - 0.1 - 0.2, Level(0, 20), 12); // 20% of the need unmet: 0.2 further+ Assert.Equal(0.0, Level(0, 100), 12); // nothing eaten: clamped at 0, never below+ Assert.True(Level(400, 0) > 0.4); // more than the cover lifts it+ }++ // R-FOOD-003: rationing and events still act on top of the stock term.+ [Fact]+ public void RationingAndEventsStillActOnFoodSupply()+ {+ var c = Gdd();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.Food = 0; // the term at its lowest, -k_food+ var rationed = s.Clone();+ rationed.Policies["rationing"] = 1.0;+ EffectsSystem.Apply(c, s, new List<Cause>());+ EffectsSystem.Apply(c, rationed, new List<Cause>());+ var feeds = rationed.EffectContributions["rationing_food"];+ Assert.True(feeds > 0);+ Assert.Equal(0.4 - 0.1, s.Indicators["food_supply"], 12);+ Assert.Equal(0.4 - 0.1 + feeds, rationed.Indicators["food_supply"], 12); // rationing on top of the stock term+ var moved = EffectsSystem.Shift(c, s, "food_supply", -0.05); // an event's shift+ Assert.Equal(-0.05, moved, 12);+ EffectsSystem.Apply(c, s, new List<Cause>());+ Assert.Equal(0.4 - 0.1 - 0.05, s.Indicators["food_supply"], 12);+ }++ // R-FOOD-002: step 7 reads the need of the people at the turn's start (the legacy head count grows after the resolver).+ [Fact]+ public void TheTurnEatsWhatTheStartOfTheTurnNeeds()+ {+ var c = Gdd();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.ActiveSituations.Add(EconomySystem.FxCrisis);+ s.FxReserves = -1000;+ s.Population["veterans"] = 2000; // 200 units now; the state's stored need is still 100+ var next = Step(c, s);+ Assert.Equal(300 - 200, next.Food); // the need is re-read at step 7, before arrivals+ Assert.True(next.TotalPopulation > 2000); // natural increase came after it+ Assert.Equal(200, next.FoodNeed);+ }++ // R-FOOD-002 (Q-POOL-4) and R-FOOD-003: the sourced 1951 currency crisis still cuts food in the real game.+ [Fact]+ public void The1951CurrencyCrisisStillCutsFood()+ {+ var s = Simulation.NewGame(Real, GoldenRun.Seed, Mode.Historical);+ var history = new List<GameState> { s };+ while (s.GameOver == null) { s = Simulation.Step(Real, s, GoldenRun.Orders(Real, s)).State; history.Add(s); }+ var first = history.FindIndex(x => x.ActiveSituations.Contains(EconomySystem.FxCrisis));+ Assert.True(first > 0 && first < history.Count - 1, "the crisis must begin before the last turn");+ var before = history[first]; // the crisis began in this turn's economy+ var cut = history[first + 1]; // the next turn's imports are cut+ Assert.True(history.Take(first + 1).All(x => x.Food == Real.Rules.Mvp!.CoverMonths!.Value * x.FoodNeed), "before the crisis the stock holds its cover");+ Assert.True(cut.Food < cut.FoodNeed * Real.Rules.Mvp!.CoverMonths!.Value, "the crisis cut the imports");+ Assert.True(cut.Indicators["food_supply"] < before.Indicators["food_supply"], "food_supply fell with the stock");+ Assert.All(history, x => Assert.True(x.Food >= 0));+ }++ // R-FOOD-001, R-LOOP-002: the pool is hashed in the GDD loop, and the legacy loop's text is unchanged.+ [Fact]+ public void ThePoolIsHashedOnlyWhenSet()+ {+ var legacy = Simulation.NewGame(ContentLoader.Load(Fixture.Write()), 1, Mode.Historical);+ Assert.DoesNotContain("\nfood=", legacy.Describe());+ var s = Simulation.NewGame(Gdd(), 1, Mode.Historical);+ Assert.Contains("\nfood=300,100,0", s.Describe());+ var other = s.Clone(); other.FoodUnmet = 1;+ Assert.NotEqual(s.Hash(), other.Hash());+ Assert.Equal(300, s.Food); // a clone does not share the pool+ }++ // R-FOOD-001: missing or out-of-range values are load errors, never a default.+ [Theory]+ [InlineData(" cover_months: 3\n", "mvp.k_food", "required")]+ [InlineData(" k_food: 0.1\n", "mvp.cover_months", "required")]+ [InlineData(" k_food: -0.1\n cover_months: 3\n", "mvp.k_food", "between 0 and 1")]+ [InlineData(" k_food: 1.5\n cover_months: 3\n", "mvp.k_food", "between 0 and 1")]+ [InlineData(" k_food: .nan\n cover_months: 3\n", "mvp.k_food", "between 0 and 1")]+ [InlineData(" k_food: 0.1\n cover_months: 0\n", "mvp.cover_months", ">= 1")]+ public void TheFoodValuesAreRequired(string extra, string field, string message)+ {+ var ex = Assert.Throws<ContentException>(() => Gdd(extra));+ Assert.Equal(field, ex.Field);+ Assert.Contains(message, ex.Message);+ }++ // R-FOOD-003: the GDD loop needs the food_supply indicator the pool feeds.+ [Fact]+ public void TheGddLoopNeedsAFoodSupplyIndicator()+ {+ var model = Fixture.Files["model.yaml"]+ .Replace(" - id: food_supply\n base: 0.4\n name: Food supply\n", "")+ .Replace(" target: food_supply\n", " target: morale\n")+ .Replace(" indicator: food_supply\n", " indicator: morale\n");+ var ex = Assert.Throws<ContentException>(() => Gdd(model: model));+ Assert.Equal("mvp.k_food", ex.Field);+ Assert.Contains("food_supply", ex.Message);+ }+}diff --git a/sim/Statecraft.Sim.Tests/golden/hash1950.txt b/sim/Statecraft.Sim.Tests/golden/hash1950.txtindex 5b44796ab..27da8b136 100644--- a/sim/Statecraft.Sim.Tests/golden/hash1950.txt+++ b/sim/Statecraft.Sim.Tests/golden/hash1950.txt@@ -109,4 +109,5 @@ site{next=2obj{first_new_yishuv=1949-06-15-score=100\ No newline at end of file+score=100+food=3003,1001,0\ No newline at end of filediff --git a/sim/Statecraft.Sim.Tests/golden/hash1952.txt b/sim/Statecraft.Sim.Tests/golden/hash1952.txtindex 5b732f5db..f47373c10 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.8566666665875042 [3FEB69D036922222]+ food_supply=0.8555155874508137 [3FEB606239AA391F]housing=0.43504947742483624 [3FDBD7D9C36B9EB6]intl_standing=0.7800000000000002 [3FE8F5C28F5C28F8]morale=0.4388039705804806 [3FDC155D3FBFE10A]@@ -18,7 +18,7 @@ eff{rationing_grates=-0.15 [BFC3333333333333]safety_lifts_morale=0.05354077083901369 [3FAB69B227832BE6]shift{- food_supply=0.11666666666666659 [3FBDDDDDDDDDDDD8]+ food_supply=0.15000000000000002 [3FC3333333333334]housing=0 [0000000000000000]intl_standing=0.28000000000000025 [3FD1EB851EB851F0]morale=-0.08000000000000007 [BFB47AE147AE1480]@@ -46,7 +46,7 @@ debt=157.01852642452684 [4063A097C4BA6E8C]fx=-12.990431328096559 [C029FB19D0A63796]rung=2;cf=0;mob=0.05 [3FA999999999999A]-stab=0.5095235022822947 [3FE04E043B5B1119]+stab=0.5097888733187989 [3FE05030C1589B0F]att=4 [4010000000000000]fired[altalena@@ -130,4 +130,5 @@ site{next=2obj{first_new_yishuv=1949-06-15-score=100\ No newline at end of file+score=100+food=2732,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 b4a495f67..0e67bdf8b 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 ad8067765007988a2ea52226a50622259b695cd72a5b735b298207e472b81504-hash1952 0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2-smoke5 85191d48688be4595726b17778ecdda0175eff8f6f0fa1d976dbe3b48b42823b-scenario-reckless e2f409a5382ea0ba01526123457a76ef3450ee242d1f7b7868b7a483abe149fa-scenario-cautious 58eb01db2e149f629bc298e9139441c5e9252d830f22908c7c888db55d167de0-scenario-mvp-absorb-first f8858f6ec1c263c1e7bae1542439c9d7358bc4caa39bc45276c4c3b93d0c0bb1-mvp-end 0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2+hash1950 ca953c983faa2a85216efdf264bf1da9167c9787a06d21a73c76717dfab0f8b4+hash1952 b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915+smoke5 848969ce7236d5fb4b8af33c2e6a8445d0a437a002b93cb076d54450c3d79e0a+scenario-reckless 420413626ec62b65f878a3cd6926d2eeec6fb0d918f3ba9e488c4f909bdf7534+scenario-cautious 5553c31a095f6b67c88f0885eca13141438d964bf07fb39af96e6bb4f3555ca8+scenario-mvp-absorb-first e01bb37a1b933a1b883655cc184c5fece35e82ad3f5890ffedcfdef5e0ff3909+mvp-end b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915diff --git a/sim/Statecraft.Sim.Tests/golden/mvp-end.txt b/sim/Statecraft.Sim.Tests/golden/mvp-end.txtindex 5b732f5db..f47373c10 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.8566666665875042 [3FEB69D036922222]+ food_supply=0.8555155874508137 [3FEB606239AA391F]housing=0.43504947742483624 [3FDBD7D9C36B9EB6]intl_standing=0.7800000000000002 [3FE8F5C28F5C28F8]morale=0.4388039705804806 [3FDC155D3FBFE10A]@@ -18,7 +18,7 @@ eff{rationing_grates=-0.15 [BFC3333333333333]safety_lifts_morale=0.05354077083901369 [3FAB69B227832BE6]shift{- food_supply=0.11666666666666659 [3FBDDDDDDDDDDDD8]+ food_supply=0.15000000000000002 [3FC3333333333334]housing=0 [0000000000000000]intl_standing=0.28000000000000025 [3FD1EB851EB851F0]morale=-0.08000000000000007 [BFB47AE147AE1480]@@ -46,7 +46,7 @@ debt=157.01852642452684 [4063A097C4BA6E8C]fx=-12.990431328096559 [C029FB19D0A63796]rung=2;cf=0;mob=0.05 [3FA999999999999A]-stab=0.5095235022822947 [3FE04E043B5B1119]+stab=0.5097888733187989 [3FE05030C1589B0F]att=4 [4010000000000000]fired[altalena@@ -130,4 +130,5 @@ site{next=2obj{first_new_yishuv=1949-06-15-score=100\ No newline at end of file+score=100+food=2732,1390,0\ No newline at end of filediff --git a/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt b/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txtindex 383c4d9f5..892b85f0f 100644--- a/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt+++ b/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt@@ -87,4 +87,5 @@ mapturn=0001-01-01:0;over=city{tel_aviv=120,90,120,80,91-coh=0.6426116838487972 [3FE4904660C50EF4]\ No newline at end of file+coh=0.6426116838487972 [3FE4904660C50EF4]+food=2253,751,0\ No newline at end of filediff --git a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txtindex 46a851479..aedc68efb 100644--- a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt+++ b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt@@ -95,4 +95,5 @@ mapturn=0001-01-01:0;over=city{tel_aviv=120,90,120,90,190-coh=0.5826124567474048 [3FE2A4C2E0FF1D3B]\ No newline at end of file+coh=0.5826124567474048 [3FE2A4C2E0FF1D3B]+food=2556,852,0\ No newline at end of filediff --git a/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt b/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txtindex 73a34e0d1..5765039f9 100644--- a/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt+++ b/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt@@ -85,4 +85,5 @@ mapturn=0001-01-01:0;over=city{tel_aviv=120,90,120,80,91-coh=0.6426116838487972 [3FE4904660C50EF4]\ No newline at end of file+coh=0.6426116838487972 [3FE4904660C50EF4]+food=2253,751,0\ No newline at end of filediff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.csindex 7f01bb651..b70a641d8 100644--- a/sim/Statecraft.Sim/Content.cs+++ b/sim/Statecraft.Sim/Content.cs@@ -479,6 +479,12 @@ namespace Statecraft.Simpublic int? ObjectiveBonusPerMonth { get; set; }/// <summary>The most bonus points one objective can earn (R-OBJ-002; D-B2, #456).</summary>public int? ObjectiveBonusCap { get; set; }+ /// <summary>How far food_supply falls when the Food stock is empty, against a full cover (R-FOOD-003; maintainer+ /// decision of 16 October 2026, #382, option (b)). Required in the GDD loop, 0 to 1.</summary>+ public double? KFood { get; set; }+ /// <summary>The months of the nation's need the Food stock holds when full: the start stock and the level the monthly+ /// imports keep (R-FOOD-001, R-FOOD-002). Required in the GDD loop, at least 1.</summary>+ public int? CoverMonths { get; set; }}/// <summary>A designated site (sites.yaml; docs/GDD.md "Pioneer work": building is allowed only at designated spots, and adiff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex a7f5450db..648aaa385 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -1018,6 +1018,13 @@ namespace Statecraft.Simif (!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");+ // 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");+ if (m.CoverMonths == null) throw new ContentException(file, "mvp.cover_months", "required when eras.yaml systems.loop is gdd");+ if (m.CoverMonths < 1) throw new ContentException(file, "mvp.cover_months", "must be >= 1");+ if (c.Indicators.All(i => i.Id != Pools.FoodIndicator))+ throw new ContentException(file, "mvp.k_food", "the Food stock feeds the food_supply indicator, which model.yaml must define");// One game has one last day (R-LOOP-004): an era cannot move it.if (m.End != c.Rules.Mvp!.End) throw new ContentException(file, "mvp.end", "must be the same in every era (the game has one end)");// R-OBJ-002. Required, so a missing key is not read as 0. Zero is allowed (a balance choice); a negative valuediff --git a/sim/Statecraft.Sim/EconomySystem.cs b/sim/Statecraft.Sim/EconomySystem.csindex 772b46aa7..f32c37fa9 100644--- a/sim/Statecraft.Sim/EconomySystem.cs+++ b/sim/Statecraft.Sim/EconomySystem.cs@@ -72,8 +72,9 @@ namespace Statecraft.Simif (!on && s.FxReserves < 0) { s.ActiveSituations.Add(FxCrisis); why.Add(new Cause("economy", FxCrisis, 1, "Foreign currency reserves are exhausted")); }else if (on && s.FxReserves > 0.25 * r.FxStart) { s.ActiveSituations.Remove(FxCrisis); why.Add(new Cause("economy", FxCrisis, -1, "Foreign currency crisis eased")); }- // The consequence: with no currency to pay for them, food imports are cut while the crisis lasts.- if (s.ActiveSituations.Contains(FxCrisis) && r.FxCrisisFoodPerYear < 0)+ // The consequence: with no currency to pay for them, food imports are cut while the crisis lasts. In the GDD loop+ // the cut falls on the Food stock's imports instead (R-FOOD-002, Q-POOL-4), and food_supply follows the stock.+ if (!c.IsGdd && s.ActiveSituations.Contains(FxCrisis) && r.FxCrisisFoodPerYear < 0){var change = EffectsSystem.Shift(c, s, "food_supply", r.FxCrisisFoodPerYear * yearFraction);if (change != 0)diff --git a/sim/Statecraft.Sim/EffectsSystem.cs b/sim/Statecraft.Sim/EffectsSystem.csindex 7ffde41cb..6eb021545 100644--- a/sim/Statecraft.Sim/EffectsSystem.cs+++ b/sim/Statecraft.Sim/EffectsSystem.cs@@ -69,9 +69,11 @@ namespace Statecraft.SimUpdateSituations(c, s, why);}- /// <summary>clamp(base + effect contributions) to [0, 1], before event shifts.</summary>+ /// <summary>clamp(base + effect contributions) to [0, 1], before event shifts. In the GDD loop food_supply also carries+ /// the Food stock's term (R-FOOD-003), exactly 0 at a full cover.</summary>internal static double Inner(Content c, GameState s, Indicator i) =>- Math.Max(0, Math.Min(1, i.Base + c.At(s.Date).Effects.Where(e => e.Target == i.Id).Sum(e => s.EffectContributions[e.Id])));+ Math.Max(0, Math.Min(1, i.Base + c.At(s.Date).Effects.Where(e => e.Target == i.Id).Sum(e => s.EffectContributions[e.Id])+ + (i.Id == Pools.FoodIndicator ? Pools.FoodTerm(c, s) : 0.0)));/// <summary>clamp(inner + event shift) to [0, 1].</summary>internal static double Level(Content c, GameState s, Indicator i) =>diff --git a/sim/Statecraft.Sim/GameState.cs b/sim/Statecraft.Sim/GameState.csindex a3c7a0caf..a871cd068 100644--- a/sim/Statecraft.Sim/GameState.cs+++ b/sim/Statecraft.Sim/GameState.cs@@ -76,6 +76,12 @@ namespace Statecraft.Sim/// <summary>The player's score (GDD "Objectives": bonus points). An int assumes whole-number points; the point values and/// the timing bonus are open decisions with the owner (D-B2, D-B6), so the type is revisited when they are set.</summary>public int Score;+ /// <summary>The national Food stock (R-FOOD-001; D-C2): units of Food, one population unit's food for a month. Never below 0.</summary>+ public int Food;+ /// <summary>The Food the nation needed in the last turn (R-FOOD-002): its population in units, set at the start and in step 7.</summary>+ public int FoodNeed;+ /// <summary>The part of <see cref="FoodNeed"/> the stock could not cover in the last turn (R-FOOD-002, Q-POOL-5).</summary>+ public int FoodUnmet;public double TotalPopulation => Population.Values.Sum();@@ -197,6 +203,12 @@ namespace Statecraft.Simif (Objectives.Count > 0)Section("obj", '{', '}', Objectives.Select(kv => kv.Key + "=" + kv.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)));if (Score != 0) { Sep(); Nl(); sb.Append("score=").Append(Score.ToString(CultureInfo.InvariantCulture)); }+ if (Food != 0 || FoodNeed != 0 || FoodUnmet != 0)+ {+ Sep(); Nl();+ sb.Append("food=").Append(Food.ToString(CultureInfo.InvariantCulture)).Append(',').Append(FoodNeed.ToString(CultureInfo.InvariantCulture))+ .Append(',').Append(FoodUnmet.ToString(CultureInfo.InvariantCulture));+ }return sb.ToString();}}diff --git a/sim/Statecraft.Sim/GoldenRun.cs b/sim/Statecraft.Sim/GoldenRun.csindex 9f40ae3c3..e3c15e992 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 = "ad8067765007988a2ea52226a50622259b695cd72a5b735b298207e472b81504";+ public const string Hash1950 = "ca953c983faa2a85216efdf264bf1da9167c9787a06d21a73c76717dfab0f8b4";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 = "0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2";+ public const string Hash1952 = "b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915";public static readonly DateTime Until1952 = new DateTime(1952, 1, 1);diff --git a/sim/Statecraft.Sim/Pools.cs b/sim/Statecraft.Sim/Pools.csnew file mode 100644index 000000000..2a0195e23--- /dev/null+++ b/sim/Statecraft.Sim/Pools.cs@@ -0,0 +1,62 @@+using System;+using System.Collections.Generic;++namespace Statecraft.Sim+{+ /// <summary>The national Food pool of the GDD v0.1 loop (Phase 2 PR 3; D-C2 "National pools"). One unit of Food is one+ /// population unit's food for one month, the nation eats its population in units each turn, and there is no storage cap+ /// (Q-POOL-2). Food comes in as a monthly import that keeps the stock at cover_months of the need, cut while foreign+ /// currency is exhausted (Q-POOL-4). The stock stops at 0, and what it cannot cover is the unmet share (Q-POOL-5).+ /// food_supply stays the 0 to 1 level the UI and events read, with a term from the stock (maintainer decision of 16+ /// October 2026, #382, option (b)). Runs only when eras.yaml systems.loop is gdd. Integers only, so no rounding drifts.</summary>+ public static class Pools+ {+ /// <summary>The indicator the Food stock feeds (model.yaml; the loader requires it in the GDD loop).</summary>+ public const string FoodIndicator = "food_supply";++ /// <summary>R-FOOD-001: the stock starts at cover_months of the start's need, so food_supply starts at its level.</summary>+ public static void Init(Content c, GameState s)+ {+ if (!c.IsGdd) return;+ var r = c.RulesAt(s.Date).Mvp!;+ s.FoodNeed = Need(s, r);+ s.Food = r.CoverMonths!.Value * s.FoodNeed;+ s.FoodUnmet = 0;+ }++ /// <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-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>+ public static void Consume(Content c, GameState s, MvpRules r, List<Cause> why)+ {+ var need = Need(s, r);+ var eaten = Math.Min(need, s.Food);+ s.Food -= eaten;+ s.FoodNeed = need;+ s.FoodUnmet = need - eaten;+ if (s.FoodUnmet > 0)+ why.Add(new Cause("economy", "food", -s.FoodUnmet, FormattableString.Invariant($"Food ran out: {s.FoodUnmet} of {need} units of the month's need went unmet")));+ if (s.ActiveSituations.Contains(EconomySystem.FxCrisis))+ {+ why.Add(new Cause("economy", "food", -eaten, FormattableString.Invariant($"No Food imported (foreign currency crisis): the stock fell to {s.Food} units")));+ return;+ }+ var target = (long)r.CoverMonths!.Value * need;+ if (s.Food < target) s.Food = (int)target;+ }++ /// <summary>R-FOOD-003: food_supply's stock term, k_food * (stock - full) / full - unmet / need, where full is+ /// cover_months of the last need. It is exactly 0 at a full stock, -k_food when the stock is empty, and the unmet+ /// share lowers it further; food_supply's clamp to 0..1 bounds it. 0 in the legacy loop and with no need.</summary>+ public static double FoodTerm(Content c, GameState s)+ {+ if (!c.IsGdd || s.FoodNeed == 0) return 0.0;+ var r = c.RulesAt(s.Date).Mvp!;+ var full = (long)r.CoverMonths!.Value * s.FoodNeed;+ return r.KFood!.Value * (s.Food - full) / full - (double)s.FoodUnmet / s.FoodNeed;+ }+ }+}diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.csindex c5b4c6275..85807a577 100644--- a/sim/Statecraft.Sim/Simulation.cs+++ b/sim/Statecraft.Sim/Simulation.cs@@ -17,6 +17,7 @@ namespace Statecraft.SimEconomySystem.Init(c, s);PopulationSystem.Init(c, s);Cities.Init(c, s);+ Pools.Init(c, s);SecuritySystem.Init(c, s, why);AttentionSystem.Refill(c, s);EventSystem.Trigger(c, s, why);diff --git a/sim/Statecraft.Sim/TurnResolver.cs b/sim/Statecraft.Sim/TurnResolver.csindex 79d1fec10..b1dacdfc8 100644--- a/sim/Statecraft.Sim/TurnResolver.cs+++ b/sim/Statecraft.Sim/TurnResolver.cs@@ -18,7 +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- // 7. Consumption: Phase 2.+ Pools.Consume(c, s, r, why); // 7. consumption: the nation eats, then imports (R-FOOD-002)Cities.House(c, s, why); // 8. housing, then Social cohesionCities.UpdateCohesion(s, r);Cities.Arrive(c, s, r, next, why); // 9. arrivalsdiff --git a/tools/tests/test_release_build.py b/tools/tests/test_release_build.pyindex 76cd0cbb9..d97377188 100644--- a/tools/tests/test_release_build.py+++ b/tools/tests/test_release_build.py@@ -8,8 +8,8 @@ import pytestimport release_build as rb-H1950 = "ad8067765007988a2ea52226a50622259b695cd72a5b735b298207e472b81504"-H1952 = "0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2"+H1950 = "ca953c983faa2a85216efdf264bf1da9167c9787a06d21a73c76717dfab0f8b4"+H1952 = "b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915"SHA = "1b7a36cb" + "0" * 32LICENCE_TEXTS = ("CC-BY-4.0.txt", "CC-BY-SA-4.0.txt", "CC0-1.0.txt", "YamlDotNet-MIT.txt")NOTICES = ["LICENSE", "LICENSES/CC-BY-4.0.txt", "LICENSES/CC-BY-SA-4.0.txt", "LICENSES/CC0-1.0.txt",diff --git a/tools/web_check.py b/tools/web_check.pyindex e04990d35..03178dd72 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 ad8067765007988a2ea52226a50622259b695cd72a5b735b298207e472b81504" --expect "GOLDEN OK 1952 0f54dc51a42575774b12a4b712d6d6ad69a45573232bd5b54b8527b24f4281f2"+ uv run tools/web_check.py unity/Builds/Web-disabled --query "golden" --expect "GOLDEN OK 1950 ca953c983faa2a85216efdf264bf1da9167c9787a06d21a73c76717dfab0f8b4" --expect "GOLDEN OK 1952 b42380ab7935e4daabd0577fa3df231c474f3ad92f6006af0a05918a46743915"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