A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Tests: pin R-MIN-001 near-neutral, R-MIN-003 not-yet-created office, R-WAR-005 no RNG draw (Fixes #2646) (#2717)
Beri8d68858085f0
diff --git a/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.cs b/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.csindex 6355ffb3b..fbfecaf87 100644--- a/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.cs+++ b/sim/Statecraft.Sim.Tests/Gdd03ArmisticeQuietTests.cs@@ -67,6 +67,23 @@ options:Assert.Equal(new[] { 2, 2, 2, 2 }, Counts(s));}+ // R-WAR-005 (#2646): counting quiet turns and marking an engagement only update the counts; neither draws a random+ // number, so the count can never change a later combat's draw.+ [Fact]+ public void CountingQuietTurnsDrawsNoRandomNumber()+ {+ var c = Load();+ var s = With(c, Ours(1, 0, 1), Theirs(2, 5, 1, "egypt"));+ var rng = s.RngState;+ Armistice.CountQuietTurns(c, s); // a quiet turn end+ Assert.Equal(new[] { 1, 1, 1, 1 }, Counts(s));+ Assert.Equal(rng, s.RngState);+ Armistice.Engaged(c, s, s.Units.Values); // an engagement on the Egyptian front, then its turn end+ Armistice.CountQuietTurns(c, s);+ Assert.Equal(new[] { 0, 2, 2, 2 }, Counts(s));+ Assert.Equal(rng, s.RngState);+ }+// R-WAR-005, Q48: an engagement with an Egyptian unit resets Egypt only; an Iraqi unit resets Jordan (the Jordan agreement// took over the Iraqi sector); an ALA or local unit belongs to no front and resets none.[Theory]diff --git a/sim/Statecraft.Sim.Tests/MinistersGddTests.cs b/sim/Statecraft.Sim.Tests/MinistersGddTests.csindex 6c48b2a6d..dd0f5f7a8 100644--- a/sim/Statecraft.Sim.Tests/MinistersGddTests.cs+++ b/sim/Statecraft.Sim.Tests/MinistersGddTests.cs@@ -195,6 +195,46 @@ offices:Assert.Equal(1.5, EffectsSystem.GddSystemMultiplier(succeeded, s, succeeded.RulesAt(s.Date).Mvp!, EffectsSystem.AbsorptionSystem), 9);}+ // R-MIN-001 (#2646): a multiplier within 1e-9 of 1.0 reads as exactly 1.0. The able holder (competence 10) is 1.0, and a+ // budget share a hair over even gives a budget factor of 1.0 + 1e-12. Just outside the band (a share of 0.5 + 1e-8, a+ // factor of about 1.0 + 1e-8) the multiplier is kept as it is, so the test holds the 1e-9 from both sides.+ [Fact]+ public void ANearNeutralMultiplierReadsExactlyOne()+ {+ var c = Town(Able);+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.Budget["agriculture_minister"] = 0.5 + 1e-12;+ s.Budget["finance_minister"] = 0.5 - 1e-12;+ Assert.NotEqual(1.0, EffectsSystem.Multiplier(c, s, "agriculture_minister")); // the raw product is off by float noise+ Assert.Equal(1.0, EffectsSystem.GddSystemMultiplier(c, s, c.RulesAt(s.Date).Mvp!, EffectsSystem.YishuvWorkSystem));++ s.Budget["agriculture_minister"] = 0.5 + 1e-8;+ s.Budget["finance_minister"] = 0.5 - 1e-8;+ var outside = EffectsSystem.Multiplier(c, s, "agriculture_minister");+ Assert.InRange(outside - 1.0, 5e-9, 2e-8); // about 1e-8 off, outside the 1e-9 band+ Assert.Equal(outside, EffectsSystem.GddSystemMultiplier(c, s, c.RulesAt(s.Date).Mvp!, EffectsSystem.YishuvWorkSystem));+ }++ // R-MIN-003 (#2646): an office not yet created on the state's date reads as absent, like an ended one: its successor's+ // multiplier, or neutral 1.0 with none, never the vacant-holder rule (0.5 competence).+ [Fact]+ public void AnOfficeNotYetCreatedIsAbsent()+ {+ const string Immigration = "- id: immigration_minister\n title: Minister of Immigration";+ var future = Town(budget: "immigration_minister",+ offices: Offices.Replace(Immigration, Immigration + "\n from: 1949-03-10"));+ var s = Simulation.NewGame(future, 1, Mode.Historical);+ Assert.True(s.Date < new DateTime(1949, 3, 10));+ Assert.Equal(1.0, EffectsSystem.GddSystemMultiplier(future, s, future.RulesAt(s.Date).Mvp!, EffectsSystem.AbsorptionSystem), 9);++ var succeeded = Town(Able.Replace("agriculture_minister", "interior_minister"), budget: "interior_minister",+ // The loader allows a successor only with until (an abolished office), so this office has both dates.+ offices: Offices.Replace(Immigration, Immigration + "\n from: 1949-03-10\n until: 1951-10-08\n successor: interior_minister")+ + " - id: interior_minister\n title: Minister of Internal Affairs\n");+ s = Simulation.NewGame(succeeded, 1, Mode.Historical);+ Assert.Equal(1.5, EffectsSystem.GddSystemMultiplier(succeeded, s, succeeded.RulesAt(s.Date).Mvp!, EffectsSystem.AbsorptionSystem), 9);+ }+// R-MIN-001: a system the map does not name is neutral.[Fact]public void AnUnmappedSystemIsNeutral()