Skip to content

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

sim: the sourced starting forces, both sides (GDD Phase 5 PR 4, refs #743) (#1186)

Beri70b83c93a6d9
diff --git a/ASSETS.yaml b/ASSETS.yaml
index ecb77ad0b..02332c5e3 100644
--- a/ASSETS.yaml
+++ b/ASSETS.yaml
@@ -200,6 +200,10 @@ rules:
licence: CC-BY-SA-4.0
source: "Generated by tools/settlement_hexes.py from settlements_1948.yaml and hexes.json"
status: verified
+ - glob: "content/map/unit_anchor_hexes.yaml"
+ licence: CC-BY-SA-4.0
+ source: "Generated by tools/unit_anchor_hexes.py from units_1948.yaml and hexes.json"
+ status: verified
- glob: "content/map/settlement_population_1945.yaml"
licence: CC-BY-SA-4.0
source: "Village Statistics, 1945 (Government of Palestine), figures read from https://en.wikipedia.org/wiki/Village_Statistics,_1945 on 2026-10-11; per-row sources in the file"
@@ -228,7 +232,7 @@ rules:
licence: CC-BY-SA-4.0
source: "The 1948 brigades, 101 Squadron and the first navy ships, with their dated positions (docs/units.md, Units in play): facts and place coordinates read from English and Hebrew Wikipedia (CC BY-SA; Wikipedia API prop=coordinates) and Wikidata (CC0), and the S-199 markings from Eduard Info 11/2025 pp. 53-54 (facts only, no text or image copied); per-row sources and check dates in the file"
status: verified
- note: "Presentation only (the map's unit tokens); the sim never reads it, so the content hash does not move (UnitsInPlayTests). Rows marked wikipedia_only are drafts until checked against a published history (Lorch, The Edge of the Sword) or the IDF and Defense Establishment Archives. Owner, 17 Oct 2026 (#879, issuecomment-6233249635): 'Accept as draft for now'; ships labelled draft (the #570 rule, 'verify later'), with a scan check before 1.0."
+ note: "Drives the map's unit tokens and, since #743, the sim reads the rows' hexes for the starting forces (StartingForces), so a new game's state carries them, and the file is part of the content hash (UnitsInPlayTests.TheUnitFileEntersTheContentHash). Rows marked wikipedia_only are drafts until checked against a published history (Lorch, The Edge of the Sword) or the IDF and Defense Establishment Archives. Owner, 17 Oct 2026 (#879, issuecomment-6233249635): 'Accept as draft for now'; ships labelled draft (the #570 rule, 'verify later'), with a scan check before 1.0."
- glob: "content/map/locations_1948.yaml"
licence: CC-BY-SA-4.0
source: "The GDD v0.2 must-have map locations (#1008, docs/locations.md): coordinates from each place's Wikidata item (CC0, property P625), names, identities and Hebrew names from English and Hebrew Wikipedia (CC BY-SA 4.0), Jerusalem's 15 May 1948 control from the Knesset's 'Liberation of Jerusalem' page and en.wiki Operation Pitchfork, Sha'ar HaAliyah's opening from R. D. Seidelman's BGU thesis abstract (facts only, no text copied beyond short quotes in comments); hexes from tools/hexgrid.py; per-row sources and check dates in the file"
diff --git a/changelog.d/sim-starting-forces-743.md b/changelog.d/sim-starting-forces-743.md
new file mode 100644
index 000000000..7101ccc46
--- /dev/null
+++ b/changelog.d/sim-starting-forces-743.md
@@ -0,0 +1,11 @@
+- GDD Phase 5 PR 4: the sourced starting forces, both sides (refs #743, #385). A new Historical game starts with one sim
+ unit per row of `content/map/units_1948.yaml` that is not hidden, is an army row, has a 15 May strength and an anchor
+ window covering 15 May 1948, on that anchor's hex (R-UNIT-006; precomputed by the new `tools/unit_anchor_hexes.py`
+ into `content/map/unit_anchor_hexes.yaml`, so the sim does no projection maths): Golani, Carmeli (at Haifa), Alexandroni, Kiryati,
+ Givati, Harel and Negev as `veteran_soldier`, and the Egyptian force, the Arab Legion, the Syrian and Iraqi forces and
+ the ALA, each under its side's new infantry type in `content/unit_types.yaml` (labelled design values, 3 movement
+ points). Strength is the row's people in 1,000-person units, halves up, never below 1 (owner, 20 October 2026, #743:
+ "all five defaults"). The sim now reads the file, so it is in the content hash and every golden moves (re-pinned,
+ docs/determinism.md): the twelve units take ids 0 to 11, and nothing else in the run changes. `--release-gate`,
+ `Build -shareable` and `tools/package_release.py` now refuse until every row a unit starts from is `fact-checked`
+ (Q-START-3); today none is. Open mode still cannot start (R-UNIT-007).
diff --git a/content/map/unit_anchor_hexes.yaml b/content/map/unit_anchor_hexes.yaml
new file mode 100644
index 000000000..8688efd0e
--- /dev/null
+++ b/content/map/unit_anchor_hexes.yaml
@@ -0,0 +1,31 @@
+# Generated by tools/unit_anchor_hexes.py from units_1948.yaml and hexes.json (hexgrid.lonlat_to_km, point_to_hex).
+# Do not edit by hand: rerun the tool after changing either input. anchor is the index in the row's anchors list.
+anchors:
+ - { id: golani, anchor: 0, q: 10, r: 9 }
+ - { id: golani, anchor: 1, q: -7, r: 24 }
+ - { id: carmeli, anchor: 0, q: 5, r: 8 }
+ - { id: carmeli, anchor: 1, q: 13, r: 5 }
+ - { id: alexandroni, anchor: 0, q: 0, r: 15 }
+ - { id: kiryati, anchor: 0, q: -3, r: 19 }
+ - { id: givati, anchor: 0, q: -5, r: 23 }
+ - { id: etzioni, anchor: 0, q: 0, r: 23 }
+ - { id: brigade_7, anchor: 0, q: -4, r: 23 }
+ - { id: brigade_7, anchor: 1, q: 2, r: 13 }
+ - { id: harel, anchor: 0, q: -2, r: 23 }
+ - { id: yiftach, anchor: 0, q: -3, r: 21 }
+ - { id: negev, anchor: 0, q: -9, r: 27 }
+ - { id: squadron_101, anchor: 0, q: -4, r: 22 }
+ - { id: squadron_101, anchor: 1, q: -2, r: 17 }
+ - { id: squadron_101, anchor: 2, q: -6, r: 23 }
+ - { id: ins_haganah, anchor: 0, q: 5, r: 8 }
+ - { id: ins_wedgwood, anchor: 0, q: 5, r: 8 }
+ - { id: egyptian_expeditionary_force, anchor: 0, q: -11, r: 27 }
+ - { id: egyptian_expeditionary_force, anchor: 1, q: -7, r: 24 }
+ - { id: egyptian_expeditionary_force, anchor: 2, q: -8, r: 25 }
+ - { id: arab_legion, anchor: 0, q: 0, r: 22 }
+ - { id: arab_legion, anchor: 1, q: -2, r: 22 }
+ - { id: syrian_army, anchor: 0, q: 10, r: 10 }
+ - { id: syrian_army, anchor: 1, q: 13, r: 5 }
+ - { id: iraqi_expeditionary_force, anchor: 0, q: 9, r: 11 }
+ - { id: iraqi_expeditionary_force, anchor: 1, q: 6, r: 13 }
+ - { id: arab_liberation_army, anchor: 0, q: 12, r: 4 }
diff --git a/content/map/units_1948.yaml b/content/map/units_1948.yaml
index 8c3f31c67..5f7b5c126 100644
--- a/content/map/units_1948.yaml
+++ b/content/map/units_1948.yaml
@@ -1,6 +1,10 @@
-# The military formations the map draws in 1948-49 (docs/units.md, "Units in play"). Map-only: the sim never reads this
-# file (ContentLoader reads only its own files), so it does not move the content hash or the goldens. The map reads it
-# (UnitRoster) together with the sim's security level and reserve call-up, and draws one token per unit.
+# The military formations the map draws in 1948-49 (docs/units.md, "Units in play"). The map reads it (UnitRoster)
+# together with the sim's security level and reserve call-up, and draws one token per unit. The sim reads it too, for the
+# starting forces (StartingForces, docs/rules/mvp.md R-UNIT-006; Phase 5 PR 4): a Historical game starts with one unit per
+# army row that is not hidden, has a 15 May strength and an anchor window covering 15 May 1948, on the anchor's hex in
+# unit_anchor_hexes.yaml (rerun tools/unit_anchor_hexes.py after changing an anchor). So the file is in the
+# content hash, and a change to such a row moves the goldens. Those rows must be fact-checked before a shareable build
+# (the release gate; Q-START-3).
#
# Owner rulings (2026-10-11): one token per brigade; the number of figures follows the call-up (1, 2 or 3); an Avia
# S-199 until the Spitfire's sourced date, then the Spitfire; brigades with no sourced position are listed but hidden;
diff --git a/content/unit_types.yaml b/content/unit_types.yaml
index c11315e4a..c7b12eb6c 100644
--- a/content/unit_types.yaml
+++ b/content/unit_types.yaml
@@ -42,3 +42,32 @@ types:
side: israel
class: armour
movement_points: 5 # DESIGN VALUE: owner-set balance, not a historical figure (D-G2, Q-MOVE-1, Q-ARTY-2: points a turn)
+# The Arab forces' types (Phase 5 PR 4, R-UNIT-006; #743, owner, 20 October 2026: "one labelled design-value infantry type
+# per Arab side that has a row, 3 movement points"). One type per side whose units_1948.yaml rows start a unit; the
+# Lebanese row is hidden, and the local forces have no row yet. The ids are the sim's, not names shown to the player (those
+# stay with Q-UI-2 and Q-START-4). Their movement points equal veteran_soldier's.
+ - id: egyptian_army
+ kind: unit
+ side: egypt
+ class: infantry
+ movement_points: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-G2, Q-MOVE-1, #743: points a turn)
+ - id: arab_legion
+ kind: unit
+ side: jordan
+ class: infantry
+ movement_points: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-G2, Q-MOVE-1, #743: points a turn)
+ - id: syrian_army
+ kind: unit
+ side: syria
+ class: infantry
+ movement_points: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-G2, Q-MOVE-1, #743: points a turn)
+ - id: iraqi_army
+ kind: unit
+ side: iraq
+ class: infantry
+ movement_points: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-G2, Q-MOVE-1, #743: points a turn)
+ - id: arab_liberation_army
+ kind: unit
+ side: ala
+ class: infantry
+ movement_points: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-G2, Q-MOVE-1, #743: points a turn)
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index cf1155773..2c741f3df 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -27,10 +27,10 @@ macOS IL2CPP parity check is not an MVP release gate.
"$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -buildTarget WebGL -executeMethod Statecraft.Game.EditorTools.Build.Web -compression gzip -shareable -logFile "$PWD/unity-build-web-gz.log"
git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset
golden_expect=(); while read -r name hash; do [[ -z "$name" || "$name" == \#* ]] || golden_expect+=(--expect "GOLDEN OK $name $hash"); done < sim/Statecraft.Sim.Tests/golden/manifest.txt
- # one GOLDEN OK line per manifest golden (#394), e.g. "GOLDEN OK hash1950 e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a"
- # and "GOLDEN OK hash1952 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde"
+ # one GOLDEN OK line per manifest golden (#394), e.g. "GOLDEN OK hash1950 259133fc83a95471547be0cb1a317bae55c8324778864733b88957d7529c8585"
+ # and "GOLDEN OK hash1952 452c65ece470e844f6898151c4d9328aa0b2e59df82db4763214d43a8e8ea7f1"
uv run tools/web_check.py unity/Builds/Web-gzip --query "golden&smoke=5" "${golden_expect[@]}" \
- --expect "SMOKE OK 5 turns 1948-10-15 8d000459d26a08a49583adfc88c14799ce6e6f653dcecff1e30b5e737f0959aa"
+ --expect "SMOKE OK 5 turns 1948-10-15 e5a66f9c2c0c0718d7969289fcc8dd005dedddd37a7c25adfffdc45e2e8b29cd"
uv run tools/web_check.py unity/Builds/Web-gzip --startscreen new --timeout 300 --stall 90
uv run tools/web_check.py unity/Builds/Web-gzip --startscreen recording --timeout 300 --stall 90
uv run tools/web_check.py unity/Builds/Web-gzip --startscreen new --query lang=he --timeout 300 --stall 90
@@ -56,7 +56,7 @@ macOS IL2CPP parity check is not an MVP release gate.
"$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -buildTarget WebGL -executeMethod Statecraft.Game.EditorTools.Build.Web -compression gzip -decompressionFallback -shareable -out Builds/Web-pages -logFile "$PWD/unity-build-web-pages.log"
git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset
uv run tools/web_check.py unity/Builds/Web-pages --query "golden&smoke=5" "${golden_expect[@]}" \
- --expect "SMOKE OK 5 turns 1948-10-15 8d000459d26a08a49583adfc88c14799ce6e6f653dcecff1e30b5e737f0959aa"
+ --expect "SMOKE OK 5 turns 1948-10-15 e5a66f9c2c0c0718d7969289fcc8dd005dedddd37a7c25adfffdc45e2e8b29cd"
uv run tools/web_check.py unity/Builds/Web-pages --startscreen new --timeout 300 --stall 90
uv run tools/web_check.py unity/Builds/Web-pages --startscreen recording --timeout 300 --stall 90
uv run tools/web_check.py unity/Builds/Web-pages --startscreen new --query lang=he --timeout 300 --stall 90
diff --git a/docs/determinism.md b/docs/determinism.md
index 5cdb49224..b97ec21dc 100644
--- a/docs/determinism.md
+++ b/docs/determinism.md
@@ -10,7 +10,8 @@ The simulation must produce the same state, bit for bit, on .NET, Unity Mono and
seeds 0 and 1234567. The expected values come from Sebastiano Vigna's reference `splitmix64.c`
(https://prng.di.unimi.it/splitmix64.c), compiled and run separately. They were not copied from this implementation.
- **No trigonometry in the sim:** the sim calls only `Math.Abs`, `Math.Min` and `Math.Max`. Geometry that needs
- cos/sin (which hex owns a settlement) is precomputed by `tools/settlement_hexes.py` and read as content.
+ cos/sin (which hex owns a settlement, which hex a starting force's anchor is on) is precomputed by
+ `tools/settlement_hexes.py` and `tools/unit_anchor_hexes.py` and read as content.
- **Canonical hash:** `GameState.Hash()` is SHA-256 over a canonical text. Keys are sorted ordinally. Doubles are
written as IEEE bit patterns, with -0.0 written as 0.0. Culture is invariant. Fractional site and city-project
carry follows the same rule: nonzero carry is written as 16 hexadecimal digits of its IEEE bit pattern, and zero carry is omitted.
@@ -32,9 +33,9 @@ final `GameState.Hash()` is pinned:
| Run | Ends | Hash |
|---|---|---|
-| to 1950-01-01 (`Hash1950`) | 1950-01-15, turn 20 | `e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a` |
-| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde` |
-| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde` |
+| to 1950-01-01 (`Hash1950`) | 1950-01-15, turn 20 | `259133fc83a95471547be0cb1a317bae55c8324778864733b88957d7529c8585` |
+| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `452c65ece470e844f6898151c4d9328aa0b2e59df82db4763214d43a8e8ea7f1` |
+| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `452c65ece470e844f6898151c4d9328aa0b2e59df82db4763214d43a8e8ea7f1` |
`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
@@ -43,7 +44,7 @@ player check enumerate the manifest, so it and every scenario are checked withou
A further value is pinned for the browser smoke run (`?smoke=5`: the golden seed, five turns played through the UI's own
buttons, 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 8d000459d26a08a49583adfc88c14799ce6e6f653dcecff1e30b5e737f0959aa`.
+ministers): `SMOKE OK 5 turns 1948-10-15 e5a66f9c2c0c0718d7969289fcc8dd005dedddd37a7c25adfffdc45e2e8b29cd`.
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 WebGL build with every manifest entry (plus the UI-path smoke line) with:
@@ -54,7 +55,7 @@ while read -r name hash; do
golden_expect+=(--expect "GOLDEN OK $name $hash")
done < sim/Statecraft.Sim.Tests/golden/manifest.txt
uv run tools/web_check.py unity/Builds/Web-<compression> --query "golden&smoke=5" "${golden_expect[@]}" \
- --expect "SMOKE OK 5 turns 1948-10-15 8d000459d26a08a49583adfc88c14799ce6e6f653dcecff1e30b5e737f0959aa"
+ --expect "SMOKE OK 5 turns 1948-10-15 e5a66f9c2c0c0718d7969289fcc8dd005dedddd37a7c25adfffdc45e2e8b29cd"
```
**When a golden moves.** The test fails with the lines that changed, grouped by section (`[ind]`, `[pol]`, `[bud]`,
@@ -321,3 +322,11 @@ The hash reads the state keys, so it never sees a record outside its window. An
| Phase 7 PR 4 carry canonical fix | 1952 | `37866907` | Nonzero site and city-project carry is written as IEEE bits, consistently on .NET and Unity Mono, instead of runtime-dependent round-trip decimal text. Only canonical representation changes; the stored progress, all other snapshot lines, completion dates and gameplay are unchanged (was `ef8c5fea`). |
| Phase 7 PR 4 carry canonical fix | mvp-end | `37866907` | Nonzero site and city-project carry is written as IEEE bits, consistently on .NET and Unity Mono, instead of runtime-dependent round-trip decimal text. Only canonical representation changes; the stored progress, all other snapshot lines, completion dates and gameplay are unchanged (was `ef8c5fea`). |
| #738 remaining scenario step | scenario-mvp-absorb-first | `c045ea90` | extends the run to 15 January 1950 so it completes `absorb_immigrants` (R-OBJ-004): two halutz cohorts free city housing, fourteen housing projects take the overflow and two industry projects raise employment, using only existing commands (was `234e32ee`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | 1950 | `259133fc` | A new game starts with the 12 forces of `map/units_1948.yaml` (R-UNIT-006): seven IDF brigades as `veteran_soldier` and the five Arab forces with a row, ids 0 to 11, so the `units[` section gains them and every later unit, cohort and city project id moves up by 12 (the halutz group 1 is now 13, `next=` 4 is 16). Nothing else in the snapshot moves: no rule reads the forces yet (was `e3c76f5f`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | 1952 | `452c65ec` | same; `next=` 7 is 19 (was `37866907`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | mvp-end | `452c65ec` | same as 1952 (was `37866907`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | smoke5 | `e5a66f9c` | same; the 12 forces are in the state from the first turn (was `8d000459`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | scenario-cautious | `b4e5caa1` | same; the scenario has no unit of its own, so it gains the `units[` section and `next=12` (was `9a3d241e`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | scenario-reckless | `8d644f6e` | same as cautious (was `d7dbcf75`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | scenario-mvp-absorb-first | `7d37c0d0` | same as cautious; the longer #738 run now also carries the 12 forces (was `c045ea90`) |
+| GDD Phase 5 PR 4: the sourced starting forces enter the state | scenario-mvp-defeat | `7bd5158f` | same as cautious; the defeat is unchanged (was `f3daaa70`) |
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 47cd078fa..51892fd36 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -136,12 +136,16 @@ R-CAMP-002: A camp site's `city` is the MVP city (`cities.yaml`) nearest to the
## Military units
-Phase 5 PR 2 (#741) adds the record and the types only; nothing moves, fights or trains into them yet (owner, 18 October 2026, #741: movement points in Phase 5 PR 5, upkeep in PR 3, enemy types in PR 4).
+Phase 5 PR 2 (#741) adds the record and the types only; nothing moves, fights or trains into them yet (owner, 18 October 2026, #741: movement points in Phase 5 PR 5, upkeep in PR 3, enemy types in PR 4). Phase 5 PR 4 (#743) adds the Arab forces' types and the sourced starting forces (R-UNIT-006).
R-UNIT-001: A military unit is a group at formation scale, one token per formation (D-A1; Q-UNIT-1). It has a side, a type, a hex, a strength (an integer, in population units) and a standing order with its target. A military type in `unit_types.yaml` is a `unit` with a `side` (one of `units_1948.yaml`'s sides) and a `class` (infantry, artillery or armour); the loader refuses a type with only one of them, an unknown side or class, or a population type with either, naming the file and field. The MVP's military types are Israel's `veteran_soldier`, `artillery` and `armoured_car`; `recruit` stays a count per city (R-TRAIN-003).
R-UNIT-002: A unit's side, strength, order and order target are written into the state hash only when they are not at their default ("" or 0), after its service (R-LOOP-002's rule), so a halutz unit's hash text, and every golden, is unchanged.
+R-UNIT-006: A new Historical game places one military unit per row of `map/units_1948.yaml` that is not `hidden`, has `service: army` (the squadron and the ships stay presentation-only tokens, Q-UNIT-5), has a `strength` whose `as_of` is the start day, and has an anchor window [from, to) covering the start. The unit stands on the hex that holds the first such anchor's coordinates, by the map's projection and cube rounding (`tools/hexgrid.py`, Unity's `HexPicker`), precomputed by `tools/unit_anchor_hexes.py` into `map/unit_anchor_hexes.yaml`, which the sim reads (no projection maths in the sim, docs/determinism.md); the token may stand one hex away (`UnitPlacer`), which is presentation. Every IDF brigade is a `veteran_soldier`; an Arab force takes its side's one military type, a labelled design value of class infantry with 3 movement points. Its strength is the row's people in population units, the nearest unit with a half up and never below 1 (`people_per_unit` 1,000: Golani's 4,500 is 5, Kiryati's 1,400 is 1). The units take ids 0 upward in the file's order, before any other unit (owner, 20 October 2026, #743: "all five defaults"). The file is in the content hash (Q-START-1), and so is the hex file. The loader refuses a starting row whose anchor is off the map or not on land or has no row in the hex file, a hex row for an anchor the unit file does not have, or whose side has no single military type, naming the file and the row. A shareable build refuses while any row a unit starts from is not `fact-checked` (Q-START-3): `Statecraft.Cli --release-gate`, `Build -shareable` and `tools/package_release.py` name them.
+
+R-UNIT-007: Open mode starts no forces (Q-START-2, owner, 15 October 2026); `Simulation.NewGame` refuses Open mode until milestone M4.
+
## Corridors
Corridor work is step 5 too, after the sites (Phase 4 PR 2, #786; owner, 17 October 2026, #782: the plan's Q-COR-1 to Q-COR-7 and Q-RAIL-1). `content/corridors.yaml` holds each corridor's kind (`road` or `rail`), names, map route and segments; a segment's hexes are derived from the route's traced line by `tools/corridor_hexes.py`. The Money and turns per segment are labelled design values in `rules.yaml` `mvp:` (Q-COR-6). On screen a segment is its corridor's name and its number ("Burma Road, segment 2"), never a waypoint's name (Q-SENS-1). The MVP's corridors are the Burma Road (four segments), the 1949 Haifa–Tel Aviv rail link (one) and the Tel Aviv–Netanya road (four, on straight draft lines between its five sourced places; owner, 18 October 2026, #786, Q-COR-3 (b)). A segment point in a hex the grid counts as sea (the coast) counts in its nearest land neighbour, as a shore town does.
diff --git a/docs/units.md b/docs/units.md
index ca501cd37..96780d3a8 100644
--- a/docs/units.md
+++ b/docs/units.md
@@ -66,10 +66,11 @@ Not in the slice:
Normal play draws one token per unit from two inputs: the sim's state and `content/map/units_1948.yaml`.
- **The state** gives the date, the security level and the reserve call-up (`GameState.Date`, `Rung`, `Mobilization`).
- Nothing else in the sim describes the military: it has no formations and no positions (design:
- `docs/superpowers/specs/2026-10-11-units-in-play-design.md`).
-- **The data file** is map-only. `ContentLoader` never reads it, so the content hash and the goldens do not move
- (`UnitsInPlayTests.TheUnitFileDoesNotMoveTheContentHash`). The WebGL manifest ships it.
+ Since Phase 5 PR 4 it also holds the starting forces (below); the tokens do not read them yet, they keep reading the
+ file's rows until Phase 5 PR 14 (design: `docs/superpowers/specs/2026-10-11-units-in-play-design.md`).
+- **The data file** is read by both. The sim reads the rows a new game starts a unit from (`StartingForces`; Q-START-1,
+ owner, 15 October 2026), so the file is in the content hash and moves the goldens
+ (`StartingForcesTests.TheUnitFileEntersTheContentHash`). The WebGL manifest ships it.
Code:
- `UnitData`: the file.
@@ -182,9 +183,29 @@ date; `as_of` is 15 May 1948, the day the ruling gives the strengths for.
- **No figure, no strength:** Etzioni, the 7th, the 8th and Oded have no size in the note, so their rows give none and
stay `status: draft`.
-- **Still map-only:** the sim does not read the file yet, so the goldens do not move. Phase 5 PR 4's sim reading follows.
+- **The sim reads them** since Phase 5 PR 4: see "The starting forces" below.
- Tests: `test_idf_brigade_strengths_are_secondary_and_to_verify` (Python) and `UnitsInPlayTests` (EditMode).
+### The starting forces (Phase 5 PR 4, #743)
+
+A Historical game on 15 May 1948 starts with one sim unit per row that is not hidden, is an army row, has a 15 May
+strength and has an anchor window covering the day (docs/rules/mvp.md R-UNIT-006; owner, 20 October 2026, #743: "all five
+defaults"). The unit stands on the hex holding the anchor's coordinates, by the map's own projection and rounding
+(`HexPicker`, `tools/hexgrid.py`), precomputed by `tools/unit_anchor_hexes.py` into `content/map/unit_anchor_hexes.yaml`
+(rerun it after changing an anchor); the token may still stand one hex away (`UnitPlacer`), which is presentation.
+- **Types:** every IDF brigade is a `veteran_soldier`. Each Arab side with a starting row has one infantry type, a labelled
+ design value with 3 movement points: `egyptian_army`, `arab_legion` (Jordan), `syrian_army`, `iraqi_army`,
+ `arab_liberation_army`. These ids are the sim's, not names shown to the player (Q-UI-2, Q-START-4).
+- **Strength** is the row's people in 1,000-person population units, the nearest unit with a half up, never below 1.
+- **Who starts:** Golani 5, Carmeli 2 (at Haifa, its sector seat), Alexandroni 5, Kiryati 1, Givati 5, Harel 1,
+ Negev 2; Egypt 10, the Arab Legion 5, Syria 3, Iraq 3, the ALA 4. Nothing starts for Etzioni (no sourced strength),
+ the 7th and Yiftach (no window on 15 May), Oded, the 8th and the Lebanese row (hidden), or the squadron and the two
+ ships (tokens only, Q-UNIT-5).
+- **Release gate:** every row the sim starts a unit from must be `fact-checked` before a shareable build carries it
+ (Q-START-3). `Statecraft.Cli --release-gate`, `Build -shareable` and `tools/package_release.py` refuse until then, and
+ name the rows; today that is all twelve.
+- Tests: `StartingForcesTests` (dotnet) and `UnitsInPlayTests.TheStartMatchesTheMap` (EditMode).
+
### The 1948 Collection on the tokens (#665)
The tokens wear Tal Heuberger's figures from The 1948 Collection (#507, #680), streamed after the first frame
diff --git a/sim/Statecraft.Cli/Program.cs b/sim/Statecraft.Cli/Program.cs
index ff1cf697a..80d42d0f6 100644
--- a/sim/Statecraft.Cli/Program.cs
+++ b/sim/Statecraft.Cli/Program.cs
@@ -62,12 +62,14 @@ catch (ContentException e) { Console.Error.WriteLine($"Content error: {e.Message
// --release-gate: the sensitivity gate before a build is shared (spec 5.5; tools/package_release.py, Build -shareable).
// Exit 0 and "RELEASE GATE OK" when every sensitive event is sensitivity-reviewed and (R-ALT-011, Q-ALT-9) every
-// consequence card and every event with variants has a person's reviewed_by; else exit 3 naming them.
+// consequence card and every event with variants has a person's reviewed_by, and (R-UNIT-006, Q-START-3) every
+// units_1948.yaml row a new game starts a unit from is fact-checked; else exit 3 naming them.
if (Array.IndexOf(args, "--release-gate") >= 0)
{
var open = ReleaseGate.SensitiveUnreviewed(content);
var unsigned = ReleaseGate.AlternateUnsigned(content);
- if (open.Count == 0 && unsigned.Count == 0) { Console.WriteLine("RELEASE GATE OK"); return 0; }
+ var forces = ReleaseGate.StartingForcesUnchecked(content);
+ if (open.Count == 0 && unsigned.Count == 0 && forces.Count == 0) { Console.WriteLine("RELEASE GATE OK"); return 0; }
if (open.Count > 0)
Console.WriteLine("RELEASE GATE REFUSED: the owner's sensitivity review is missing for: " + string.Join(", ", open)
+ " (set status: sensitivity-reviewed in each event's YAML; see docs/m3-release.md)");
@@ -76,6 +78,9 @@ if (Array.IndexOf(args, "--release-gate") >= 0)
Console.WriteLine("RELEASE GATE REFUSED: no person has signed off (reviewed_by) these alternate cards: " + string.Join(", ", unsigned)
+ " (see docs/m3-release.md)");
foreach (var id in unsigned) Console.WriteLine(" unsigned alternate card: " + id);
+ if (forces.Count > 0)
+ Console.WriteLine("RELEASE GATE REFUSED: these starting forces' rows are not fact-checked: " + string.Join(", ", forces)
+ + " (status: fact-checked in content/map/units_1948.yaml; Q-START-3, #743)");
return 3;
}
diff --git a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
index dc3c24ec9..572c385a8 100644
--- a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
+++ b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
@@ -148,6 +148,11 @@ public class DesignValuesTests
("unit_types.yaml", "types[veteran_soldier].movement_points"),
("unit_types.yaml", "types[artillery].movement_points"),
("unit_types.yaml", "types[armoured_car].movement_points"),
+ ("unit_types.yaml", "types[egyptian_army].movement_points"), // #743, owner, 20 October 2026
+ ("unit_types.yaml", "types[arab_legion].movement_points"), // #743, owner, 20 October 2026
+ ("unit_types.yaml", "types[syrian_army].movement_points"), // #743, owner, 20 October 2026
+ ("unit_types.yaml", "types[iraqi_army].movement_points"), // #743, owner, 20 October 2026
+ ("unit_types.yaml", "types[arab_liberation_army].movement_points"), // #743, owner, 20 October 2026
// The national Arms pool (Phase 2 PR 3b; #781, owner 18 October 2026: "Approve as drafted").
("rules.yaml", "attention_cost.buy_arms"),
("rules.yaml", "mvp.arms_start"),
diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.cs
index 6603574dd..bdbc14ad6 100644
--- a/sim/Statecraft.Sim.Tests/Fixture.cs
+++ b/sim/Statecraft.Sim.Tests/Fixture.cs
@@ -235,6 +235,8 @@ series:
["sites.yaml"] = GddSites,
["projects.yaml"] = GddProjects,
["corridors.yaml"] = GddCorridors,
+ ["map/units_1948.yaml"] = "units: []\n", // no starting forces (R-UNIT-006); StartingForcesTests writes rows
+ ["map/unit_anchor_hexes.yaml"] = "anchors: []\n", // their hexes (tools/unit_anchor_hexes.py)
};
if (extra != null) foreach (var kv in extra) o[kv.Key] = kv.Value;
return o;
diff --git a/sim/Statecraft.Sim.Tests/MilitaryUnitTests.cs b/sim/Statecraft.Sim.Tests/MilitaryUnitTests.cs
index d5b8c8630..68bfcc676 100644
--- a/sim/Statecraft.Sim.Tests/MilitaryUnitTests.cs
+++ b/sim/Statecraft.Sim.Tests/MilitaryUnitTests.cs
@@ -36,7 +36,7 @@ public class MilitaryUnitTests
{
var c = ContentLoader.Load(RealContentTests.ContentRoot());
Assert.Equal(new[] { ("veteran_soldier", "unit", "israel", "infantry"), ("artillery", "unit", "israel", "artillery"), ("armoured_car", "unit", "israel", "armour") },
- c.UnitTypes.Where(t => t.Side != "").Select(t => (t.Id, t.Kind, t.Side, t.Class)));
+ c.UnitTypes.Where(t => t.Side == "israel").Select(t => (t.Id, t.Kind, t.Side, t.Class)));
Assert.Equal("", c.UnitTypes.Single(t => t.Id == "recruit").Side); // a count per city until PR 3 (R-TRAIN-003)
}
diff --git a/sim/Statecraft.Sim.Tests/MovementTests.cs b/sim/Statecraft.Sim.Tests/MovementTests.cs
index c699689ad..f7dc1f921 100644
--- a/sim/Statecraft.Sim.Tests/MovementTests.cs
+++ b/sim/Statecraft.Sim.Tests/MovementTests.cs
@@ -88,7 +88,8 @@ public class MovementTests
new SortedDictionary<string, int>(costs));
Assert.Equal(new SortedSet<string>(costs.Keys), new SortedSet<string>(c.Hexes.Where(h => h.Land).Select(h => h.Biome)));
Assert.DoesNotContain(c.Hexes, h => h.Land && (h.Biome == "sea" || h.Biome == "lake"));
- Assert.Equal(new[] { ("veteran_soldier", 3), ("artillery", 2), ("armoured_car", 5) },
+ Assert.Equal(new[] { ("veteran_soldier", 3), ("artillery", 2), ("armoured_car", 5), ("egyptian_army", 3), ("arab_legion", 3),
+ ("syrian_army", 3), ("iraqi_army", 3), ("arab_liberation_army", 3) }, // the Arab types: #743, owner, 20 October 2026
c.UnitTypes.Where(t => t.Side != "").Select(t => (t.Id, t.MovementPoints)));
}
@@ -367,7 +368,7 @@ public class MovementTests
var c = ContentLoader.Load(RealContentTests.ContentRoot());
var s = Simulation.NewGame(c, 1, Mode.Historical);
foreach (var h in c.SettlementHexes) { var id = s.NextId++; s.Units.Add(id, new Unit(id, "armoured_car", h.Q, h.R, side: "israel")); }
- Assert.Equal(25, s.Units.Count);
+ Assert.Equal(25 + c.StartingForces.Count, s.Units.Count); // with the starting forces (R-UNIT-006): the enemy's hexes block
var best = double.MaxValue;
var listed = 0;
for (int run = 0; run < 5; run++)
@@ -376,7 +377,7 @@ public class MovementTests
listed = s.Units.Keys.Sum(id => Movement.Reachable(c, s, id).Count);
best = Math.Min(best, w.Elapsed.TotalMilliseconds);
}
- _out.WriteLine(string.Format(CultureInfo.InvariantCulture, "25 Reachable calls, {0} hexes listed: {1:F2} ms (budget 16 ms, {2:F1}x margin)", listed, best, 16 / best));
+ _out.WriteLine(string.Format(CultureInfo.InvariantCulture, "{3} Reachable calls, {0} hexes listed: {1:F2} ms (budget 16 ms, {2:F1}x margin)", listed, best, 16 / best, s.Units.Count));
Assert.True(listed > 25);
Assert.True(best < 16, string.Format(CultureInfo.InvariantCulture, "{0:F2} ms", best));
}
diff --git a/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs b/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs
index 0093d4844..bd4db322e 100644
--- a/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs
+++ b/sim/Statecraft.Sim.Tests/ReferencePlayerTests.cs
@@ -82,7 +82,7 @@ public class ReferencePlayerTests
training.Cohorts.Clear();
Assert.Contains(ReferencePlayer.Commands(Mvp, training), x => x is Train);
var trained = s.Clone();
- trained.Units.Add(1, new Unit(1, "halutz", -3, 19));
+ trained.Units.Add(trained.NextId, new Unit(trained.NextId, "halutz", -3, 19));
Assert.DoesNotContain(ReferencePlayer.Commands(Mvp, trained), x => x is Train);
var busy = s.Clone();
busy.Cities["tel_aviv"] = busy.Cities["tel_aviv"].WithCounts(106, 106, 0); // 106 jobs: all filled, nobody free
@@ -98,32 +98,32 @@ public class ReferencePlayerTests
public void ItSendsAnIdleHalutzToTheFirstAvailableSite()
{
var s = Simulation.NewGame(Mvp, GoldenRun.Seed, Mode.Historical);
- s.Units.Add(7, new Unit(7, "halutz", -3, 19));
- s.Units.Add(8, new Unit(8, "halutz", -3, 19));
- s.NextId = 9;
+ s.Units.Add(17, new Unit(17, "halutz", -3, 19));
+ s.Units.Add(18, new Unit(18, "halutz", -3, 19));
+ s.NextId = 19;
s.Treasury = 10;
// Two groups, six yishuv sites (Q-SITE-1, #785): each group takes the next free site in ordinal id order.
var builds = ReferencePlayer.Commands(Mvp, s).OfType<PioneerWork>().ToList();
- Assert.Equal(new[] { (7, "build_yishuv", "beit_kama"), (8, "build_yishuv", "beit_shemesh") }, builds.Select(b => (b.Unit, b.Action, b.Site)));
+ Assert.Equal(new[] { (17, "build_yishuv", "beit_kama"), (18, "build_yishuv", "beit_shemesh") }, builds.Select(b => (b.Unit, b.Action, b.Site)));
Assert.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.Units.Add(19, new Unit(19, "halutz", -3, 19)); // a site being built names its unit (SiteWork, R-VET-002)
+ oneLeft.NextId = 20;
+ oneLeft.Sites["beit_kama"] = new SiteWork("beit_kama", 19, 3, null);
oneLeft.Sites["beit_shemesh"] = SiteWork.Built("beit_shemesh", new DateTime(1949, 6, 15));
oneLeft.Sites["gilat"] = SiteWork.Built("gilat", new DateTime(1949, 6, 15));
oneLeft.Sites["kiryat_shmona"] = SiteWork.Built("kiryat_shmona", 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 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", "beit_shemesh_field") }, last.Select(b => (b.Unit, b.Action, b.Site)));
+ Assert.Equal(new[] { (17, "build_yishuv", "reim"), (18, "plow_fields", "beit_shemesh_field") }, last.Select(b => (b.Unit, b.Action, b.Site)));
var none = oneLeft.Clone();
- none.Sites["reim"] = new SiteWork("reim", 7, 3, null);
+ none.Sites["reim"] = new SiteWork("reim", 17, 3, null);
// Every yishuv site taken: the idle group plows the first ready field, beit_shemesh_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", "beit_shemesh_field"), (plow.Unit, plow.Action, plow.Site));
+ Assert.Equal((18, "plow_fields", "beit_shemesh_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["beit_shemesh_field"] = SiteWork.Built("beit_shemesh_field", new DateTime(1949, 6, 15));
@@ -131,17 +131,17 @@ public class ReferencePlayerTests
none.Sites["kiryat_shmona_field"] = SiteWork.Built("kiryat_shmona_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));
+ Assert.Equal((18, "build_camp", "camp_80"), (camp.Unit, camp.Action, camp.Site));
// Every camp site taken as well: the idle group takes the lowest free corridor segment (R-COR-001).
none.Sites["camp_80"] = SiteWork.Built("camp_80", new DateTime(1949, 6, 15));
none.Sites["tzrifin"] = SiteWork.Built("tzrifin", new DateTime(1949, 6, 15));
var road = Assert.Single(ReferencePlayer.Commands(Mvp, none).OfType<PioneerWork>());
- Assert.Equal((8, "build_road", "burma_road:1"), (road.Unit, road.Action, road.Site));
+ Assert.Equal((18, "build_road", "burma_road:1"), (road.Unit, road.Action, road.Site));
Assert.Empty(Simulation.Step(Mvp, none, ReferencePlayer.Commands(Mvp, none)).Rejected);
// Two idle groups: each takes the next free segment.
none.Sites["reim"] = SiteWork.Built("reim", new DateTime(1949, 12, 15));
none.Sites["reim_field"] = SiteWork.Built("reim_field", new DateTime(1949, 12, 15));
- Assert.Equal(new[] { (7, "burma_road:1"), (8, "burma_road:2") },
+ Assert.Equal(new[] { (17, "burma_road:1"), (18, "burma_road:2") },
ReferencePlayer.Commands(Mvp, none).OfType<PioneerWork>().Select(p => (p.Unit, p.Site)));
var poor = s.Clone();
poor.Treasury = 0;
diff --git a/sim/Statecraft.Sim.Tests/StartingForcesTests.cs b/sim/Statecraft.Sim.Tests/StartingForcesTests.cs
new file mode 100644
index 000000000..f3faa2fe2
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/StartingForcesTests.cs
@@ -0,0 +1,180 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>The sourced starting forces, both sides (GDD Phase 5 PR 4; #743, owner, 20 October 2026: "all five defaults").
+/// A Historical game starts with one unit per row of map/units_1948.yaml that is not hidden, is an army row, has a 15 May
+/// strength and has an anchor window covering the start; the unit stands on the anchor's hex, read from
+/// map/unit_anchor_hexes.yaml (written by tools/unit_anchor_hexes.py, so the sim needs no projection maths).</summary>
+public class StartingForcesTests
+{
+ static readonly Content Real = ContentLoader.Load(RealContentTests.ContentRoot());
+
+ /// <summary>The fixture's military types: Israel's brigade type and one Egyptian type (design values for the test).</summary>
+ const string Types = Fixture.GddUnitTypes
+ + " - { id: veteran_soldier, kind: unit, side: israel, class: infantry, movement_points: 3 }\n"
+ + " - { id: egyptian_army, kind: unit, side: egypt, class: infantry, movement_points: 3 }\n";
+
+ /// <summary>One units_1948.yaml row in the fixture's map (an army row with one anchor from 15 May 1948) and its anchor's
+ /// unit_anchor_hexes.yaml row on hex (q, r). The anchor's coordinates are those of hex (1, 0); the sim never reads them.</summary>
+ static (string row, string hex) Row(string id, string side, int? people, int q = 1, int r = 0, string extra = "", string from = "1948-05-15",
+ string service = "army", string status = "draft") =>
+ (FormattableString.Invariant($"- id: {id}\n service: {service}\n side: {side}\n status: {status}\n{extra}")
+ + (people is int p ? FormattableString.Invariant($" strength: {{ value: {p}, as_of: '1948-05-15' }}\n") : "")
+ + FormattableString.Invariant($" anchors:\n - {{ place: Here, lon: 34.29, lat: 33.35, from: '{from}', to: '1949-01-01' }}\n"),
+ FormattableString.Invariant($" - {{ id: {id}, anchor: 0, q: {q}, r: {r} }}\n"));
+
+ static Content Load(params (string row, string hex)[] rows) => Load("anchors:\n" + string.Concat(rows.Select(x => x.hex)), rows);
+
+ static Content Load(string hexes, params (string row, string hex)[] rows) => ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string>
+ {
+ ["unit_types.yaml"] = Types,
+ ["map/units_1948.yaml"] = "units:\n" + string.Concat(rows.Select(x => x.row)),
+ ["map/unit_anchor_hexes.yaml"] = hexes,
+ })));
+
+ // R-UNIT-006: every starting unit is one row's, at that row's anchor covering 15 May 1948, with the owner's type and
+ // its strength in 1,000-person units (halves up). The unit with id i is the content's i-th starting force.
+ [Fact]
+ public void EveryStartingUnitNamesItsRowAndAnchor()
+ {
+ Assert.Equal(new[]
+ {
+ ("golani", "Yavne'el", "veteran_soldier", "israel", 5, 10, 9),
+ ("carmeli", "Haifa", "veteran_soldier", "israel", 2, 5, 8),
+ ("alexandroni", "Netanya (Camp Dora)", "veteran_soldier", "israel", 5, 0, 15),
+ ("kiryati", "Tel Aviv", "veteran_soldier", "israel", 1, -3, 19),
+ ("givati", "Gedera", "veteran_soldier", "israel", 5, -5, 23),
+ ("harel", "Sha'ar HaGai", "veteran_soldier", "israel", 1, -2, 23),
+ ("negev", "Nir Am (Mekorot camp)", "veteran_soldier", "israel", 2, -9, 27),
+ ("egyptian_expeditionary_force", "Gaza", "egyptian_army", "egypt", 10, -11, 27),
+ ("arab_legion", "Ramallah", "arab_legion", "jordan", 5, 0, 22),
+ ("syrian_army", "South of Lake Tiberias, before Samakh", "syrian_army", "syria", 3, 10, 10),
+ ("iraqi_expeditionary_force", "The high ground over Gesher", "iraqi_army", "iraq", 3, 9, 11),
+ ("arab_liberation_army", "al-Malikiyya", "arab_liberation_army", "ala", 4, 12, 4),
+ }, Real.StartingForces.Select(f => (f.Row, f.Anchor, f.Type, f.Side, f.Strength, f.Q, f.R)));
+ var s = Simulation.NewGame(Real, GoldenRun.Seed, Mode.Historical);
+ Assert.Equal(Real.StartingForces.Count, s.Units.Count);
+ for (int i = 0; i < Real.StartingForces.Count; i++)
+ {
+ var (f, u) = (Real.StartingForces[i], s.Units[i]);
+ Assert.Equal((f.Type, f.Side, f.Strength, f.Q, f.R, 0, "", ""), (u.Type, u.Side, u.Strength, u.Q, u.R, u.Service, u.Order, u.OrderTarget));
+ }
+ Assert.All(Real.StartingForces, f => Assert.NotNull(Real.HexAt(f.Q, f.R)));
+ }
+
+ // R-UNIT-006: a hidden row, a row with no sourced strength and a row with no window on 15 May start nothing.
+ [Fact]
+ public void HiddenRowsStartNothing()
+ {
+ var rows = Real.StartingForces.Select(f => f.Row).ToList();
+ foreach (var id in new[] { "oded", "brigade_8", "lebanese_army" }) Assert.DoesNotContain(id, rows); // hidden
+ Assert.DoesNotContain("etzioni", rows); // no strength
+ foreach (var id in new[] { "yiftach", "brigade_7" }) Assert.DoesNotContain(id, rows); // no 15 May window
+ // The real hidden rows have no anchor, so the fixture holds the case that would otherwise start a unit.
+ var c = Load(Row("seen", "israel", 20), Row("unseen", "israel", 20, extra: " hidden: \"no sourced place\"\n"),
+ Row("unsized", "israel", null), Row("nobody", "israel", 0), Row("later", "israel", 20, from: "1948-06-01"));
+ Assert.Equal(new[] { "seen" }, c.StartingForces.Select(f => f.Row));
+ }
+
+ // R-UNIT-006, Q-UNIT-5 (owner, 15 October 2026): the squadron and the two ships stay presentation-only tokens.
+ [Fact]
+ public void AirAndNavyFollowTheAnswer()
+ {
+ var rows = Real.StartingForces.Select(f => f.Row).ToList();
+ foreach (var id in new[] { "squadron_101", "ins_haganah", "ins_wedgwood" }) Assert.DoesNotContain(id, rows);
+ var c = Load(Row("ships", "israel", 20, service: "navy"));
+ Assert.Empty(c.StartingForces);
+ }
+
+ // R-UNIT-006 (#743, owner, 20 October 2026): people to population units, the nearest unit, a half up, never below 1.
+ // The fixture's people_per_unit is 10.
+ [Fact]
+ public void StrengthsRoundToTheNearestUnitHalvesUpNeverBelowOne()
+ {
+ var c = Load(Row("a", "israel", 45), Row("b", "egypt", 14, q: 2), Row("c", "israel", 4, q: 3));
+ Assert.Equal(new[] { ("a", 5), ("b", 1), ("c", 1) }, c.StartingForces.Select(f => (f.Row, f.Strength)));
+ Assert.Equal(new[] { ("a", "veteran_soldier"), ("b", "egyptian_army"), ("c", "veteran_soldier") }, c.StartingForces.Select(f => (f.Row, f.Type)));
+ Assert.Equal(new[] { (1, 0), (2, 0), (3, 0) }, c.StartingForces.Select(f => (f.Q, f.R)));
+ }
+
+ // R-UNIT-006: a starting row the sim cannot place is a load error naming the file and the row, never a silent skip.
+ [Theory]
+ [InlineData("syria", 1, 0, "units[x].side", "no military type of side 'syria'")]
+ [InlineData("israel", 0, 0, "units[x].anchors[0]", "hex q=0 r=0 is not a land hex")]
+ [InlineData("israel", 40, 0, "units[x].anchors[0]", "hex q=40 r=0 is not on the map")]
+ public void AStartingRowNeedsALandHexAndAType(string side, int q, int r, string field, string message)
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(Row("x", side, 20, q, r)));
+ Assert.Equal("map/units_1948.yaml", ex.File);
+ Assert.Equal(field, ex.Field);
+ Assert.Contains(message, ex.Message);
+ }
+
+ // R-UNIT-006, Q-START-1 (owner, 15 October 2026): the sim reads units_1948.yaml, so the file is in the content hash.
+ [Fact]
+ public void TheUnitFileEntersTheContentHash()
+ {
+ var a = Load(Row("a", "israel", 20));
+ var row = Row("a", "israel", 20);
+ var b = Load((row.row + " # a comment changes the file\n", row.hex));
+ Assert.NotEqual(a.Hash, b.Hash);
+ var h = Load("anchors:\n" + row.hex + "# a comment changes the hex file\n", row);
+ Assert.NotEqual(a.Hash, h.Hash);
+ }
+
+ // docs/determinism.md: the sim does no projection maths. A starting unit stands on the hex unit_anchor_hexes.yaml gives
+ // its anchor (tools/unit_anchor_hexes.py), not on one the sim works out from lon/lat: the fixture's anchor lies in hex
+ // (1, 0), the file says (2, 1).
+ [Fact]
+ public void TheHexIsReadFromTheGeneratedFileNotProjected()
+ {
+ var c = Load(Row("a", "israel", 20, q: 2, r: 1));
+ Assert.Equal(new[] { (2, 1) }, c.StartingForces.Select(f => (f.Q, f.R)));
+ }
+
+ // The real file is the tool's output (tools/tests/test_unit_anchor_hexes.py); these are its hexes for the 12 starting
+ // anchors, the ones the sim's own projection gave before #1186's review moved it out of the sim (goldens unchanged).
+ [Fact]
+ public void TheRealStartingHexesArePinned() =>
+ Assert.Equal(new[]
+ {
+ ("golani", 10, 9), ("carmeli", 5, 8), ("alexandroni", 0, 15), ("kiryati", -3, 19), ("givati", -5, 23), ("harel", -2, 23),
+ ("negev", -9, 27), ("egyptian_expeditionary_force", -11, 27), ("arab_legion", 0, 22), ("syrian_army", 10, 10),
+ ("iraqi_expeditionary_force", 9, 11), ("arab_liberation_army", 12, 4),
+ }, Real.StartingForces.Select(f => (f.Row, f.Q, f.R)));
+
+ // A starting anchor with no hex row, a row for an anchor that does not exist, a repeated row and a q that is not a whole
+ // number are load errors naming
+ // unit_anchor_hexes.yaml: the file is stale and the tool must be rerun.
+ [Theory]
+ [InlineData("anchors: []\n", "anchors", "no hex for units[x].anchors[0]")]
+ [InlineData("anchors:\n - { id: x, anchor: 0, q: 1, r: 0 }\n - { id: y, anchor: 0, q: 1, r: 0 }\n", "anchors[y]", "no anchor 0 of a row 'y'")]
+ [InlineData("anchors:\n - { id: x, anchor: 0, q: 1, r: 0 }\n - { id: x, anchor: 1, q: 1, r: 0 }\n", "anchors[x]", "no anchor 1 of a row 'x'")]
+ [InlineData("anchors:\n - { id: x, anchor: 0, q: 1, r: 0 }\n - { id: x, anchor: 0, q: 2, r: 0 }\n", "anchors[x]", "anchor 0 is listed twice")]
+ [InlineData("anchors:\n - { id: x, anchor: 0, q: 1.5, r: 0 }\n", "anchors[x].q", "required, a whole number")]
+ public void TheHexFileMustMatchTheUnitFile(string hexes, string field, string message)
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(hexes, Row("x", "israel", 20)));
+ Assert.Equal("map/unit_anchor_hexes.yaml", ex.File);
+ Assert.Equal(field, ex.Field);
+ Assert.Contains(message, ex.Message);
+ }
+
+ // R-UNIT-007, Q-START-2 (owner, 15 October 2026): Open mode starts no forces; it cannot start a game yet at all.
+ [Fact]
+ public void OpenModeStartsNoForces() =>
+ Assert.Throws<NotSupportedException>(() => Simulation.NewGame(Real, GoldenRun.Seed, Mode.Open));
+
+ // R-UNIT-006, Q-START-3 (#743, owner, 20 October 2026): a shareable build waits until every row the sim starts a unit
+ // from is fact-checked.
+ [Fact]
+ public void TheReleaseGateWaitsForEveryStartingRowToBeFactChecked()
+ {
+ Assert.Equal(Real.StartingForces.Select(f => f.Row).OrderBy(x => x, StringComparer.Ordinal), ReleaseGate.StartingForcesUnchecked(Real));
+ var c = Load(Row("b", "israel", 20), Row("a", "israel", 20, q: 2, status: "fact-checked"));
+ Assert.Equal(new[] { "b" }, ReleaseGate.StartingForcesUnchecked(c));
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/TrainingTests.cs b/sim/Statecraft.Sim.Tests/TrainingTests.cs
index 7af6d9190..e01af8fa9 100644
--- a/sim/Statecraft.Sim.Tests/TrainingTests.cs
+++ b/sim/Statecraft.Sim.Tests/TrainingTests.cs
@@ -251,7 +251,7 @@ public class TrainingTests
}
Assert.Empty(s.Cohorts);
Assert.Equal(3, s.Cities["tel_aviv"].Recruits);
- Assert.Empty(s.Units); // a recruit is a count until Phase 5
+ Assert.Equal(Mvp.StartingForces.Count, s.Units.Count); // the starting forces only (R-UNIT-006): a recruit is a count until Phase 5
}
/// <summary>The timing rule, the plan's reading of D-A6 (Task 4.3) and not part of the owner's ruling: the turn a cohort is ordered in is its first training turn, so a cohort
@@ -273,8 +273,8 @@ public class TrainingTests
var u0 = Step(Mvp, start, new Train("tel_aviv", "halutz", 2)).State; // halutz: 4 turns, done at the end of T+3
var u2 = Step(Mvp, Step(Mvp, u0).State).State;
- Assert.Empty(u2.Units);
- Assert.Equal(2, Step(Mvp, u2).State.Units.Count);
+ Assert.Equal(Mvp.StartingForces.Count, u2.Units.Count); // the starting forces only (R-UNIT-006)
+ Assert.Equal(Mvp.StartingForces.Count + 2, Step(Mvp, u2).State.Units.Count);
}
// R-TRAIN-003
@@ -287,12 +287,13 @@ public class TrainingTests
var cohort = Assert.Single(s.Cohorts.Keys);
for (int turn = 1; turn < Mvp.UnitTypes.Single(t => t.Id == "halutz").TrainingTurns; turn++)
{
- Assert.Empty(s.Units);
+ Assert.Equal(Mvp.StartingForces.Count, s.Units.Count); // the starting forces only (R-UNIT-006)
s = Step(Mvp, s).State;
}
Assert.Empty(s.Cohorts);
- Assert.Equal(new[] { cohort + 1, cohort + 2, cohort + 3 }, s.Units.Keys);
- Assert.All(s.Units.Values, u => Assert.Equal(("halutz", -3, 19), (u.Type, u.Q, u.R))); // Tel Aviv's settlement hex
+ var halutzim = s.Units.Values.Skip(Mvp.StartingForces.Count).ToList(); // after the starting forces (R-UNIT-006)
+ Assert.Equal(new[] { cohort + 1, cohort + 2, cohort + 3 }, halutzim.Select(u => u.Id));
+ Assert.All(halutzim, u => Assert.Equal(("halutz", -3, 19), (u.Type, u.Q, u.R))); // Tel Aviv's settlement hex
Assert.Equal(cohort + 4, s.NextId);
Assert.Equal(0, s.Cities["tel_aviv"].Recruits);
}
diff --git a/sim/Statecraft.Sim.Tests/golden/hash1950.txt b/sim/Statecraft.Sim.Tests/golden/hash1950.txt
index 3e225c10c..951e82572 100644
--- a/sim/Statecraft.Sim.Tests/golden/hash1950.txt
+++ b/sim/Statecraft.Sim.Tests/golden/hash1950.txt
@@ -114,14 +114,26 @@ city{
tiberias=6,2,8,2,1,c0.18928571428571433 [3FC83A83A83A83AA]
zikhron_yaakov=2,1,2,1,1,c0.35 [3FD6666666666666]
units[
- 1:veteran_halutz@-3,19/6
+ 0:veteran_soldier@10,9|side=israel|strength=5
+ 1:veteran_soldier@5,8|side=israel|strength=2
+ 2:veteran_soldier@0,15|side=israel|strength=5
+ 3:veteran_soldier@-3,19|side=israel|strength=1
+ 4:veteran_soldier@-5,23|side=israel|strength=5
+ 5:veteran_soldier@-2,23|side=israel|strength=1
+ 6:veteran_soldier@-9,27|side=israel|strength=2
+ 7:egyptian_army@-11,27|side=egypt|strength=10
+ 8:arab_legion@0,22|side=jordan|strength=5
+ 9:syrian_army@10,10|side=syria|strength=3
+ 10:iraqi_army@9,11|side=iraq|strength=3
+ 11:arab_liberation_army@12,4|side=ala|strength=4
+ 13:veteran_halutz@-3,19/6
site{
beit_kama=done,1949-06-15
beit_shemesh=done,1949-11-15
- gilat=b,1,4,3FE4DD2F1A9FBE78
+ gilat=b,13,4,3FE4DD2F1A9FBE78
cproj[
- 2:housing@tel_aviv,-4,20/done,1949-10-15
- 3:housing@tel_aviv,-3,19/4,3FDB851EB851EB88
-next=4
+ 14:housing@tel_aviv,-4,20/done,1949-10-15
+ 15:housing@tel_aviv,-3,19/4,3FDB851EB851EB88
+next=16
food=3003,1001,0
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim.Tests/golden/hash1952.txt b/sim/Statecraft.Sim.Tests/golden/hash1952.txt
index 7380859be..b941a3912 100644
--- a/sim/Statecraft.Sim.Tests/golden/hash1952.txt
+++ b/sim/Statecraft.Sim.Tests/golden/hash1952.txt
@@ -135,7 +135,19 @@ city{
tiberias=6,2,13,2,0,c0 [0000000000000000]
zikhron_yaakov=2,1,4,1,0,c0 [0000000000000000]
units[
- 1:veteran_halutz@-3,19/6
+ 0:veteran_soldier@10,9|side=israel|strength=5
+ 1:veteran_soldier@5,8|side=israel|strength=2
+ 2:veteran_soldier@0,15|side=israel|strength=5
+ 3:veteran_soldier@-3,19|side=israel|strength=1
+ 4:veteran_soldier@-5,23|side=israel|strength=5
+ 5:veteran_soldier@-2,23|side=israel|strength=1
+ 6:veteran_soldier@-9,27|side=israel|strength=2
+ 7:egyptian_army@-11,27|side=egypt|strength=10
+ 8:arab_legion@0,22|side=jordan|strength=5
+ 9:syrian_army@10,10|side=syria|strength=3
+ 10:iraqi_army@9,11|side=iraq|strength=3
+ 11:arab_liberation_army@12,4|side=ala|strength=4
+ 13:veteran_halutz@-3,19/6
site{
beit_kama=done,1949-06-15
beit_kama_field=done,1951-10-15
@@ -146,12 +158,12 @@ site{
mefalsim=done,1951-02-15
reim=done,1951-07-15
cproj[
- 2:housing@tel_aviv,-4,20/done,1949-10-15
- 3:housing@tel_aviv,-3,19/done,1950-06-15
- 4:housing@tel_aviv,-3,20/done,1951-02-15
- 5:housing@tel_aviv,-2,18/done,1951-10-15
- 6:housing@tel_aviv,-2,19/4,3FDB851EB851EB88
-next=7
+ 14:housing@tel_aviv,-4,20/done,1949-10-15
+ 15:housing@tel_aviv,-3,19/done,1950-06-15
+ 16:housing@tel_aviv,-3,20/done,1951-02-15
+ 17:housing@tel_aviv,-2,18/done,1951-10-15
+ 18:housing@tel_aviv,-2,19/4,3FDB851EB851EB88
+next=19
obj{
first_new_yishuv=1951-02-15
score=100
diff --git a/sim/Statecraft.Sim.Tests/golden/manifest.txt b/sim/Statecraft.Sim.Tests/golden/manifest.txt
index e790fc0dc..11caf130b 100644
--- a/sim/Statecraft.Sim.Tests/golden/manifest.txt
+++ b/sim/Statecraft.Sim.Tests/golden/manifest.txt
@@ -2,11 +2,11 @@
# 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 e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a
-hash1952 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde
-smoke5 8d000459d26a08a49583adfc88c14799ce6e6f653dcecff1e30b5e737f0959aa
-scenario-reckless d7dbcf75d3767cf2de0621de15f67c37068363060e3a0267cc185a590d01fe2d
-scenario-cautious 9a3d241ece9c896367c75c66e094019cd9b8e946bd14f7b083b19a3b483301ee
-scenario-mvp-absorb-first c045ea9023a7afa2743162d5f7517fbdf7b12156fe64201394fdb3cf6e83eb94
-mvp-end 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde
-scenario-mvp-defeat f3daaa70500cf86e741f5cc32475f9aa78d3b73b93fa87911f69e72f35a61eab
+hash1950 259133fc83a95471547be0cb1a317bae55c8324778864733b88957d7529c8585
+hash1952 452c65ece470e844f6898151c4d9328aa0b2e59df82db4763214d43a8e8ea7f1
+smoke5 e5a66f9c2c0c0718d7969289fcc8dd005dedddd37a7c25adfffdc45e2e8b29cd
+scenario-reckless 8d644f6eea2abe2d1fccafec82191994769c6c2feb480a3ca3bc045d6089c6a5
+scenario-cautious b4e5caa1fec69c7b8883226e01d40283aed0999e405f162d2f197f8943c64267
+scenario-mvp-absorb-first 7d37c0d0a4740bd3c74191feb138de24351bebca4682c27d6597373b8478091b
+mvp-end 452c65ece470e844f6898151c4d9328aa0b2e59df82db4763214d43a8e8ea7f1
+scenario-mvp-defeat 7bd5158f52e0743533c930a583aed9e2cc146220016aa0532fdefef21f2e9905
diff --git a/sim/Statecraft.Sim.Tests/golden/mvp-end.txt b/sim/Statecraft.Sim.Tests/golden/mvp-end.txt
index 7380859be..b941a3912 100644
--- a/sim/Statecraft.Sim.Tests/golden/mvp-end.txt
+++ b/sim/Statecraft.Sim.Tests/golden/mvp-end.txt
@@ -135,7 +135,19 @@ city{
tiberias=6,2,13,2,0,c0 [0000000000000000]
zikhron_yaakov=2,1,4,1,0,c0 [0000000000000000]
units[
- 1:veteran_halutz@-3,19/6
+ 0:veteran_soldier@10,9|side=israel|strength=5
+ 1:veteran_soldier@5,8|side=israel|strength=2
+ 2:veteran_soldier@0,15|side=israel|strength=5
+ 3:veteran_soldier@-3,19|side=israel|strength=1
+ 4:veteran_soldier@-5,23|side=israel|strength=5
+ 5:veteran_soldier@-2,23|side=israel|strength=1
+ 6:veteran_soldier@-9,27|side=israel|strength=2
+ 7:egyptian_army@-11,27|side=egypt|strength=10
+ 8:arab_legion@0,22|side=jordan|strength=5
+ 9:syrian_army@10,10|side=syria|strength=3
+ 10:iraqi_army@9,11|side=iraq|strength=3
+ 11:arab_liberation_army@12,4|side=ala|strength=4
+ 13:veteran_halutz@-3,19/6
site{
beit_kama=done,1949-06-15
beit_kama_field=done,1951-10-15
@@ -146,12 +158,12 @@ site{
mefalsim=done,1951-02-15
reim=done,1951-07-15
cproj[
- 2:housing@tel_aviv,-4,20/done,1949-10-15
- 3:housing@tel_aviv,-3,19/done,1950-06-15
- 4:housing@tel_aviv,-3,20/done,1951-02-15
- 5:housing@tel_aviv,-2,18/done,1951-10-15
- 6:housing@tel_aviv,-2,19/4,3FDB851EB851EB88
-next=7
+ 14:housing@tel_aviv,-4,20/done,1949-10-15
+ 15:housing@tel_aviv,-3,19/done,1950-06-15
+ 16:housing@tel_aviv,-3,20/done,1951-02-15
+ 17:housing@tel_aviv,-2,18/done,1951-10-15
+ 18:housing@tel_aviv,-2,19/4,3FDB851EB851EB88
+next=19
obj{
first_new_yishuv=1951-02-15
score=100
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt b/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt
index 04e5ca80b..6268cb396 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt
@@ -100,5 +100,19 @@ city{
tel_aviv=248,106,255,106,9,c0.3458823529411765 [3FD622EFBC895623]
tiberias=6,2,6,2,0,c0.35 [3FD6666666666666]
zikhron_yaakov=2,1,2,1,0,c0.35 [3FD6666666666666]
+units[
+ 0:veteran_soldier@10,9|side=israel|strength=5
+ 1:veteran_soldier@5,8|side=israel|strength=2
+ 2:veteran_soldier@0,15|side=israel|strength=5
+ 3:veteran_soldier@-3,19|side=israel|strength=1
+ 4:veteran_soldier@-5,23|side=israel|strength=5
+ 5:veteran_soldier@-2,23|side=israel|strength=1
+ 6:veteran_soldier@-9,27|side=israel|strength=2
+ 7:egyptian_army@-11,27|side=egypt|strength=10
+ 8:arab_legion@0,22|side=jordan|strength=5
+ 9:syrian_army@10,10|side=syria|strength=3
+ 10:iraqi_army@9,11|side=iraq|strength=3
+ 11:arab_liberation_army@12,4|side=ala|strength=4
+next=12
food=2253,751,0
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt
index 0e5e1ed70..8423d65a9 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt
@@ -115,18 +115,18 @@ city{
tiberias=6,2,8,2,1,c0.18928571428571433 [3FC83A83A83A83AA]
zikhron_yaakov=2,1,2,1,1,c0.35 [3FD6666666666666]
units[
- 7:halutz@-3,19
- 8:halutz@-3,19
- 9:halutz@-3,19
- 10:halutz@-3,19
- 11:halutz@-3,19
- 12:halutz@-3,19
- 13:halutz@-3,19
- 14:halutz@-3,19
- 15:halutz@-3,19
- 16:halutz@-3,19
- 17:halutz@-3,19
- 18:halutz@-3,19
+ 0:veteran_soldier@10,9|side=israel|strength=5
+ 1:veteran_soldier@5,8|side=israel|strength=2
+ 2:veteran_soldier@0,15|side=israel|strength=5
+ 3:veteran_soldier@-3,19|side=israel|strength=1
+ 4:veteran_soldier@-5,23|side=israel|strength=5
+ 5:veteran_soldier@-2,23|side=israel|strength=1
+ 6:veteran_soldier@-9,27|side=israel|strength=2
+ 7:egyptian_army@-11,27|side=egypt|strength=10
+ 8:arab_legion@0,22|side=jordan|strength=5
+ 9:syrian_army@10,10|side=syria|strength=3
+ 10:iraqi_army@9,11|side=iraq|strength=3
+ 11:arab_liberation_army@12,4|side=ala|strength=4
19:halutz@-3,19
20:halutz@-3,19
21:halutz@-3,19
@@ -273,18 +273,18 @@ units[
162:halutz@-3,19
163:halutz@-3,19
164:halutz@-3,19
+ 165:halutz@-3,19
+ 166:halutz@-3,19
+ 167:halutz@-3,19
+ 168:halutz@-3,19
+ 169:halutz@-3,19
+ 170:halutz@-3,19
+ 171:halutz@-3,19
+ 172:halutz@-3,19
+ 173:halutz@-3,19
+ 174:halutz@-3,19
+ 175:halutz@-3,19
176:halutz@-3,19
- 177:halutz@-3,19
- 178:halutz@-3,19
- 179:halutz@-3,19
- 180:halutz@-3,19
- 181:halutz@-3,19
- 182:halutz@-3,19
- 183:halutz@-3,19
- 184:halutz@-3,19
- 185:halutz@-3,19
- 186:halutz@-3,19
- 187:halutz@-3,19
188:halutz@-3,19
189:halutz@-3,19
190:halutz@-3,19
@@ -356,24 +356,36 @@ units[
256:halutz@-3,19
257:halutz@-3,19
258:halutz@-3,19
+ 259:halutz@-3,19
+ 260:halutz@-3,19
+ 261:halutz@-3,19
+ 262:halutz@-3,19
+ 263:halutz@-3,19
+ 264:halutz@-3,19
+ 265:halutz@-3,19
+ 266:halutz@-3,19
+ 267:halutz@-3,19
+ 268:halutz@-3,19
+ 269:halutz@-3,19
+ 270:halutz@-3,19
cproj[
- 1:housing@haifa,5,8/done,1949-02-15
- 2:housing@haifa,4,9/done,1949-02-15
- 3:housing@haifa,5,9/done,1949-03-15
- 4:industry@haifa,6,8/done,1949-03-15
- 5:housing@jerusalem,0,22/done,1949-04-15
- 6:housing@jerusalem,1,22/done,1949-04-15
- 165:housing@jerusalem,-1,23/done,1949-05-15
- 166:housing@jerusalem,1,23/done,1949-06-15
- 167:industry@jerusalem,-1,24/done,1949-06-15
- 168:housing@petah_tikva,-2,18/done,1949-07-15
- 169:housing@petah_tikva,-1,18/done,1949-07-15
- 170:housing@rehovot,-4,20/done,1949-08-15
- 171:housing@hadera,2,12/done,1949-08-15
- 172:housing@netanya,0,15/done,1949-09-15
- 173:housing@jerusalem,0,23/done,1949-09-15
- 174:housing@rishon_lezion,-4,21/done,1949-10-15
-next=259
+ 13:housing@haifa,5,8/done,1949-02-15
+ 14:housing@haifa,4,9/done,1949-02-15
+ 15:housing@haifa,5,9/done,1949-03-15
+ 16:industry@haifa,6,8/done,1949-03-15
+ 17:housing@jerusalem,0,22/done,1949-04-15
+ 18:housing@jerusalem,1,22/done,1949-04-15
+ 177:housing@jerusalem,-1,23/done,1949-05-15
+ 178:housing@jerusalem,1,23/done,1949-06-15
+ 179:industry@jerusalem,-1,24/done,1949-06-15
+ 180:housing@petah_tikva,-2,18/done,1949-07-15
+ 181:housing@petah_tikva,-1,18/done,1949-07-15
+ 182:housing@rehovot,-4,20/done,1949-08-15
+ 183:housing@hadera,2,12/done,1949-08-15
+ 184:housing@netanya,0,15/done,1949-09-15
+ 185:housing@jerusalem,0,23/done,1949-09-15
+ 186:housing@rishon_lezion,-4,21/done,1949-10-15
+next=271
obj{
absorb_immigrants=1950-01-15
score=100
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt
index 9f898d719..cd625875b 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt
@@ -133,6 +133,20 @@ city{
tel_aviv=248,106,541,106,4,c0 [0000000000000000]
tiberias=6,2,13,2,0,c0 [0000000000000000]
zikhron_yaakov=2,1,4,1,0,c0 [0000000000000000]
+units[
+ 0:veteran_soldier@10,9|side=israel|strength=5
+ 1:veteran_soldier@5,8|side=israel|strength=2
+ 2:veteran_soldier@0,15|side=israel|strength=5
+ 3:veteran_soldier@-3,19|side=israel|strength=1
+ 4:veteran_soldier@-5,23|side=israel|strength=5
+ 5:veteran_soldier@-2,23|side=israel|strength=1
+ 6:veteran_soldier@-9,27|side=israel|strength=2
+ 7:egyptian_army@-11,27|side=egypt|strength=10
+ 8:arab_legion@0,22|side=jordan|strength=5
+ 9:syrian_army@10,10|side=syria|strength=3
+ 10:iraqi_army@9,11|side=iraq|strength=3
+ 11:arab_liberation_army@12,4|side=ala|strength=4
+next=12
food=0,1390,1390
exhausted=3
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt b/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt
index a9a664311..85875180d 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt
@@ -98,5 +98,19 @@ city{
tel_aviv=248,106,255,106,9,c0.3458823529411765 [3FD622EFBC895623]
tiberias=6,2,6,2,0,c0.35 [3FD6666666666666]
zikhron_yaakov=2,1,2,1,0,c0.35 [3FD6666666666666]
+units[
+ 0:veteran_soldier@10,9|side=israel|strength=5
+ 1:veteran_soldier@5,8|side=israel|strength=2
+ 2:veteran_soldier@0,15|side=israel|strength=5
+ 3:veteran_soldier@-3,19|side=israel|strength=1
+ 4:veteran_soldier@-5,23|side=israel|strength=5
+ 5:veteran_soldier@-2,23|side=israel|strength=1
+ 6:veteran_soldier@-9,27|side=israel|strength=2
+ 7:egyptian_army@-11,27|side=egypt|strength=10
+ 8:arab_legion@0,22|side=jordan|strength=5
+ 9:syrian_army@10,10|side=syria|strength=3
+ 10:iraqi_army@9,11|side=iraq|strength=3
+ 11:arab_liberation_army@12,4|side=ala|strength=4
+next=12
food=2253,751,0
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 8003fa785..93d561b57 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -1195,6 +1195,9 @@ namespace Statecraft.Sim
public List<CityStart> Cities = new List<CityStart>();
/// <summary>The GDD population and unit types (unit_types.yaml). Empty in the legacy loop.</summary>
public List<UnitType> UnitTypes = new List<UnitType>();
+ /// <summary>The forces a Historical game starts with (map/units_1948.yaml; R-UNIT-006), in file order: the unit with id i
+ /// of a new game is the i-th. Empty in the legacy loop.</summary>
+ public List<StartingForce> StartingForces = new List<StartingForce>();
/// <summary>The GDD designated sites (sites.yaml), in file order. Empty in the legacy loop.</summary>
public List<Site> Sites = new List<Site>();
/// <summary>The GDD city project kinds (projects.yaml), in file order. Empty in the legacy loop.</summary>
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index dc030e715..e57b930e0 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -375,6 +375,8 @@ namespace Statecraft.Sim
c.ProjectKinds = Read<ProjectsFile>(readFile, "projects.yaml").Projects; // design values (Phase 3 PR 4)
c.Corridors = Read<CorridorsFile>(readFile, "corridors.yaml").Corridors; // sourced, hexes derived (Phase 4 PR 2)
ValidateGdd(c, settlementIds);
+ // The sourced starting forces (Phase 5 PR 4, R-UNIT-006), once the types and people_per_unit are known valid.
+ c.StartingForces = StartingForces.Read(readFile, c);
}
EventRules.ValidateStructured(c); // R-EFX-006: after the GDD records it names are read
c.BuildWindows();
diff --git a/sim/Statecraft.Sim/GoldenRun.cs b/sim/Statecraft.Sim/GoldenRun.cs
index 2e2394991..310f285b9 100644
--- a/sim/Statecraft.Sim/GoldenRun.cs
+++ b/sim/Statecraft.Sim/GoldenRun.cs
@@ -16,13 +16,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 = "e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a";
+ public const string Hash1950 = "259133fc83a95471547be0cb1a317bae55c8324778864733b88957d7529c8585";
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 = "37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde";
+ public const string Hash1952 = "452c65ece470e844f6898151c4d9328aa0b2e59df82db4763214d43a8e8ea7f1";
public static readonly DateTime Until1952 = new DateTime(1952, 1, 1);
diff --git a/sim/Statecraft.Sim/ReleaseGate.cs b/sim/Statecraft.Sim/ReleaseGate.cs
index 738aeb484..c251983c8 100644
--- a/sim/Statecraft.Sim/ReleaseGate.cs
+++ b/sim/Statecraft.Sim/ReleaseGate.cs
@@ -26,5 +26,11 @@ namespace Statecraft.Sim
public static IReadOnlyList<string> AlternateUnsigned(Content c) =>
c.Events.Where(e => (e.Kind == EventKinds.Consequence || e.Variants.Count > 0) && e.ReviewedBy == "")
.Select(e => e.Id).OrderBy(x => x, StringComparer.Ordinal).ToList();
+
+ /// <summary>R-UNIT-006, Q-START-3 (owner, 15 October 2026; #743, owner, 20 October 2026): the units_1948.yaml rows a
+ /// new game starts a unit from whose status is not yet fact-checked, in id order. Once the sim reads a row it is game
+ /// state, so a shareable build refuses while this is not empty.</summary>
+ public static IReadOnlyList<string> StartingForcesUnchecked(Content c) =>
+ c.StartingForces.Where(f => f.Status != "fact-checked").Select(f => f.Row).OrderBy(x => x, StringComparer.Ordinal).ToList();
}
}
diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.cs
index fb8df9d69..ed06c52bf 100644
--- a/sim/Statecraft.Sim/Simulation.cs
+++ b/sim/Statecraft.Sim/Simulation.cs
@@ -18,6 +18,7 @@ namespace Statecraft.Sim
PopulationSystem.Init(c, s);
Cities.Init(c, s);
Pools.Init(c, s);
+ StartingForces.Init(c, s); // R-UNIT-006: before any event can grant a unit, so the forces take ids 0 to n-1
SecuritySystem.Init(c, s, why);
AttentionSystem.Refill(c, s);
EventSystem.Trigger(c, s, why);
diff --git a/sim/Statecraft.Sim/StartingForces.cs b/sim/Statecraft.Sim/StartingForces.cs
new file mode 100644
index 000000000..b682387a8
--- /dev/null
+++ b/sim/Statecraft.Sim/StartingForces.cs
@@ -0,0 +1,157 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using YamlDotNet.Core;
+using YamlDotNet.Serialization;
+
+namespace Statecraft.Sim
+{
+ /// <summary>One unit a Historical game starts with (R-UNIT-006): the units_1948.yaml row it comes from, the anchor it
+ /// stands at, its type, side and strength in population units, and the anchor's hex.</summary>
+ public sealed class StartingForce
+ {
+ public string Row { get; set; } = "";
+ /// <summary>The anchor's place, as the row names it.</summary>
+ public string Anchor { get; set; } = "";
+ public string Type { get; set; } = "";
+ public string Side { get; set; } = "";
+ public int Strength { get; set; }
+ public int Q { get; set; }
+ public int R { get; set; }
+ /// <summary>The row's review status (draft, to_verify, fact-checked); the release gate reads it (Q-START-3).</summary>
+ public string Status { get; set; } = "";
+ }
+
+ /// <summary>The sourced starting forces, both sides (GDD Phase 5 PR 4; docs/rules/mvp.md R-UNIT-006, R-UNIT-007).
+ /// The sim reads map/units_1948.yaml (Q-START-1, owner, 15 October 2026), so the file is in the content hash. Only the
+ /// keys the start needs are read, untyped, as for settlements_1948.yaml: the map's reader (Unity's UnitData) and
+ /// tools/tests/test_units_1948.py own the rest of the row.</summary>
+ public static class StartingForces
+ {
+ public const string FileName = "map/units_1948.yaml";
+ /// <summary>Each anchor's hex, written by tools/unit_anchor_hexes.py with the map's projection and rounding
+ /// (tools/hexgrid.py, Unity's HexPicker), so the sim needs no trigonometry (docs/determinism.md).</summary>
+ public const string HexesFileName = "map/unit_anchor_hexes.yaml";
+ /// <summary>Every IDF brigade starts as a veteran soldier (#743, owner, 20 October 2026).</summary>
+ public const string IsraeliBrigadeType = "veteran_soldier";
+
+ /// <summary>The starting forces in the file's order (R-UNIT-006): every row that is not hidden, is an army row (the
+ /// squadron and the ships stay tokens, Q-UNIT-5), has a strength for the start day and an anchor window
+ /// [from, to) covering it. The first such anchor places the unit on its hex in unit_anchor_hexes.yaml (the hex holding
+ /// its coordinates, precomputed by tools/unit_anchor_hexes.py). Strength is the row's people in population units,
+ /// the nearest unit with a half up and at least 1 (#743). A row it cannot place is a load error.</summary>
+ internal static List<StartingForce> Read(Func<string, string?> readFile, Content c)
+ {
+ var rows = Rows(readFile, FileName, "units");
+ var hexes = Hexes(readFile, rows);
+ var start = c.Rules.Start.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
+ var ppu = c.RulesAt(c.Rules.Start).Mvp!.PeoplePerUnit; // the start day's rules, as Cities.Init reads them
+ var list = new List<StartingForce>();
+ for (int i = 0; i < rows.Count; i++)
+ {
+ var row = rows[i] ?? throw new ContentException(FileName, $"units[{i}]", "empty row");
+ var id = Text(row, "id");
+ if (id == "") throw new ContentException(FileName, $"units[{i}].id", "required");
+ var at = $"units[{id}]";
+ if (row.ContainsKey("hidden") || Text(row, "service") != "army") continue;
+ if (!(row.TryGetValue("strength", out var so) && so is Dictionary<object, object> strength) || Text(strength, "as_of") != start) continue;
+ if (!(row.TryGetValue("anchors", out var ao) && ao is List<object> anchors)) continue;
+ int k = anchors.FindIndex(a => a is Dictionary<object, object> m
+ && string.CompareOrdinal(Text(m, "from"), start) <= 0 && string.CompareOrdinal(start, Text(m, "to")) < 0);
+ if (k < 0) continue;
+ var anchor = (Dictionary<object, object>)anchors[k];
+ var side = Text(row, "side");
+ var people = Number(strength, "value", $"{at}.strength.value");
+ if (people < 0 || people != decimal.Truncate(people)) throw new ContentException(FileName, $"{at}.strength.value", "must be a whole number >= 0");
+ var units = Cities.StartUnits(people, ppu); // the nearest unit, a half up, at least 1 for a force with people
+ if (units == 0) continue; // a strength of nobody starts nothing
+ if (!hexes.TryGetValue((id, k), out var qr))
+ throw new ContentException(HexesFileName, "anchors", $"no hex for {at}.anchors[{k}] ({FileName}); rerun tools/unit_anchor_hexes.py");
+ var (q, r) = qr;
+ var hex = c.HexAt(q, r);
+ if (hex == null) throw new ContentException(FileName, $"{at}.anchors[{k}]", FormattableString.Invariant($"hex q={q} r={r} is not on the map ({ContentLoader.HexesFile})"));
+ if (!hex.Land) throw new ContentException(FileName, $"{at}.anchors[{k}]", FormattableString.Invariant($"hex q={q} r={r} is not a land hex in {ContentLoader.HexesFile}"));
+ list.Add(new StartingForce
+ {
+ Row = id, Anchor = Text(anchor, "place"), Type = TypeFor(c, side, at), Side = side,
+ Strength = units, Q = q, R = r, Status = Text(row, "status"),
+ });
+ }
+ return list;
+ }
+
+ /// <summary>Adds the starting forces to a new game, in the content's order, taking the next ids: the unit with id i
+ /// of a new game is <c>c.StartingForces[i]</c>.</summary>
+ public static void Init(Content c, GameState s)
+ {
+ foreach (var f in c.StartingForces)
+ {
+ var id = s.NextId++;
+ s.Units.Add(id, new Unit(id, f.Type, f.Q, f.R, side: f.Side, strength: f.Strength));
+ }
+ }
+
+ /// <summary>A starting row's unit type: Israel's brigade type, or the one military type of the row's side (one
+ /// labelled design-value infantry type per Arab side with a row; #743, owner, 20 October 2026).</summary>
+ static string TypeFor(Content c, string side, string at)
+ {
+ var types = side == "israel"
+ ? c.UnitTypes.Where(t => t.Id == IsraeliBrigadeType && t.Side == side).ToList()
+ : c.UnitTypes.Where(t => t.Side == side && side != "").ToList();
+ if (types.Count != 1)
+ throw new ContentException(FileName, at + ".side", types.Count == 0
+ ? $"no military type of side '{side}' in unit_types.yaml" + (side == "israel" ? $" (the brigades start as {IsraeliBrigadeType})" : "")
+ : $"side '{side}' has several military types in unit_types.yaml ({string.Join(", ", types.Select(t => t.Id))}); a starting row needs one");
+ return types[0].Id;
+ }
+
+ /// <summary>A file's list under <paramref name="key"/>, read untyped (only the keys the start needs are read).</summary>
+ static List<Dictionary<object, object>> Rows(Func<string, string?> readFile, string fileName, string key)
+ {
+ string? text;
+ try { text = readFile(fileName); }
+ catch (System.IO.IOException e) { throw new ContentException(fileName, "(file)", e.Message); }
+ catch (UnauthorizedAccessException e) { throw new ContentException(fileName, "(file)", e.Message); }
+ if (text == null) throw new ContentException(fileName, "(file)", "missing file");
+ Dictionary<string, List<Dictionary<object, object>>>? file;
+ try { file = new DeserializerBuilder().Build().Deserialize<Dictionary<string, List<Dictionary<object, object>>>>(text); }
+ catch (YamlException e) { throw new ContentException(fileName, $"line {e.Start.Line}", e.InnerException?.Message ?? e.Message); }
+ if (file == null || !file.TryGetValue(key, out var rows) || rows == null) throw new ContentException(fileName, key, "required");
+ return rows;
+ }
+
+ /// <summary>unit_anchor_hexes.yaml by (row id, anchor index). Every row must name an anchor of <paramref name="units"/>,
+ /// once: a row that does not means the file is stale (the tool was not rerun after units_1948.yaml changed).</summary>
+ static Dictionary<(string id, int anchor), (int q, int r)> Hexes(Func<string, string?> readFile, List<Dictionary<object, object>> units)
+ {
+ var anchors = new Dictionary<string, int>(StringComparer.Ordinal);
+ foreach (var u in units)
+ if (u != null) anchors[Text(u, "id")] = u.TryGetValue("anchors", out var ao) && ao is List<object> list ? list.Count : 0;
+ var hexes = new Dictionary<(string, int), (int, int)>();
+ var rows = Rows(readFile, HexesFileName, "anchors");
+ for (int i = 0; i < rows.Count; i++)
+ {
+ var row = rows[i] ?? throw new ContentException(HexesFileName, $"anchors[{i}]", "empty row");
+ var id = Text(row, "id");
+ var at = id == "" ? $"anchors[{i}]" : $"anchors[{id}]";
+ int k = Int(row, "anchor", at), q = Int(row, "q", at), r = Int(row, "r", at);
+ if (!anchors.TryGetValue(id, out var n) || k < 0 || k >= n)
+ throw new ContentException(HexesFileName, at, FormattableString.Invariant($"no anchor {k} of a row '{id}' in {FileName}; rerun tools/unit_anchor_hexes.py"));
+ if (!hexes.TryAdd((id, k), (q, r)))
+ throw new ContentException(HexesFileName, at, FormattableString.Invariant($"anchor {k} is listed twice"));
+ }
+ return hexes;
+ }
+
+ static int Int(Dictionary<object, object> m, string key, string at) =>
+ int.TryParse(Text(m, key), NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var n)
+ ? n : throw new ContentException(HexesFileName, $"{at}.{key}", "required, a whole number");
+
+ static string Text(Dictionary<object, object> m, string key) => m.TryGetValue(key, out var v) && v is string s ? s : "";
+
+ static decimal Number(Dictionary<object, object> m, string key, string field) =>
+ decimal.TryParse(Text(m, key), NumberStyles.Float, CultureInfo.InvariantCulture, out var d)
+ ? d : throw new ContentException(FileName, field, "required, a number");
+ }
+}
diff --git a/tools/README.md b/tools/README.md
index ad719e4c3..ce066c519 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -20,6 +20,8 @@ Offline data tools (uv inline-script Python). Run from the repo root.
- `hexgrid.py` writes `content/map/hexes.json` from the heightmap and those committed precipitation inputs (no network).
- `settlement_hexes.py` writes `content/map/settlement_hexes.yaml` (committed): the hex that owns each settlement, by the
`hexgrid.settlement_hex` rule. The sim reads it, so it needs no projection maths.
+- `unit_anchor_hexes.py` writes `content/map/unit_anchor_hexes.yaml` (committed): the hex holding each anchor of
+ `units_1948.yaml`, for the sim's starting forces (R-UNIT-006). Rerun it after changing an anchor.
- `routes_1948.py [--fetch] [--only ID ...] [--preview DIR]` traces the railways and main roads of May 1948 (issue #35)
on the Survey of Palestine 1:250,000 map of 1946 (public domain; Palestine Open Maps' tiles, downloaded with `--fetch`
into `tools/.cache/pal250k-1946/`, not committed): it reads the hand-written routes, sources and waypoints in
diff --git a/tools/tests/test_package_release.py b/tools/tests/test_package_release.py
index 38fee345c..66bcbb8fc 100644
--- a/tools/tests/test_package_release.py
+++ b/tools/tests/test_package_release.py
@@ -20,8 +20,10 @@ def photo_manifest(build, reviewed=True, shareable=True):
(build / package_release.PHOTO_MANIFEST).write_text(json.dumps({"version": 1, "shareable": shareable, "photos": photos}))
-def fake_build(tmp_path, reviewed, photos_reviewed=True):
- """A build folder with index.html, the real content copied into StreamingAssets/content and the photo manifest."""
+def fake_build(tmp_path, reviewed, photos_reviewed=True, forces_checked=True):
+ """A build folder with index.html, the real content copied into StreamingAssets/content and the photo manifest.
+ forces_checked: the starting forces' rows in units_1948.yaml are fact-checked, as a person's check would leave them
+ (R-UNIT-006, Q-START-3); the real rows are draft or to_verify."""
build = tmp_path / "Web-brotli"
(build / "StreamingAssets").mkdir(parents=True)
(build / "index.html").write_text("<html></html>")
@@ -31,6 +33,9 @@ def fake_build(tmp_path, reviewed, photos_reviewed=True):
for e in SENSITIVE:
f = content / "events" / f"{e}.yaml"
f.write_text(re.sub(r"(?m)^status: .*$", f"status: {status}", f.read_text()))
+ if forces_checked:
+ units = content / "map" / "units_1948.yaml"
+ units.write_text(re.sub(r"(?m)^ status: .*$", " status: fact-checked", units.read_text(encoding="utf-8")), encoding="utf-8")
photo_manifest(build, reviewed=photos_reviewed)
return build
@@ -45,6 +50,17 @@ def test_packaging_is_refused_until_every_sensitive_event_is_reviewed(tmp_path,
assert e in out
+def test_packaging_is_refused_until_every_starting_row_is_fact_checked(tmp_path, capsys):
+ # R-UNIT-006, Q-START-3 (#743): the rows the sim starts a unit from are game state, so they are checked first.
+ build, zip_path = fake_build(tmp_path, reviewed=True, forces_checked=False), tmp_path / "out.zip"
+ assert package_release.main(["--build", str(build), "--zip", str(zip_path)]) == 1
+ assert not zip_path.exists()
+ out = capsys.readouterr().out
+ assert "PACKAGE REFUSED" in out
+ for row in ("golani", "egyptian_expeditionary_force", "arab_liberation_army"):
+ assert row in out
+
+
def test_packaging_writes_the_zip_once_all_are_reviewed(tmp_path, capsys):
build, zip_path = fake_build(tmp_path, reviewed=True), tmp_path / "out.zip"
assert package_release.main(["--build", str(build), "--zip", str(zip_path)]) == 0
diff --git a/tools/tests/test_unit_anchor_hexes.py b/tools/tests/test_unit_anchor_hexes.py
new file mode 100644
index 000000000..cd11aca10
--- /dev/null
+++ b/tools/tests/test_unit_anchor_hexes.py
@@ -0,0 +1,23 @@
+"""content/map/unit_anchor_hexes.yaml is the committed output of tools/unit_anchor_hexes.py and must stay in sync: the sim
+places the starting forces (R-UNIT-006) on these hexes instead of projecting lon/lat itself (docs/determinism.md)."""
+import json
+from pathlib import Path
+
+import yaml12
+
+import unit_anchor_hexes as uah
+
+ROOT = Path(__file__).resolve().parents[2]
+MAP = ROOT / "content" / "map"
+HEXES = json.loads((MAP / "hexes.json").read_text())
+UNITS = yaml12.load((MAP / "units_1948.yaml").read_text(encoding="utf-8"))["units"]
+
+
+def test_committed_file_is_up_to_date():
+ assert (MAP / "unit_anchor_hexes.yaml").read_text() == uah.render(HEXES, UNITS), "rerun: uv run tools/unit_anchor_hexes.py"
+
+
+def test_two_known_anchors_are_pinned_literally():
+ rows = {(r["id"], r["anchor"]): (r["q"], r["r"]) for r in yaml12.load((MAP / "unit_anchor_hexes.yaml").read_text())["anchors"]}
+ assert rows[("carmeli", 0)] == (5, 8) # Haifa (#743, owner, 20 October 2026)
+ assert rows[("kiryati", 0)] == (-3, 19) # Tel Aviv, the hex settlement_hexes.yaml gives tel_aviv
diff --git a/tools/unit_anchor_hexes.py b/tools/unit_anchor_hexes.py
new file mode 100644
index 000000000..437cca747
--- /dev/null
+++ b/tools/unit_anchor_hexes.py
@@ -0,0 +1,48 @@
+# /// script
+# requires-python = ">=3.11"
+# dependencies = ["numpy==2.5.3", "pyyaml==6.0.3"]
+# ///
+"""Unit anchor -> hex for the simulation's starting forces (R-UNIT-006).
+
+Usage: uv run tools/unit_anchor_hexes.py (reads content/map/hexes.json and content/map/units_1948.yaml,
+writes content/map/unit_anchor_hexes.yaml)
+Each anchor's hex is the one holding its coordinates, by the map's projection and cube rounding (hexgrid.lonlat_to_km,
+hexgrid.point_to_hex; Unity's HexPicker does the same). The sim reads the result instead of re-implementing the
+projection, so it needs no trigonometry (docs/determinism.md: no libm calls in the sim), as for settlement_hexes.py."""
+import json
+import sys
+from pathlib import Path
+
+import numpy as np
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import hexgrid as hg # noqa: E402
+import yaml12 # noqa: E402
+
+ROOT = Path(__file__).resolve().parents[1]
+MAP = ROOT / "content" / "map"
+OUT = MAP / "unit_anchor_hexes.yaml"
+HEADER = ("# Generated by tools/unit_anchor_hexes.py from units_1948.yaml and hexes.json (hexgrid.lonlat_to_km, point_to_hex).\n"
+ "# Do not edit by hand: rerun the tool after changing either input. anchor is the index in the row's anchors list.\n")
+
+
+def render(hexes: dict, units: list[dict]) -> str:
+ """The file text: one flow mapping per anchor, in units_1948.yaml order."""
+ lines = [HEADER, "anchors:\n"]
+ for u in units:
+ for k, a in enumerate(u.get("anchors") or []):
+ x, y = hg.lonlat_to_km(a["lon"], a["lat"], hexes["bounds"])
+ (q,), (r,) = hg.point_to_hex(np.array([x]), np.array([y]), hexes["hex_size_km"])
+ lines.append(f" - {{ id: {u['id']}, anchor: {k}, q: {q}, r: {r} }}\n")
+ return "".join(lines)
+
+
+def main() -> None:
+ hexes = json.loads((MAP / "hexes.json").read_text())
+ units = yaml12.load((MAP / "units_1948.yaml").read_text(encoding="utf-8"))["units"]
+ OUT.write_text(render(hexes, units))
+ print(f"wrote {OUT.relative_to(ROOT)} ({len(units)} units)")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tools/web_check.py b/tools/web_check.py
index 89be59aa3..56679babc 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 hash1950 e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a" --expect "GOLDEN OK hash1952 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde"
+ uv run tools/web_check.py unity/Builds/Web-disabled --query "golden" --expect "GOLDEN OK hash1950 259133fc83a95471547be0cb1a317bae55c8324778864733b88957d7529c8585" --expect "GOLDEN OK hash1952 452c65ece470e844f6898151c4d9328aa0b2e59df82db4763214d43a8e8ea7f1"
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
diff --git a/unity/Assets/Editor/Build.cs b/unity/Assets/Editor/Build.cs
index a1de04659..a7950ffe1 100644
--- a/unity/Assets/Editor/Build.cs
+++ b/unity/Assets/Editor/Build.cs
@@ -55,7 +55,8 @@ namespace Statecraft.Game.EditorTools
};
/// <summary>Why a shareable build may not be made, or null: every event with a sensitive tag needs the owner's
- /// sensitivity review first (status sensitivity-reviewed; docs/m3-release.md, M3 final review I4), and so does every
+ /// sensitivity review first (status sensitivity-reviewed; docs/m3-release.md, M3 final review I4), every row the
+ /// starting forces come from must be fact-checked (ReleaseGate.StartingForcesUnchecked; R-UNIT-006), and so does every
/// sensitive event photograph the build would carry (EventImageCatalog; docs/event-images.md), and every sensitive
/// illustration clip (<paramref name="clips"/>, event-videos.yaml; docs/event-videos.md). See
/// <see cref="EventImageRefusal"/> for <paramref name="catalogFileExists"/> and <paramref name="mapping"/>.</summary>
@@ -66,6 +67,10 @@ namespace Statecraft.Game.EditorTools
var reasons = new List<string>();
if (open.Count > 0)
reasons.Add("a shareable build needs the owner's sensitivity review of: " + string.Join(", ", open) + " (set status: sensitivity-reviewed; see docs/m3-release.md)");
+ // R-UNIT-006, Q-START-3 (#743): the rows a new game starts a unit from are game state, so a person checks them first.
+ if (Statecraft.Sim.ReleaseGate.StartingForcesUnchecked(c) is { Count: > 0 } forces)
+ reasons.Add("a shareable build needs these starting forces' rows fact-checked: " + string.Join(", ", forces)
+ + " (status: fact-checked in content/map/units_1948.yaml; see docs/units.md)");
if (EventImageRefusal(photos, catalogFileExists, mapping) is string pictures) reasons.Add(pictures);
if (clips != null && EventVideoMapping.SensitiveUnreviewed(clips) is { Count: > 0 } openClips)
reasons.Add("a shareable build needs the owner's sensitivity review of the illustration clips: " + string.Join(", ", openClips)
diff --git a/unity/Assets/Tests/EditMode/BuildGateTests.cs b/unity/Assets/Tests/EditMode/BuildGateTests.cs
index 29a7c7e6c..515e07b0f 100644
--- a/unity/Assets/Tests/EditMode/BuildGateTests.cs
+++ b/unity/Assets/Tests/EditMode/BuildGateTests.cs
@@ -17,10 +17,30 @@ public class BuildGateTests
return (string?)t!.GetMethod("ShareableRefusal", BindingFlags.Public | BindingFlags.Static)!.Invoke(null, new object?[] { c, null, false, null, null }); // event content only
}
+ /// <summary>The real content with its starting forces' rows fact-checked, as a person's check would leave them
+ /// (R-UNIT-006, Q-START-3), for the tests about the other gates.</summary>
+ internal static Content Checked()
+ {
+ var c = ContentLoader.Load(Paths.Content);
+ foreach (var f in c.StartingForces) f.Status = "fact-checked";
+ return c;
+ }
+
+ /// <summary>R-UNIT-006, Q-START-3 (#743): a starting force's row that is not fact-checked blocks a shareable build, by name.</summary>
[Test]
- public void AShareableBuildWaitsForTheSensitivityReview()
+ public void AShareableBuildWaitsForTheStartingForcesRows()
{
var c = ContentLoader.Load(Paths.Content);
+ var refusal = Refusal(c);
+ Assert.IsNotNull(refusal, "every real row is draft or to_verify");
+ foreach (var f in c.StartingForces) StringAssert.Contains(f.Row, refusal);
+ Assert.IsNull(Refusal(Checked()));
+ }
+
+ [Test]
+ public void AShareableBuildWaitsForTheSensitivityReview()
+ {
+ var c = Checked();
Assert.IsNull(Refusal(c), "the owner signed off all seven on 2026-10-10 (D11)");
foreach (var e in c.Events) if (ReleaseGate.SensitiveEvents(c).Contains(e.Id)) e.Status = "fact-checked"; // as before the sign-off
var refusal = Refusal(c);
@@ -37,7 +57,7 @@ public class BuildGateTests
{
var t = Type.GetType("Statecraft.Game.EditorTools.Build, Assembly-CSharp-Editor")!;
var gate = t.GetMethod("GateRefusal", BindingFlags.Public | BindingFlags.Static)!;
- var c = ContentLoader.Load(Paths.Content);
+ var c = Checked();
Assert.IsNull(gate.Invoke(null, new object?[] { new[] { "Unity", "-executeMethod", "Statecraft.Game.EditorTools.Build.Mac" }, c, null, false, null, null }), "a dev build is not gated");
Assert.IsNull(gate.Invoke(null, new object?[] { new[] { "Unity", "-shareable" }, c, null, false, null, null }), "all seven are sensitivity-reviewed (D11)");
foreach (var e in c.Events) if (e.Id == "reparations_claim") e.Status = "fact-checked";
@@ -98,7 +118,7 @@ public class BuildGateTests
{
var t = Type.GetType("Statecraft.Game.EditorTools.Build, Assembly-CSharp-Editor")!;
var gate = t.GetMethod("GateRefusal", BindingFlags.Public | BindingFlags.Static)!;
- var c = ContentLoader.Load(Paths.Content);
+ var c = Checked();
var photos = ShippedPhotos();
try
{
@@ -141,7 +161,7 @@ public class BuildGateTests
[Test]
public void TheGateFailsClosedWhenTheCatalogDoesNotLoad()
{
- var c = ContentLoader.Load(Paths.Content);
+ var c = Checked();
var refusal = (string?)Gate.Invoke(null, new object?[] { Shareable, c, null, true, null, null });
Assert.IsNotNull(refusal, "an existing catalog that did not load is a refusal");
StringAssert.Contains("did not load", refusal);
@@ -155,7 +175,7 @@ public class BuildGateTests
[Test]
public void TheGateRefusesACatalogThatDoesNotMatchTheMapping()
{
- var c = ContentLoader.Load(Paths.Content);
+ var c = Checked();
var photos = ShippedPhotos();
try
{
diff --git a/unity/Assets/Tests/EditMode/EventVideoTests.cs b/unity/Assets/Tests/EditMode/EventVideoTests.cs
index e9f730cf2..11603aff3 100644
--- a/unity/Assets/Tests/EditMode/EventVideoTests.cs
+++ b/unity/Assets/Tests/EditMode/EventVideoTests.cs
@@ -21,7 +21,7 @@ using UnityEngine.UIElements;
/// the owner's review before a shareable build.</summary>
public class EventVideoTests
{
- static readonly Content C = ContentLoader.Load(Paths.Content);
+ static readonly Content C = BuildGateTests.Checked(); // the starting forces' rows fact-checked: these tests are about the clips (R-UNIT-006)
static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
static EventImageCatalog Photos => AssetDatabase.LoadAssetAtPath<EventImageCatalog>("Assets/Resources/EventImageCatalog.asset");
static IReadOnlyList<EventVideoMapping.Row> Rows => EventVideoMapping.Parse(File.ReadAllText(EventVideoMapping.Path));
diff --git a/unity/Assets/Tests/EditMode/OutcomeClipTests.cs b/unity/Assets/Tests/EditMode/OutcomeClipTests.cs
index ce907d6f8..3d918e854 100644
--- a/unity/Assets/Tests/EditMode/OutcomeClipTests.cs
+++ b/unity/Assets/Tests/EditMode/OutcomeClipTests.cs
@@ -22,7 +22,7 @@ using Object = UnityEngine.Object;
/// skips one; the focus then goes back. A sensitive one waits for the owner's review before a shareable build.</summary>
public class OutcomeClipTests
{
- static readonly Content C = ContentLoader.Load(Paths.Content);
+ static readonly Content C = BuildGateTests.Checked(); // the starting forces' rows fact-checked: these tests are about the clips (R-UNIT-006)
static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
static string Yaml => File.ReadAllText(EventVideoMapping.Path);
diff --git a/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs b/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs
index 65e54431c..28c9c4427 100644
--- a/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs
+++ b/unity/Assets/Tests/EditMode/SimBridgeSiteTests.cs
@@ -78,8 +78,9 @@ public class SimBridgeSiteTests
{
var t = Text;
var b = Bridge(Legacy);
- Assert.AreEqual(t.Format("order.unknown", "unit"), b.Queue(new PioneerWork(1, Projects.BuildYishuv, "mefalsim")));
- Assert.AreEqual(t.Format("order.unknown", "unit"), b.Queue(new StopWork(1)));
+ var none = b.State.NextId; // no unit has it: the starting forces take ids 0 to 11 (R-UNIT-006)
+ Assert.AreEqual(t.Format("order.unknown", "unit"), b.Queue(new PioneerWork(none, Projects.BuildYishuv, "mefalsim")));
+ Assert.AreEqual(t.Format("order.unknown", "unit"), b.Queue(new StopWork(none)));
Assert.AreEqual(0, b.Queued.Count);
}
}
diff --git a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
index 122fe9c60..889d8103b 100644
--- a/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitsInPlayTests.cs
@@ -42,24 +42,44 @@ public class UnitsInPlayTests
// ---- The data -----------------------------------------------------------------------------------------------
- /// <summary>Map-only: the sim's content hash is the same with and without the unit file (so it cannot move the
- /// goldens), and the WebGL manifest ships it (the player reads it).</summary>
+ /// <summary>The sim reads the unit file for the starting forces (R-UNIT-006; Q-START-1), so it is in the content hash and
+ /// the goldens follow it; the WebGL manifest ships it (the player reads it).</summary>
[Test]
- public void TheUnitFileDoesNotMoveTheContentHash()
+ public void TheUnitFileEntersTheContentHash()
{
- var copy = Path.Combine(Path.GetTempPath(), "statecraft-nounits-" + Guid.NewGuid().ToString("N"));
+ var copy = Path.Combine(Path.GetTempPath(), "statecraft-units-" + Guid.NewGuid().ToString("N"));
try
{
Statecraft.Game.Boot.ContentManifest.Copy(Paths.Content, copy);
var file = Path.Combine(copy, "map", UnitData.DefaultFileName);
Assert.IsTrue(File.Exists(file), "the manifest copies the unit file");
- File.Delete(file);
- Assert.AreEqual(ContentLoader.Load(Paths.Content).Hash, ContentLoader.Load(copy).Hash);
+ File.AppendAllText(file, "# a comment changes the file\n");
+ Assert.AreNotEqual(ContentLoader.Load(Paths.Content).Hash, ContentLoader.Load(copy).Hash);
CollectionAssert.Contains(Statecraft.Game.Boot.ContentManifest.Collect(Paths.Content), "map/" + UnitData.DefaultFileName);
}
finally { if (Directory.Exists(copy)) Directory.Delete(copy, true); }
}
+ /// <summary>R-UNIT-006: the sim's starting hexes are the hexes the map computes for the same rows' anchors (HexPicker,
+ /// the map's own lon/lat to hex). The token may still stand one hex away (UnitPlacer); the sim's hex is the anchor's.</summary>
+ [Test]
+ public void TheStartMatchesTheMap()
+ {
+ var hexes = MapBuilder.LoadHexes(Path.Combine(Paths.Content, "map", "hexes.json"));
+ var start = C.Rules.Start.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
+ Assert.AreEqual(12, C.StartingForces.Count, "the twelve sourced forces of 15 May 1948 (#743)");
+ foreach (var f in C.StartingForces)
+ {
+ var row = Units.Single(u => u.Id == f.Row);
+ Assert.IsNull(row.Hidden, f.Row);
+ Assert.AreEqual(UnitData.Army, row.Service, f.Row);
+ Assert.AreEqual(f.Side, row.Side, f.Row);
+ var anchor = row.Anchors.First(a => string.CompareOrdinal(a.From, start) <= 0 && string.CompareOrdinal(start, a.To) < 0);
+ Assert.AreEqual(anchor.Place, f.Anchor, f.Row);
+ Assert.AreEqual(HexPicker.FromLonLat(anchor.Lon, anchor.Lat, hexes.bounds, hexes.hex_size_km), (f.Q, f.R), f.Row);
+ }
+ }
+
/// <summary>Review C1: every window ends for a reason. A source-based end cites its source and says which; any other
/// end is the armistice of the anchor's front (the owner's "after the armistices, only what a source says continued").
/// No window runs past its unit's sourced disbandment.</summary>