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.

Docs and policy tests: determinism.md's Math list and deport fixture; RELEASING wraps Unity in the machine lock (Fixes #2659) (#2660)

Eyal Golan7973e1804e0d
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index f5ee2d37c..cbce6af95 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -25,7 +25,7 @@ macOS IL2CPP parity check is not an MVP release gate.
tag after a squash merge. Before building, check that the disk has several GB free for `unity/Library/Bee`.
```bash
- "$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"
+ uv run tools/machine_lock.py --shared --wait-unity -- "$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 a08ff8504d862925563c8523a707b58ebe3bcaac0b504dc9ce7e028fc19eb0e4"
@@ -63,7 +63,7 @@ macOS IL2CPP parity check is not an MVP release gate.
and only a `-shareable` build may be published. Check it and package it the same way:
```bash
- "$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"
+ uv run tools/machine_lock.py --shared --wait-unity -- "$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 d12c83ce94e3940f93ed21abe7c2c9957de099b2653961da90e87785e6405e79"
@@ -362,7 +362,7 @@ first (`python3 tools/build_sim_for_unity.py`), run Unity with graphics (not `-n
`xvfb-run -a`), then encode the frames with ffmpeg:
```sh
-"$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity \
+uv run tools/machine_lock.py --shared --wait-unity -- "$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity \
-executeMethod MapCapture.Trailer -captureDir "$PWD/captures/<name>" -seed 1948 -logFile "$PWD/unity-trailer.log"
ffmpeg -framerate 60 -i captures/<name>/frame-%05d.png -vf scale=out_color_matrix=bt709 \
-c:v libx264 -preset slow -crf 16 -pix_fmt yuv420p -colorspace bt709 -color_primaries bt709 -color_trc bt709 \
diff --git a/docs/determinism.md b/docs/determinism.md
index c9630874f..73ca83858 100644
--- a/docs/determinism.md
+++ b/docs/determinism.md
@@ -9,8 +9,10 @@ The simulation must produce the same state, bit for bit, on .NET, Unity Mono and
- **Reference vectors:** `DeterminismTests.SplitMix64MatchesTheReferenceVectors` checks the first three outputs for
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, which hex a starting force's anchor is on) is precomputed by
+- **No trigonometry in the sim:** paths that change state call only `Math.Abs`, `Math.Floor`, `Math.Max`, `Math.Min`
+ and `Math.Round`, and every such `Math.Round` passes `MidpointRounding.AwayFromZero`. `PlayerText` also rounds, for
+ display only, and `MapOverrides` uses `Math.Sqrt(3)` only to diagnose editor offsets; neither changes state. Geometry
+ that needs 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
@@ -38,7 +40,7 @@ The simulation must produce the same state, bit for bit, on .NET, Unity Mono and
per place in `DisplacedByPlayer`) and the International Support ceiling are plain arithmetic on the indicator's shift,
with no RNG draw (R-CTRL-018; `DeportTests.DeportDrawsNothing`). `DisplacedByPlayer` is hashed as `displaced=` only when
non-zero. The real content keeps Deport out of play (`mvp.deport_in_play: false`), and no golden Deports, so
- none moves. The `mvp-deport-cost` golden, paired with `mvp-occupy-cost`, cannot play the real content, where Deport
+ none moves. The `mvp-deport-cost` fixture comparison (not a manifest golden), paired with `mvp-occupy-cost`, cannot play the real content, where Deport
is refused (#800);
`DeportNeverDominatesTests` plays both runs from the same fixture states.
diff --git a/scripts/oss/tests/test_policies.py b/scripts/oss/tests/test_policies.py
index 376b09e27..351873546 100644
--- a/scripts/oss/tests/test_policies.py
+++ b/scripts/oss/tests/test_policies.py
@@ -316,3 +316,23 @@ def test_new_strings_are_pointed_at_the_binding_ui_guides():
assert "binding for new strings from 22 October 2026 (#622)" in header, rel
glossary = read("docs/UX_GLOSSARY.yaml")
assert "DRAFT" not in glossary.split("conventions:")[0], "UX_GLOSSARY.yaml header"
+
+
+def test_determinism_doc_names_every_math_function_the_sim_calls():
+ """#2659: docs/determinism.md lists the Math functions the sim uses; a new one must be named (and argued) there."""
+ import re
+ used = set()
+ for f in (ROOT / "sim" / "Statecraft.Sim").rglob("*.cs"):
+ used |= set(re.findall(r"\bMath\.([A-Z][A-Za-z]*)\b", f.read_text(encoding="utf-8")))
+ doc = read("docs/determinism.md")
+ missing = sorted(m for m in used if f"`Math.{m}`" not in doc and f"Math.{m}(" not in doc)
+ assert not missing, f"docs/determinism.md does not name: {missing}"
+ assert "`mvp-deport-cost` golden" not in doc, "mvp-deport-cost is a fixture comparison, not a manifest golden"
+
+
+def test_releasing_runs_every_unity_batch_command_under_the_machine_lock():
+ """#2659: AGENTS.md and docs/dev-setup.md require the machine lock around Unity; the manual recipe follows it."""
+ lines = [line for line in read("docs/RELEASING.md").splitlines() if '"$UNITY" -batchmode' in line]
+ assert lines, "RELEASING.md has Unity batch commands to check"
+ for line in lines:
+ assert line.lstrip().startswith('uv run tools/machine_lock.py --shared --wait-unity -- "$UNITY" -batchmode'), line