A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Tests: gdd-0.3 pins for R-POW-002, R-POW-003 and R-POW-005 (Fixes #2600) (#2615)
Eyal Golanaee7e4aabf7a
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 58c79d81e..ce27f636f 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -398,7 +398,7 @@ R-POW-004: An event with `prisoners: <front>` (egypt, jordan, lebanon or syria)R-POW-005: A surrendered unit of the player's is added to `GameState.SoldiersHeld` under the side of the engagement's lowest-id attacker. In step 7, after the prisoners eat, the Treasury pays `mvp.held_soldier_cost_per_turn` (real value IL 0.005m) for each population unit held, borrowing what it lacks (R-MONEY-003; Q-POW-4). They come home when that side's front's exchange card resolves, with no score effect.-Under gdd-0.3 (#1710), the prisoners in R-POW-004's pins come from a real surrender (R-POW-001). R-POW-002, R-POW-003 and R-POW-005 have no gdd-0.3 pin yet. The real per-front exchange cards wait on #751, so every R-POW rule that needs them (R-POW-004's returns, R-POW-005's homecoming) stays as written until they land.+Under gdd-0.3 (#1710), the prisoners in these pins come from a real surrender (R-POW-001). `PrisonersGdd03Tests.PrisonersEatAndAFoodShortfallCostsCohesion` pins R-POW-002, `PrisonersGdd03Tests.PrisonersAreNeverAResource` pins R-POW-003, and `PrisonersGdd03Tests.OwnSoldiersAreCapturedCostMoneyAndComeHome` pins R-POW-005. The real per-front exchange cards wait on #751, so the return and homecoming pins use the synthetic card until those cards land.## Objectivesdiff --git a/sim/Statecraft.Sim.Tests/PrisonersGdd03Tests.cs b/sim/Statecraft.Sim.Tests/PrisonersGdd03Tests.csindex 16243189c..26655a5b7 100644--- a/sim/Statecraft.Sim.Tests/PrisonersGdd03Tests.cs+++ b/sim/Statecraft.Sim.Tests/PrisonersGdd03Tests.cs@@ -5,9 +5,10 @@ using System.Linq;using System.Text.RegularExpressions;using Statecraft.Sim;-/// <summary>Prisoner returns under gdd-0.3 (#1710): the return-only scoring main already has (R-POW-004), pinned under the-/// gdd-0.3 identity. The exchange card is synthetic, built here: the real per-front cards wait on #751. Every capture is a-/// real surrender from a player's attack order, so a save, which is a command log, replays it. The fixture starts four+/// <summary>Prisoners under gdd-0.3 (#1710): R-POW-002 to R-POW-005 pinned under the gdd-0.3 identity. The exchange card is+/// synthetic, built here: the real per-front cards wait on #751. Enemy-prisoner captures are real surrenders from a player's+/// attack order, so a save, which is a command log, replays them. The held-soldier pin reverses the corner engagement: the+/// Egyptian and Iraqi units attack an Israeli defender, whose surrender is resolved by the same combat path. The fixture starts four/// Israeli units of 6,000 people and two Egyptian units of 40, each Egyptian unit in a corner of the board with both its/// land neighbours held by Israeli units. One Israeli unit attacks (a gdd-0.3 attack commits one adjacent unit): far above/// 2:1, the defender loses one population unit and, with nowhere to retreat, surrenders with 3 (R-COMBAT-003). Neither@@ -15,7 +16,8 @@ using Statecraft.Sim;public class PrisonersGdd03Tests{const string Types = Fixture.GddUnitTypes- + " - { id: enemy, kind: unit, side: egypt, class: infantry, movement_points: 3 }\n";+ + " - { id: enemy, kind: unit, side: egypt, class: infantry, movement_points: 3 }\n"+ + " - { id: iraqi, kind: unit, side: iraq, class: infantry, movement_points: 3 }\n";/// <summary>The starting forces, by id: 0 and 1 hold the land around unit 2 in corner (0, 0), 3 and 4 the land around unit/// 5 in corner (5, 2). Units 0 and 3 attack.</summary>@@ -98,6 +100,94 @@ options:Assert.Equal(GameOverCodes.EraEnded, g.State.GameOver); // 1 January 1957, long after the card's window}+ // R-POW-002 under gdd-0.3: the three units taken by a real surrender need six Food at the fixture rate. With one Food,+ // they eat it, the five-unit shortfall costs cohesion, and none of the prisoners disappears.+ [Fact]+ public void PrisonersEatAndAFoodShortfallCostsCohesion()+ {+ var c = Load();+ var g = GameSession.New(c, 1, Mode.Historical);+ Assert.Empty(g.Step(Attack(0, 0, 0)).Rejected);+ Assert.Equal(new[] { ("egypt", 3) }, g.State.PrisonersHeld.Select(kv => (kv.Key, kv.Value)));++ g.State.Food = 1;+ var morale = g.State.Indicators["morale"];+ var why = new List<Cause>();+ Prisoners.Upkeep(c, g.State, c.RulesAt(g.State.Date).Mvp!, why);++ Assert.Equal(0, g.State.Food);+ Assert.Equal(morale - 5 * 0.05, g.State.Indicators["morale"], 12);+ Assert.Equal(new[] { ("egypt", 3) }, g.State.PrisonersHeld.Select(kv => (kv.Key, kv.Value)));+ Assert.Contains(why, x => x.Message == "The prisoners held ate 1 units of Food");+ Assert.Contains(why, x => x.Message.StartsWith(+ "The prisoners held went short of 5 units of Food: ", StringComparison.Ordinal));+ }++ // R-POW-003 under gdd-0.3: for every command kind, prisoners change no Money, Arms, city or unit. Their only resource+ // difference is their Food upkeep.+ [Fact]+ public void PrisonersAreNeverAResource()+ {+ var c = Load();+ var m = c.RulesAt(new DateTime(1948, 5, 15)).Mvp!;+ foreach (var cmd in CommandGuardTests.Samples.Values)+ {+ var without = Simulation.NewGame(c, 1, Mode.Historical);+ var with = without.Clone();+ with.PrisonersHeld["egypt"] = 3;++ var a = Simulation.Step(c, without, new[] { cmd }).State;+ var b = Simulation.Step(c, with, new[] { cmd }).State;++ Assert.Equal((a.Treasury, a.Debt, a.Arms), (b.Treasury, b.Debt, b.Arms));+ Assert.Equal(a.Food - 3 * m.FoodPerPrisonerUnit!.Value, b.Food);+ Assert.Equal(+ string.Join(";", a.Cities.Values.Select(x => x.Canonical(false))),+ string.Join(";", b.Cities.Values.Select(x => x.Canonical(false))));+ Assert.Equal(+ string.Join(";", a.Units.Values.Select(x => x.Canonical())),+ string.Join(";", b.Units.Values.Select(x => x.Canonical())));+ }+ }++ // R-POW-005 under gdd-0.3: a real surrender counts the player's soldiers under the lowest-id attacker's side; their+ // fixture-rate upkeep borrows a shortfall, and that front's exchange card sends them home without scoring.+ [Fact]+ public void OwnSoldiersAreCapturedCostMoneyAndComeHome()+ {+ var c = Load();+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.Units.Clear();+ s.Units.Add(0, new Unit(0, "enemy", 1, 0, side: "egypt", strength: 4,+ order: Combat.Attack, orderTarget: "0,0"));+ s.Units.Add(1, new Unit(1, "iraqi", 0, 1, side: "iraq", strength: 4,+ order: Combat.Attack, orderTarget: "0,0"));+ s.Units.Add(2, new Unit(2, "veteran_soldier", 0, 0, side: "israel", strength: 3));++ var why = new List<Cause>();+ Combat.Resolve(c, s, why);+ Assert.False(s.Units.ContainsKey(2));+ Assert.Empty(s.PrisonersHeld);+ Assert.Equal(new[] { ("egypt", 2) }, s.SoldiersHeld.Select(kv => (kv.Key, kv.Value)));++ s.Treasury = 0.4;+ var debt = s.Debt;+ Prisoners.Upkeep(c, s, c.RulesAt(s.Date).Mvp!, why);+ Assert.Equal(0.0, s.Treasury);+ Assert.Equal(debt + 0.6, s.Debt, 12);++ for (int i = 0; i < 20 && !s.PendingEvents.Contains("pow_egypt"); i++)+ s = Simulation.Step(c, s, Array.Empty<Command>()).State;+ Assert.Contains("pow_egypt", s.PendingEvents);+ var score = s.Score;++ var returned = Simulation.Step(c, s,+ new Command[] { new ChooseEventOption("pow_egypt", "continue") });+ Assert.Empty(returned.Rejected);+ Assert.Empty(returned.State.SoldiersHeld);+ Assert.Equal(score, returned.State.Score);+ }+// R-POW-004 under gdd-0.3. docs/gdd/military-combat.md:77: "A returned enemy population unit scores 10 points, main's// value (`R-POW-004`; owner, 1 November 2026, O7: "10 per unit, main (Recommended)") [S21]." Three units returned score 30,// all of it prisoner points (R-SCORE-001), and nothing scored at the capture.