A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Loader: refuse a starting strength of 0 (Fixes #2815) (#2904)
Berid6d521f8f563
diff --git a/changelog.d/2815-zero-strength-force.md b/changelog.d/2815-zero-strength-force.mdnew file mode 100644index 000000000..a7af41ef8--- /dev/null+++ b/changelog.d/2815-zero-strength-force.md@@ -0,0 +1,5 @@+### Fixed++- A starting force whose `map/units_1948.yaml` strength is 0 is now refused when the game loads, with "must be a whole+ number >= 1", instead of being skipped without a word. R-UNIT-006 says a force is never below 1. No row in the real+ file has 0 people, so nothing changes for players and no golden moves.diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex ab792c5a1..e7cd40cac 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -270,7 +270,7 @@ R-UNIT-004: Each Israeli recruit formation already in play before step 4 gains oR-UNIT-005: `UnitOrder(unit, send_home)` (the unit card's "Send home", #1309) is the player's order and the only way home: no automatic demobilisation happens (owner, 22 October 2026, #1309: https://github.com/eyalgolan/statecraft-israel/issues/1309#issuecomment-6334162964). It is refused, the state unchanged, with the orders' own reasons for an unknown unit, a unit with no side or an enemy unit (R-ORDER-001's wording) and "That order names no hex" when a hex is given, and with "The armistice with <front> is not signed" while the armistice on the unit's front is unsigned. A unit's front is the front of the enemy side it attacked this turn or borders; ties take the nearest enemy unit, then the lowest unit id (owner, 22 October 2026, #1309: https://github.com/eyalgolan/statecraft-israel/issues/1309#issuecomment-6340226644). A side that belongs to no front (the ALA and the local forces, Q-OBJ-1; R-POW-004's map) names none (accepted per maintainer comment, 22 October 2026, #1309: https://github.com/eyalgolan/statecraft-israel/issues/1309#issuecomment-6341877062: the ALA and the local forces belong to no front, having no armistice of their own), and a unit attacking and bordering no front-bearing enemy may be sent home once any armistice is signed, refused with "No armistice is signed" until then (accepted per maintainer comment 6341877062 on #1309: "no enemy units in play" means attacking and bordering no enemy that has a front). Taken, the order waits for End turn and can be withdrawn until then, as Send home is not an instant order (R-TURN-004); when it runs, it acts at once: the unit leaves the map and its strength, in population units, joins the nearest of the twelve cities as civilians without a job (owner, 22 October 2026, #1309: https://github.com/eyalgolan/statecraft-israel/issues/1309#issuecomment-6334162964: "nearest ... as unemployed civilians"), counting in the city's jobs and housing from the same turn; nearest by hex distance to the city's settlement hex, ties by the city's id (agent default - the ruling sets no tie break). The Why line states the count in people (Q-CIV-4): "Unit N is sent home: its P people are civilians in <city> now". A veteran keeps nothing (none suggested, #1309).-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,095 is 4, Kiryati's 2,504 is 3). 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-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,095 is 4, Kiryati's 2,504 is 3). 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 `strength.value` is not a whole number of at least 1 (#2815, option 1, the issue's Recommended option, confirmed on the issue on 6 November 2026), 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.diff --git a/sim/Statecraft.Sim.Tests/StartingForcesTests.cs b/sim/Statecraft.Sim.Tests/StartingForcesTests.csindex 801242f24..caa700f6e 100644--- a/sim/Statecraft.Sim.Tests/StartingForcesTests.cs+++ b/sim/Statecraft.Sim.Tests/StartingForcesTests.cs@@ -78,10 +78,20 @@ public class StartingForcesTestsAssert.DoesNotContain("yiftach", 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"));+ Row("unsized", "israel", null), Row("later", "israel", 20, from: "1948-06-01"));Assert.Equal(new[] { "seen" }, c.StartingForces.Select(f => f.Row));}+ // R-UNIT-006 (#2815, option 1, the issue's Recommended option, confirmed on the issue on 6 November 2026): a strength of nobody is a load error, since a force is never below 1.+ [Fact]+ public void AStrengthOfZeroIsALoadError()+ {+ var ex = Assert.Throws<ContentException>(() => Load(Row("nobody", "israel", 0)));+ Assert.Equal("map/units_1948.yaml", ex.File);+ Assert.Equal("units[nobody].strength.value", ex.Field);+ Assert.Contains("must be a whole number >= 1", ex.Message);+ }+// R-UNIT-006, Q-UNIT-5 (owner, 15 October 2026): the squadron and the two ships stay presentation-only tokens.[Fact]public void AirAndNavyFollowTheAnswer()diff --git a/sim/Statecraft.Sim/StartingForces.cs b/sim/Statecraft.Sim/StartingForces.csindex 9915ae173..9f07252eb 100644--- a/sim/Statecraft.Sim/StartingForces.cs+++ b/sim/Statecraft.Sim/StartingForces.cs@@ -92,9 +92,8 @@ namespace Statecraft.Simvar 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 (people < 1 || people != decimal.Truncate(people)) throw new ContentException(FileName, $"{at}.strength.value", "must be a whole number >= 1");+ var units = Cities.StartUnits(people, ppu); // the nearest unit, a half up, at least 1 (people is >= 1 here)if (asOf > c.Rules.Start && side != Movement.PlayerSide)throw new ContentException(FileName, $"{at}.strength.as_of", "an enemy-side force may not arrive after the game starts (R-ENEMY-004)");if (!hexes.TryGetValue((id, k), out var qr))