A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: R-OBJ-004 employment counts civilians and craftsmen, as R-CITY-005 (both rulesets) (#2386)
Eyal Golanbb04857a83b7
diff --git a/changelog.d/1714-absorbed-denominator.md b/changelog.d/1714-absorbed-denominator.mdnew file mode 100644index 000000000..7a9fe6af1--- /dev/null+++ b/changelog.d/1714-absorbed-denominator.md@@ -0,0 +1,4 @@+### Fixed+- The "absorb immigrants" objective now measures employment against the cities' civilians and craftsmen together,+ the same share that lifts Social cohesion, so employed craftsmen can no longer push it above 100% (R-OBJ-004,+ #1714; both rulesets).diff --git a/docs/gdd/objective-card.md b/docs/gdd/objective-card.mdindex 8252db07d..3b0dcd559 100644--- a/docs/gdd/objective-card.md+++ b/docs/gdd/objective-card.md@@ -12,7 +12,7 @@ I see clear objectives, receive sourced completion cards and earn a bounded bonu- The later Nir Am infrastructure-protection ruling is also part of the third objective, but its points remain an unset balance value [S11]. It is not silently added as a fourth build part to the decided three-part score.- The "absorb immigrants" objective (D-B4) completes once the Jewish population has reached a stated number, and then the cities' overflow is at most a stated share of the people they house and their employed at least a stated share of their civilians (owner, 18 October 2026, option (a) [S8]; R-OBJ-004). The population gate keeps the start values from completing it on the first turn; refugees waiting do not count, since each turn's arrivals come after housing. Its numbers, reference date and card are content (`objectives.yaml` and its card), added with a person's source check [S8].-The retained `Q-ABS-2` condition is stricter than that shorthand: **no refugees wait for housing**. It is a required completion condition alongside the population, overflow and employment gates [S8].+The retained `Q-ABS-2` condition first read **no refugees wait for housing**; option (a) [S8] has no such clause, so refugees waiting in the cities do not block completion (R-OBJ-004). Amir's refugee-awaiting-legal-bed input never blocks it in the MVP either, which has no reception-bed layer (owner, 1 November 2026: "No reception-bed layer (Recommended)") [S19].- An objective is recorded once, in the last step of the GDD turn, with the turn's end date, and only in the GDD loop (R-OBJ-001).- Completing a standalone objective scores 100 points (unitless) once. A multipart objective pays the same base once, when its last part completes (D-B6 [S2], R-OBJ-002, R-OBJ-006).- Each calendar month (unitless) between the completion's month and the reference date's month adds 5 points (unitless), up to 60 points (unitless) (D-B2 [S2], R-OBJ-002). The same month is on time and earns no bonus; finishing late costs nothing. Calendar months match the owner's card wording [S6], and the owner confirmed them on 15 October 2026 [S7].diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 2385837ea..ddb5ce680 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -384,7 +384,7 @@ R-OBJ-002: Recording a standalone objective adds `objective_points + min(objectiR-OBJ-003: An event with `objective:` is that objective's card. It is eligible only once its objective is recorded, so it fires once, at the end of the turn the objective is completed in, and never in the legacy loop. A card has exactly one option, and an objective and its card name each other (the loader checks both). An unanswered card resolves to its option without drawing from the RNG.-R-OBJ-004: An objective may instead name `completes_when: { absorbed: { population_at_least, overflow_at_most, employed_at_least } }` (D-B4; owner, 18 October 2026, #738, option (a)). It holds at step 11 once the Jewish population (`GameState.TotalPopulation`, the national count as step 11 reads it, before the turn's population step) is at or above `population_at_least`, and then the cities' overflow (R-HOUSE-002), summed, is at most `overflow_at_most` of their housed people (R-HOUSE-003), summed, and their employed civilians, summed, are at least `employed_at_least` of their civilians (as R-CITY-005 counts them). Refugees waiting do not count: each turn's arrivals (step 9) wait at step 11, after housing (step 8). The gate keeps the census start values (41% employed, no overflow) from completing it on the first turn. Sums are integers, compared with the decimal share, so city order cannot change the result. An objective names exactly one kind; all three keys are required (a missing key is never read as 0), the shares are from 0 to 1 and the population above 0 (the loader). Recorded and scored as R-OBJ-001 and R-OBJ-002 say; its card follows R-OBJ-003.+R-OBJ-004: An objective may instead name `completes_when: { absorbed: { population_at_least, overflow_at_most, employed_at_least } }` (D-B4; owner, 18 October 2026, #738, option (a)). It holds at step 11 once the Jewish population (`GameState.TotalPopulation`, the national count as step 11 reads it, before the turn's population step) is at or above `population_at_least`, and then the cities' overflow (R-HOUSE-002), summed, is at most `overflow_at_most` of their housed people (R-HOUSE-003), summed, and their employed, summed, are at least `employed_at_least` of their civilians and craftsmen, summed (as R-CITY-005 counts them; owner, 3 November 2026, #1714: "Both rulesets (Recommended)", so gdd-0.1 and gdd-0.3 alike). Refugees waiting do not count: each turn's arrivals (step 9) wait at step 11, after housing (step 8). The gate keeps the census start values (41% employed, no overflow) from completing it on the first turn. Sums are integers, compared with the decimal share, so city order cannot change the result. An objective names exactly one kind; all three keys are required (a missing key is never read as 0), the shares are from 0 to 1 and the population above 0 (the loader). Recorded and scored as R-OBJ-001 and R-OBJ-002 say; its card follows R-OBJ-003.For R-OBJ-004, the preceding active gdd-0.1 rule remains unchanged. The gdd-0.3 addition is an inactive, synthetic-only boundary: `Gdd03SyntheticAbsorptionBoundary.HoldsForSyntheticSettledFacts` accepts supplied represented own units, a canonical refugee-awaiting-legal-bed flag, ordinary-housing overflow/demand and employed/all-free-civilian counts; it neither produces nor classifies them (`sim/Statecraft.Sim/Gdd03SyntheticAbsorptionBoundary.cs:6-25@1e4b8a248`). Source: `docs/gdd/objective-card.md:19@605277dfa511dc512562ececeb273b8393b21d35`, "Empty denominators mean no overflow/full employment." and "Reference remains 20 December 1949"; `docs/gdd/balance.md:195-196` at that source revision gives the exceeded population target and inclusive percentage limits.diff --git a/sim/Statecraft.Sim.Tests/ObjectivesTests.cs b/sim/Statecraft.Sim.Tests/ObjectivesTests.csindex bf67cb56e..be805b7cd 100644--- a/sim/Statecraft.Sim.Tests/ObjectivesTests.cs+++ b/sim/Statecraft.Sim.Tests/ObjectivesTests.cs@@ -623,6 +623,93 @@ eras:Assert.True(s.Objectives.ContainsKey("first_goal"));}+ /// <summary>The absorb fixture under <paramref name="ruleset"/>: gdd-0.1 is the fixture's own GDD loop; gdd-0.3 names the+ /// ruleset in eras.yaml and adds the real balance catalogue it needs, as Gdd03MovementFortTests does.</summary>+ static Content LoadAbsorbIn(string ruleset)+ {+ var f = Fixture.Gdd();+ f["objectives.yaml"] = AbsorbYaml;+ if (ruleset == SaveGame.Gdd03Ruleset)+ {+ f["eras.yaml"] = f["eras.yaml"].Replace("loop: gdd", "loop: gdd, ruleset: " + ruleset);+ f[Gdd03BalanceCatalogue.FileName] = System.IO.File.ReadAllText(System.IO.Path.Combine(RealContentTests.ContentRoot(), Gdd03BalanceCatalogue.FileName));+ }+ var c = ContentLoader.Load(Fixture.Write(f, new Dictionary<string, string> { ["first_card.yaml"] = Card }));+ Assert.Equal(ruleset, c.Ruleset);+ return c;+ }++ /// <summary>Runs step 11 on a new game whose only city is town_a, housing 100 (so nothing overflows), with the counts+ /// given; returns the state.</summary>+ static GameState AbsorbWith(Content c, int population, int civilians, int craftsmen, int employed)+ {+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.Population = new Dictionary<string, double> { ["veterans"] = population };+ s.Cities.Clear();+ s.Cities["town_a"] = new City("town_a", 100, 100, civilians, employed, 0, craftsmen: craftsmen);+ Objectives.Complete(c, s, c.Rules.Mvp!, D("1949-04-15"), new List<Cause>());+ return s;+ }++ // R-OBJ-004 with R-CITY-005 (owner, 3 November 2026, #1714: "Both rulesets (Recommended)"): the employment share's+ // denominator is civilians plus craftsmen, as R-CITY-005 counts it, in gdd-0.1 and gdd-0.3 alike. Employed includes the+ // craftsmen in jobs (City.Employed), so dividing by civilians alone could pass a share above 100%.+ [Theory]+ [InlineData(SaveGame.GddRuleset, 6, 4, 4, true)] // 4 of 10 = 40%: on the bound+ [InlineData(SaveGame.GddRuleset, 6, 5, 4, false)] // 4 of 11 = 36% (civilians alone: 4 of 6 = 67%)+ [InlineData(SaveGame.GddRuleset, 2, 8, 8, true)] // 8 of 10 = 80% (civilians alone: 400%)+ [InlineData(SaveGame.GddRuleset, 2, 20, 8, false)] // 8 of 22 = 36% (civilians alone: 400%)+ [InlineData(SaveGame.Gdd03Ruleset, 6, 4, 4, true)]+ [InlineData(SaveGame.Gdd03Ruleset, 6, 5, 4, false)]+ [InlineData(SaveGame.Gdd03Ruleset, 2, 8, 8, true)]+ [InlineData(SaveGame.Gdd03Ruleset, 2, 20, 8, false)]+ public void AbsorptionCountsCraftsmenInTheEmploymentDenominator(string ruleset, int civilians, int craftsmen, int employed, bool done)+ {+ var s = AbsorbWith(LoadAbsorbIn(ruleset), 1500, civilians, craftsmen, employed);+ Assert.Equal(done, s.Objectives.ContainsKey("first_goal"));+ }++ // R-OBJ-004: the population gate still decides first, with craftsmen counted: below it nothing completes however well+ // the cities employ; at it (at or above, as main has it) the same cities complete it. Both rulesets.+ [Theory]+ [InlineData(SaveGame.GddRuleset, 1499, false)]+ [InlineData(SaveGame.GddRuleset, 1500, true)]+ [InlineData(SaveGame.Gdd03Ruleset, 1499, false)]+ [InlineData(SaveGame.Gdd03Ruleset, 1500, true)]+ public void ThePopulationGateDecidesFirstWithCraftsmenCounted(string ruleset, int population, bool done)+ {+ var s = AbsorbWith(LoadAbsorbIn(ruleset), population, 6, 4, 10); // 10 of 10 employed+ Assert.Equal(done, s.Objectives.ContainsKey("first_goal"));+ }++ // R-OBJ-004 and R-CITY-005 (#1714 Done-when: "The same employment aggregate feeds the objective and the cohesion link"):+ // above the gate and with no overflow, the objective completes exactly when the cohesion link's employed share+ // (Cities.EmployedShare) is at least the objective's 40%. Two cities, so the sums cross cities. Both rulesets.+ [Theory]+ [InlineData(SaveGame.GddRuleset)]+ [InlineData(SaveGame.Gdd03Ruleset)]+ public void TheObjectiveAndTheCohesionLinkReadTheSameEmployment(string ruleset)+ {+ var c = LoadAbsorbIn(ruleset);+ var cases = new[] { (3, 2, 1, 2, 1, 1), (3, 2, 2, 2, 3, 2), (5, 0, 1, 0, 5, 4), (1, 9, 4, 0, 0, 0), (4, 1, 3, 1, 4, 1) };+ var outcomes = new List<bool>();+ foreach (var (civA, crA, empA, civB, crB, empB) in cases)+ {+ var s = Simulation.NewGame(c, 1, Mode.Historical);+ s.Population = new Dictionary<string, double> { ["veterans"] = 1500 };+ s.Cities.Clear();+ s.Cities["town_a"] = new City("town_a", 100, 100, civA, empA, 0, craftsmen: crA);+ s.Cities["town_b"] = new City("town_b", 100, 100, civB, empB, 0, craftsmen: crB);+ var share = Cities.EmployedShare(s);+ Objectives.Complete(c, s, c.Rules.Mvp!, D("1949-04-15"), new List<Cause>());+ Assert.True(share >= 0.40 == s.Objectives.ContainsKey("first_goal"),+ $"{ruleset} {(civA, crA, empA, civB, crB, empB)}: share {share} but objective {s.Objectives.ContainsKey("first_goal")}");+ outcomes.Add(s.Objectives.ContainsKey("first_goal"));+ }+ Assert.Contains(true, outcomes); // the cases cover both verdicts+ Assert.Contains(false, outcomes);+ }+// R-OBJ-004 (#738): Q-ABS-2 as first recorded (no refugees waiting, overflow <= 10%, employed >= 40%) already// holds at the end of the real game's first turn, with nobody absorbed: the census start values are 41% employed with no// overflow (#738, issuecomment-6242964308). The population gate keeps the objective open.diff --git a/sim/Statecraft.Sim/Objectives.cs b/sim/Statecraft.Sim/Objectives.csindex c5ffc77a0..230bebc68 100644--- a/sim/Statecraft.Sim/Objectives.cs+++ b/sim/Statecraft.Sim/Objectives.cs@@ -57,9 +57,11 @@ namespace Statecraft.Sim/// <summary>R-OBJ-004 (D-B4; owner, 18 October 2026, #738, option (a)): once the Jewish population (the national count,/// as it stands when step 11 runs, before the turn's population step) has reached the gate, the cities' overflow is at- /// most its share of the people they house and their employed at least its share of their civilians. Refugees waiting- /// do not count: the turn's arrivals (step 9) always wait at step 11, after housing (step 8). The city counts are- /// integer sums times a decimal share, so city order and the runtime cannot change them.</summary>+ /// most its share of the people they house and their employed at least its share of their civilians and craftsmen, as+ /// R-CITY-005 counts them (Cities.EmployedShare; owner, 3 November 2026, #1714: "Both rulesets (Recommended)", so+ /// gdd-0.1 and gdd-0.3 alike). Refugees waiting do not count: the turn's arrivals (step 9) always wait at step 11,+ /// after housing (step 8). The city counts are integer sums times a decimal share, so city order and the runtime+ /// cannot change them.</summary>static bool Absorbed(GameState s, AbsorbCondition a){if (s.TotalPopulation < a.PopulationAtLeast) return false;@@ -68,7 +70,7 @@ namespace Statecraft.Sim{housed += Cities.Housed(s, x);over += Cities.Overflow(s, x);- civilians += x.Civilians;+ civilians += x.Civilians + x.Craftsmen;employed += x.Employed;}return over <= a.OverflowAtMost!.Value * housed && employed >= a.EmployedAtLeast * civilians;