A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: remove the unpaid-upkeep term from Gdd03HousingFormula.Evaluate (Fixes #2516) (#2631)
Beri19e217a2071a
diff --git a/changelog.d/2516-housing-no-unpaid-upkeep.md b/changelog.d/2516-housing-no-unpaid-upkeep.mdnew file mode 100644index 000000000..6b87022a3--- /dev/null+++ b/changelog.d/2516-housing-no-unpaid-upkeep.md@@ -0,0 +1,4 @@+### Removed++- The `gdd-0.3` test-only housing arithmetic no longer has an unpaid-upkeep loss, since the MVP has no housing upkeep+ (27M-17). Nothing in the game changes. (#2516)diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 1bb0cc80b..34574e69c 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -136,11 +136,11 @@ For R-HOUSE-001, the preceding legacy/gdd-0.1 wording remains unchanged. The inaR-HOUSE-002: A city's overflow is `max(0, housed - housing_capacity)`, one capacity point housing one population unit (D-D1, Q-HOUSE-1, owner, 15 October 2026). On the housing step, after R-CITY-004 and before Social cohesion (D-A6), a city with overflow loses `overflow_condition_loss * overflow / housed` of its condition, never below 0; a city without overflow keeps its condition. `overflow_condition_loss` is 0.15, a design value. The loader requires both values, from 0 to 1. Overflow reaches Social cohesion through R-HOUSE-004 (a lower condition lowers the base of the national `housing` indicator) and the existing `homes_lift_morale` link (k 0.15) from `housing` into `morale`, which is Social cohesion (R-NAT-001); there is no direct overflow term (Q-HOUSE-1, decided by the owner 15 October 2026, plan:165 of `docs/superpowers/plans/2026-10-15-gdd-phase-3.md`: cohesion follows through the existing `housing` to `morale` link, "so it needs no number of its own"; the cohesion half was built after #728, merged as #857, owner 17 October 2026).-For R-HOUSE-002, inactive gdd-0.3 synthetic arithmetic prices the surcharge as `SurchargeResidents * max(0, money_threshold - ConditionBefore) * money_slope`, then subtracts overflow and unpaid-upkeep losses and clamps condition. Overflow loss is `(overflow_deterioration / 100) * max(0, Residents - Capacity) / Residents`, with `Residents` the housed residents after the step's arrivals become civilians (27M-15, owner-approved 1 November 2026: "After that step's arrivals become civilians (R-CITY-004)."; #2517); unpaid loss is `(max_deterioration / 100) * (UpkeepDue - UpkeepPaid) / UpkeepDue`. Zero residents or zero upkeep due gives zero for the respective loss. The returned cohesion contribution is `max_cohesion_loss * (CohesionResidents / OwnPopulation) * max(0, (cohesion_threshold - ConditionAfter) / cohesion_threshold)`, zero with no own population. It is displayed points, not an indicator write or a national summation (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:66-88@25938871c`; the after-arrivals, worked-number, distinct-count, post-deterioration and zero-denominator fixtures in `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:77-86,112-172@25938871c`). Source: `docs/gdd/cities.md:29-35@605277dfa511dc512562ececeb273b8393b21d35`; #1703 says, "Price the surcharge from pre-deterioration condition, then deteriorate once, then apply cohesion once." Under `gdd-0.3` this arithmetic is now live, per city, as R-HOUSE-005 (#1703); under `gdd-0.1` and legacy the preceding active rule (0.15) is unchanged. Repairs are R-HOUSE-006 under `gdd-0.3` (#1700); monthly snapshot timing (#1716) remains pending.+For R-HOUSE-002, inactive gdd-0.3 synthetic arithmetic prices the surcharge as `SurchargeResidents * max(0, money_threshold - ConditionBefore) * money_slope`, then subtracts the overflow loss and clamps condition. Overflow loss is `(overflow_deterioration / 100) * max(0, Residents - Capacity) / Residents`, with `Residents` the housed residents after the step's arrivals become civilians (27M-15, owner-approved 1 November 2026: "After that step's arrivals become civilians (R-CITY-004)."; #2517); zero residents gives zero loss. There is no unpaid-upkeep loss and the helper takes no upkeep input: there is no housing upkeep (27M-17, R-HOUSE-005), and `housing.max_deterioration` stays in `content/gdd03-balance.yaml` as post-MVP design that nothing reads (#2516). The returned cohesion contribution is `max_cohesion_loss * (CohesionResidents / OwnPopulation) * max(0, (cohesion_threshold - ConditionAfter) / cohesion_threshold)`, zero with no own population. It is displayed points, not an indicator write or a national summation (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:66-88@25938871c`; the after-arrivals, worked-number, distinct-count, post-deterioration and zero-denominator fixtures in `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:77-86,112-172@25938871c`). Source: `docs/gdd/cities.md:29-35@605277dfa511dc512562ececeb273b8393b21d35`; #1703 says, "Price the surcharge from pre-deterioration condition, then deteriorate once, then apply cohesion once." Under `gdd-0.3` this arithmetic is now live, per city, as R-HOUSE-005 (#1703); under `gdd-0.1` and legacy the preceding active rule (0.15) is unchanged. Repairs are R-HOUSE-006 under `gdd-0.3` (#1700); monthly snapshot timing (#1716) remains pending.R-HOUSE-003: The people who take a city's housing (`housed`) are its civilians, its craftsmen, its recruits and its groups in training, a halutz group included until it becomes a movable unit. Halutz units do not (Q-HOUSE-5, owner, 15 October 2026). Refugees wait for housing and are not in it.-For R-HOUSE-003, the inactive gdd-0.3 helper takes independently supplied surcharge, overflow and cohesion resident counts plus own population, the overflow count taken after the step's arrivals (27M-15); it selects no residents and substitutes none of those counts for another (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:66-88@25938871c`, `:130-150`; `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:77-86,135-144@25938871c`). Negative counts, capacity or upkeep, overpayment, cohesion residents above total own population, and condition outside 0..1 are refused. A zero-population cohesion input therefore requires zero cohesion residents (`docs/gdd/cities.md:27,31@605277dfa511dc512562ececeb273b8393b21d35`). Source: `docs/gdd/cities.md:25@605277dfa511dc512562ececeb273b8393b21d35`, "A civilian resident without dedicated reception, teacher or military-training housing uses ordinary housing."; `docs/gdd/loop-switch.md:33` at that revision said, "use pre-arrival residents for overcrowding deterioration", which 27M-15 superseded: housing effects count residents after the step's arrivals become civilians (owner-approved 1 November 2026; owner, 2 November 2026: "After housing arrivals (Recommended)"), so `Gdd03SyntheticMonthContext` no longer carries a pre-arrival resident list (#2517). Those are producer requirements, not resident-selection behavior implemented here. Live status selection (#1689), regions/approved housing locations (#1691; #1690 closed on 2 November 2026, its post-MVP regional pools moved to #2233) and which residents to count (#1668) remain pending under the #1703 status comment, which says, "Regional housing settlement is not yet implemented". The preceding legacy/gdd-0.1 resident set remains unchanged. Under `gdd-0.3` (#1703) a city's Israeli formations are not housed: `housed` is its civilians, craftsmen, recruits and groups in training, so the formations whose home it is no longer count toward its overflow, R-HOUSE-004's weights or R-OBJ-004 (27M-18, owner-approved 1 November 2026: "Housed = civilians, craftsmen, recruits and groups in training. Refugees and pioneer units are not housed."; confirmed by the owner, 3 November 2026: "Yes, formations not housed (Recommended)"). `gdd-0.1` keeps counting them (Q-HOUSE-5; `Cities.Housed`).+For R-HOUSE-003, the inactive gdd-0.3 helper takes independently supplied surcharge, overflow and cohesion resident counts plus own population, the overflow count taken after the step's arrivals (27M-15); it selects no residents and substitutes none of those counts for another (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:66-88@25938871c`, `:130-150`; `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:77-86,135-144@25938871c`). Negative counts or capacity, cohesion residents above total own population, and condition outside 0..1 are refused. A zero-population cohesion input therefore requires zero cohesion residents (`docs/gdd/cities.md:27,31@605277dfa511dc512562ececeb273b8393b21d35`). Source: `docs/gdd/cities.md:25@605277dfa511dc512562ececeb273b8393b21d35`, "A civilian resident without dedicated reception, teacher or military-training housing uses ordinary housing."; `docs/gdd/loop-switch.md:33` at that revision said, "use pre-arrival residents for overcrowding deterioration", which 27M-15 superseded: housing effects count residents after the step's arrivals become civilians (owner-approved 1 November 2026; owner, 2 November 2026: "After housing arrivals (Recommended)"), so `Gdd03SyntheticMonthContext` no longer carries a pre-arrival resident list (#2517). Those are producer requirements, not resident-selection behavior implemented here. Live status selection (#1689), regions/approved housing locations (#1691; #1690 closed on 2 November 2026, its post-MVP regional pools moved to #2233) and which residents to count (#1668) remain pending under the #1703 status comment, which says, "Regional housing settlement is not yet implemented". The preceding legacy/gdd-0.1 resident set remains unchanged. Under `gdd-0.3` (#1703) a city's Israeli formations are not housed: `housed` is its civilians, craftsmen, recruits and groups in training, so the formations whose home it is no longer count toward its overflow, R-HOUSE-004's weights or R-OBJ-004 (27M-18, owner-approved 1 November 2026: "Housed = civilians, craftsmen, recruits and groups in training. Refugees and pioneer units are not housed."; confirmed by the owner, 3 November 2026: "Yes, formations not housed (Recommended)"). `gdd-0.1` keeps counting them (Q-HOUSE-5; `Cities.Housed`).R-HOUSE-004: In the GDD loop the base of the national `housing` indicator is the people-weighted mean of the cities' housing condition, each city weighed by its housed people (R-HOUSE-003): `sum(condition * housed) / sum(housed)`. Policy effects, map actions and events still act on top, as on any indicator. Decided (owner, 17 Oct 2026, option (a) of Q-PR3-A, relayed on [#855 at 06:33Z](https://github.com/eyalgolan/statecraft-israel/pull/855#issuecomment-6230731177)): the national housing base is the people-weighted mean of city condition, with policy, map actions and events still applied on top. When no city houses anybody the mean is undefined, and the base is `model.yaml`'s. Capacity reaches the level through overflow and condition (R-HOUSE-002).diff --git a/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs b/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.csindex bc6b4b6c6..8742b54e1 100644--- a/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs+++ b/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs@@ -9,9 +9,9 @@ public class Gdd03HousingFormulaTestsstatic Gdd03HousingInput Input(int surcharge = 10, int residents = 10,int cohesion = 10, int population = 20, decimal capacity = 5m,- decimal condition = 0.40m, decimal due = 4m, decimal paid = 2m) =>+ decimal condition = 0.40m) =>new Gdd03HousingInput(surcharge, residents, cohesion, population,- capacity, condition, due, paid);+ capacity, condition);// Each fixture changes one coefficient before the existing reader validates/snapshots it.static Gdd03HousingFormula FormulaWithSyntheticScalar(string key, decimal value)@@ -49,7 +49,7 @@ public class Gdd03HousingFormulaTestsvar f = FormulaWithSyntheticScalar("housing.cohesion_threshold", threshold);var expected = 2m * (5m / 20m) * Math.Max(0m, (threshold - 0.125m) / threshold);Assert.Equal(expected, f.Evaluate(Input(cohesion: 5, population: 20,- capacity: 10m, condition: 0.125m, due: 0m, paid: 0m)).CohesionLossPoints);+ capacity: 10m, condition: 0.125m)).CohesionLossPoints);}[Fact] public void SyntheticMaximumCohesionLossComesFromSuppliedCatalogue()@@ -59,7 +59,7 @@ public class Gdd03HousingFormulaTestsvar f = FormulaWithSyntheticScalar("housing.max_cohesion_loss", maximumLoss);var expected = maximumLoss * (5m / 20m) * Math.Max(0m, (0.25m - 0.125m) / 0.25m);Assert.Equal(expected, f.Evaluate(Input(cohesion: 5, population: 20,- capacity: 10m, condition: 0.125m, due: 0m, paid: 0m)).CohesionLossPoints);+ capacity: 10m, condition: 0.125m)).CohesionLossPoints);}[Fact] public void SyntheticOverflowRateComesFromSuppliedCatalogue()@@ -69,7 +69,7 @@ public class Gdd03HousingFormulaTestsvar f = FormulaWithSyntheticScalar("housing.overflow_deterioration", overflowPp);var expectedLoss = (overflowPp / 100m) * Math.Max(0m, 20m - 8m) / 20m;var r = f.Evaluate(Input(residents: 20, capacity: 8m,- condition: 0.40m, due: 4m, paid: 4m));+ condition: 0.40m));Assert.Equal(expectedLoss, r.OverflowConditionLoss);Assert.Equal(0.40m - expectedLoss, r.ConditionAfter);}@@ -79,21 +79,21 @@ public class Gdd03HousingFormulaTests// R-HOUSE-005, 27M-15 (#2517): R is counted after the step's arrivals become civilians. 10 housed people at// capacity 10 overflow by nothing; 2 arrivals this step make R 12, and those 2 overflow.var f = Formula();- Assert.Equal(0m, f.Evaluate(new Gdd03HousingInput(10, residents: 10, 10, 20, 10m, 0.40m, 0m, 0m)).OverflowConditionLoss);- var r = f.Evaluate(new Gdd03HousingInput(12, residents: 12, 12, 20, 10m, 0.40m, 0m, 0m));+ Assert.Equal(0m, f.Evaluate(new Gdd03HousingInput(10, residents: 10, 10, 20, 10m, 0.40m)).OverflowConditionLoss);+ var r = f.Evaluate(new Gdd03HousingInput(12, residents: 12, 12, 20, 10m, 0.40m));Assert.Equal((5m / 100m) * 2m / 12m, r.OverflowConditionLoss); // overflow_deterioration 5 pp (owner, 2 November 2026)Assert.Equal(0.40m - (5m / 100m) * 2m / 12m, r.ConditionAfter);}- [Fact] public void SyntheticUnpaidRateComesFromSuppliedCatalogue()+ [Fact] public void NoUnpaidUpkeepTermAndTheDeclinedRowIsNotRead(){- // R-HOUSE-002: catches unpaidPp replaced by the shipped literal 10m.- const decimal unpaidPp = 18m;- var f = FormulaWithSyntheticScalar("housing.max_deterioration", unpaidPp);- var expectedLoss = (unpaidPp / 100m) * ((10m - 2m) / 10m);- var r = f.Evaluate(Input(capacity: 10m, condition: 0.40m, due: 10m, paid: 2m));- Assert.Equal(expectedLoss, r.UnpaidConditionLoss);- Assert.Equal(0.40m - expectedLoss, r.ConditionAfter);+ // R-HOUSE-005, 27M-17: no housing upkeep, so no unpaid-upkeep loss; `housing.max_deterioration` stays in the+ // catalogue as post-MVP design (#2516) and the reader no longer requires it.+ var c = ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance ?? throw new InvalidOperationException("GDD 0.3 catalogue required");+ c.Values.Remove("housing.max_deterioration"); // TEST-ONLY SYNTHETIC: the declined row is absent+ var r = Gdd03HousingFormula.FromCatalogue(c).Evaluate(Input());+ Assert.Equal(0.025m, r.OverflowConditionLoss);+ Assert.Equal(0.40m - 0.025m, r.ConditionAfter);}[Fact] public void SyntheticRepairEffectComesFromSuppliedCatalogue()@@ -109,16 +109,15 @@ public class Gdd03HousingFormulaTestsAssert.Equal(expected, f.RepairCondition(0.40m));}- [Fact] public void PreDeteriorationPriceAndBothLossesHaveWorkedNumbers()+ [Fact] public void PreDeteriorationPriceAndOverflowLossHaveWorkedNumbers(){// R-HOUSE-001, R-HOUSE-002: price first, deteriorate once, return arithmetic only.var r = Formula().Evaluate(Input());Assert.Equal(0.1m, r.SurchargeMoney); // 10 x 0.10 x money_slope 0.1 (#1703: "Scale it to unit size (Recommended)", owner, 2 November 2026; was 1)Assert.Equal(0.025m, r.OverflowConditionLoss);- Assert.Equal(0.05m, r.UnpaidConditionLoss);- Assert.Equal(0.325m, r.ConditionAfter);+ Assert.Equal(0.375m, r.ConditionAfter);Assert.Equal(0m, r.CohesionLossPoints);- Assert.Equal(7.5m, r.TotalConditionLossPp);+ Assert.Equal(2.5m, r.TotalConditionLossPp);}[Theory]@@ -136,7 +135,7 @@ public class Gdd03HousingFormulaTests{// R-HOUSE-002, R-HOUSE-003: does not select residents or settle timing.var r = Formula().Evaluate(Input(surcharge: 10, residents: 20,- cohesion: 5, population: 20, capacity: 15m, condition: 0.125m, due: 0m, paid: 0m));+ cohesion: 5, population: 20, capacity: 15m, condition: 0.125m));Assert.Equal(0.375m, r.SurchargeMoney); // 10 x 0.375 x money_slope 0.1 (#1703; was 3.75 at slope 1)Assert.Equal(0.0125m, r.OverflowConditionLoss);Assert.Equal(0.1125m, r.ConditionAfter);@@ -147,26 +146,23 @@ public class Gdd03HousingFormulaTests{// R-HOUSE-002: no extra direct overflow penalty or indicator mutation.var f = Formula();- var r = f.Evaluate(Input(population: 10, condition: 0.26m, due: 0m, paid: 0m));+ var r = f.Evaluate(Input(population: 10, condition: 0.26m));Assert.Equal(0.235m, r.ConditionAfter);Assert.Equal(0.12m, r.CohesionLossPoints);- var a = f.Evaluate(Input(condition: 0.125m, capacity: 10m, due: 0m, paid: 0m));+ var a = f.Evaluate(Input(condition: 0.125m, capacity: 10m));var b = f.Evaluate(Input(surcharge: 5, residents: 5, cohesion: 5,- condition: 0m, capacity: 5m, due: 0m, paid: 0m));+ condition: 0m, capacity: 5m));Assert.Equal(1m, a.CohesionLossPoints + b.CohesionLossPoints);}- [Fact] public void ZeroDenominatorsAndFullPaymentHaveNoLoss()+ [Fact] public void ZeroDenominatorsHaveNoLoss(){// R-HOUSE-002var r = Formula().Evaluate(Input(surcharge: 0, residents: 0, cohesion: 0,- population: 0, capacity: 0m, condition: 0m, due: 0m, paid: 0m));+ population: 0, capacity: 0m, condition: 0m));Assert.Equal(0m, r.OverflowConditionLoss);- Assert.Equal(0m, r.UnpaidConditionLoss);Assert.Equal(0m, r.CohesionLossPoints);Assert.Equal(0m, r.SurchargeMoney);- Assert.Equal(0m, Formula().Evaluate(Input(due: 4m, paid: 4m)).UnpaidConditionLoss);- Assert.Equal(0.075m, Formula().Evaluate(Input(due: 4m, paid: 1m)).UnpaidConditionLoss);Assert.Equal(0m, Formula().Evaluate(Input(residents: 0, cohesion: 0, population: 0,condition: 0m)).CohesionLossPoints);}@@ -175,7 +171,7 @@ public class Gdd03HousingFormulaTests{// R-HOUSE-001: arithmetic only, no project, payment or initial condition.var f = Formula();- Assert.Equal(0m, f.Evaluate(Input(condition: 0.01m, paid: 0m)).ConditionAfter);+ Assert.Equal(0m, f.Evaluate(Input(condition: 0.01m)).ConditionAfter);Assert.Equal(1m, f.RepairCondition(0.95m));Assert.Equal(0m, f.ApplyConditionEffect(0.04m, -0.10m));Assert.Equal(0.90m, f.ApplyConditionEffect(f.RepairCondition(0.95m), -0.10m));@@ -189,7 +185,7 @@ public class Gdd03HousingFormulaTests{// R-HOUSE-002: a region's ordinary residents are part of total own population.Assert.Throws<ArgumentOutOfRangeException>(() => Formula().Evaluate(- Input(cohesion: residents, population: population, condition: 0m, due: 0m, paid: 0m)));+ Input(cohesion: residents, population: population, condition: 0m)));}[Fact] public void InvalidExplicitInputsAreRejectedWithoutState()@@ -197,8 +193,7 @@ public class Gdd03HousingFormulaTestsvar f = Formula();foreach (var input in new[] { Input(surcharge: -1), Input(residents: -1),Input(cohesion: -1), Input(population: -1), Input(capacity: -1m),- Input(condition: -0.01m), Input(condition: 1.01m), Input(due: -1m),- Input(paid: -1m), Input(paid: 5m), Input(due: 0m, paid: 1m) })+ Input(condition: -0.01m), Input(condition: 1.01m) })Assert.Throws<ArgumentOutOfRangeException>(() => f.Evaluate(input));Assert.Throws<ArgumentNullException>(() => f.Evaluate(null!));Assert.Equal(0.1m, f.Evaluate(Input()).SurchargeMoney); // money_slope 0.1 (#1703; was 1)@@ -214,7 +209,7 @@ public class Gdd03HousingFormulaTests{CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture);CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo(culture);- Assert.Equal("0.325", Formula().Evaluate(Input()).ConditionAfter.ToString(CultureInfo.InvariantCulture));+ Assert.Equal("0.375", Formula().Evaluate(Input()).ConditionAfter.ToString(CultureInfo.InvariantCulture));}finally { CultureInfo.CurrentCulture = old; CultureInfo.CurrentUICulture = oldUi; }}@@ -253,7 +248,7 @@ public class Gdd03HousingFormulaTests}// R-HOUSE-005 (#1703): the live step EvaluateTurn (double, the state type) is the decimal Evaluate with every resident- // count equal and no upkeep (27M-17). Pins the two forms together over the shipped catalogue and each synthetic scalar+ // count equal; neither has upkeep (27M-17). Pins the two forms together over the shipped catalogue and each synthetic scalar// override above, every count, capacity and condition these tests use, and conditions 0.00 to 0.60 in 0.01 steps.[Fact] public void LiveDoubleStepAgreesWithTheDecimalFormula(){@@ -276,7 +271,7 @@ public class Gdd03HousingFormulaTestsforeach (var condition in conditions){if (residents > population) continue;- var d = f.Evaluate(new Gdd03HousingInput(residents, residents, residents, population, capacity, condition, 0m, 0m));+ var d = f.Evaluate(new Gdd03HousingInput(residents, residents, residents, population, capacity, condition));var live = f.EvaluateTurn(residents, population, capacity, (double)condition);var at = $"R={residents} P={population} cap={capacity} c={condition}";Assert.True(Math.Abs((double)d.SurchargeMoney - live.Surcharge) <= 1e-9, "surcharge " + at);diff --git a/sim/Statecraft.Sim/Gdd03HousingFormula.cs b/sim/Statecraft.Sim/Gdd03HousingFormula.csindex 80f714576..bc6601ad1 100644--- a/sim/Statecraft.Sim/Gdd03HousingFormula.cs+++ b/sim/Statecraft.Sim/Gdd03HousingFormula.cs@@ -8,7 +8,7 @@ namespace Statecraft.Siminternal sealed class Gdd03HousingFormula{readonly decimal conditionMax, moneyThreshold, moneySlope, cohesionThreshold;- readonly decimal maxCohesionLoss, overflowPp, unpaidPp, repairPp;+ readonly decimal maxCohesionLoss, overflowPp, repairPp;internal string OverflowBasis { get; }Gdd03HousingFormula(Gdd03BalanceCatalogue c)@@ -20,7 +20,6 @@ namespace Statecraft.SimcohesionThreshold = Scalar(c, "housing.cohesion_threshold", true);maxCohesionLoss = Scalar(c, "housing.max_cohesion_loss", false);overflowPp = Scalar(c, "housing.overflow_deterioration", false);- unpaidPp = Scalar(c, "housing.max_deterioration", false);OverflowBasis = c.Values["housing.overflow_deterioration"].Basis;if (conditionMax != 1m || moneyThreshold > conditionMax || cohesionThreshold > conditionMax)throw Invalid("housing.condition_max", "condition is a fraction in [0,1]; thresholds must lie within it");@@ -68,23 +67,21 @@ namespace Statecraft.Simif (input == null) throw new ArgumentNullException(nameof(input));if (input.SurchargeResidents < 0 || input.Residents < 0|| input.CohesionResidents < 0 || input.OwnPopulation < 0- || input.CohesionResidents > input.OwnPopulation || input.Capacity < 0m- || input.UpkeepDue < 0m || input.UpkeepPaid < 0m || input.UpkeepPaid > input.UpkeepDue)- throw new ArgumentOutOfRangeException(nameof(input), "counts/capacity/upkeep must be nonnegative; regional residents cannot exceed own population; paid cannot exceed due");+ || input.CohesionResidents > input.OwnPopulation || input.Capacity < 0m)+ throw new ArgumentOutOfRangeException(nameof(input), "counts/capacity must be nonnegative; regional residents cannot exceed own population");ValidateCondition(input.ConditionBefore);// GDD cities.md:29,33,35 at 605277df. Overflow counts the housed residents after the step's arrivals become// civilians (27M-15, owner, 1 November 2026). Counts are independently supplied; this helper selects no one.var surcharge = input.SurchargeResidents * Math.Max(0m, moneyThreshold - input.ConditionBefore) * moneySlope;var overflow = input.Residents == 0 ? 0m :(overflowPp / 100m) * Math.Max(0m, input.Residents - input.Capacity) / input.Residents;- var unpaid = input.UpkeepDue == 0m ? 0m :- (unpaidPp / 100m) * ((input.UpkeepDue - input.UpkeepPaid) / input.UpkeepDue);- var after = Clamp(input.ConditionBefore - overflow - unpaid);+ // No unpaid-upkeep term: there is no housing upkeep (27M-17, R-HOUSE-005; #2516).+ var after = Clamp(input.ConditionBefore - overflow);// GDD cities.md:31,33 at 605277df. Contribution in displayed points, not indicator storage.var cohesion = input.OwnPopulation == 0 ? 0m : maxCohesionLoss* ((decimal)input.CohesionResidents / input.OwnPopulation)* Math.Max(0m, (cohesionThreshold - after) / cohesionThreshold);- return new Gdd03HousingResult(surcharge, overflow, unpaid, after, cohesion);+ return new Gdd03HousingResult(surcharge, overflow, after, cohesion);}/// <summary>R-HOUSE-005's live step for one city (#1703; Cities.UpdateCondition): Evaluate's surcharge, overflow@@ -137,15 +134,13 @@ namespace Statecraft.Siminternal int OwnPopulation { get; }internal decimal Capacity { get; }internal decimal ConditionBefore { get; }- internal decimal UpkeepDue { get; }- internal decimal UpkeepPaid { get; }internal Gdd03HousingInput(int surchargeResidents, int residents, int cohesionResidents,- int ownPopulation, decimal capacity, decimal conditionBefore, decimal upkeepDue, decimal upkeepPaid)+ int ownPopulation, decimal capacity, decimal conditionBefore){SurchargeResidents = surchargeResidents; Residents = residents;CohesionResidents = cohesionResidents; OwnPopulation = ownPopulation; Capacity = capacity;- ConditionBefore = conditionBefore; UpkeepDue = upkeepDue; UpkeepPaid = upkeepPaid;+ ConditionBefore = conditionBefore;}}@@ -153,16 +148,15 @@ namespace Statecraft.Sim{internal decimal SurchargeMoney { get; }internal decimal OverflowConditionLoss { get; }- internal decimal UnpaidConditionLoss { get; }- internal decimal TotalConditionLossPp => (OverflowConditionLoss + UnpaidConditionLoss) * 100m;+ internal decimal TotalConditionLossPp => OverflowConditionLoss * 100m;internal decimal ConditionAfter { get; }internal decimal CohesionLossPoints { get; }internal Gdd03HousingResult(decimal surchargeMoney, decimal overflowConditionLoss,- decimal unpaidConditionLoss, decimal conditionAfter, decimal cohesionLossPoints)+ decimal conditionAfter, decimal cohesionLossPoints){SurchargeMoney = surchargeMoney; OverflowConditionLoss = overflowConditionLoss;- UnpaidConditionLoss = unpaidConditionLoss; ConditionAfter = conditionAfter;+ ConditionAfter = conditionAfter;CohesionLossPoints = cohesionLossPoints;}}