A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: GDD 0.3 housing condition per city: surcharge, 5 pp overflow, cohesion term (Refs #1703) (#2291)
Eyal Goland03047dc3315
diff --git a/changelog.d/1703.md b/changelog.d/1703.mdnew file mode 100644index 000000000..40470443d--- /dev/null+++ b/changelog.d/1703.md@@ -0,0 +1,8 @@+### Changed++- Under the gdd-0.3 ruleset only, each city's housing condition now costs and wears (Refs #1703): below 50% condition a+ city pays a housing surcharge of 0.1 Money per housed unit times the gap below 50% as a fraction, 7.665 (the ruling's+ "about 7.6") Money on the opening turn; overflow wears the condition by 5 percentage points times the overflow share,+ and condition below 25% lowers Social cohesion by up to 2 points a turn, replacing the old homes-to-cohesion link. A+ city's formations no longer count as housed there, so the city panel drops its "Soldiers housed" line under gdd-0.3.+ The Hebrew Why lines call the charge "היטל דיור". The gdd-0.1 game is unchanged.diff --git a/content/gdd03-balance.yaml b/content/gdd03-balance.yamlindex 98c2558f8..0a455577b 100644--- a/content/gdd03-balance.yaml+++ b/content/gdd03-balance.yaml@@ -229,12 +229,12 @@"values": [1]"housing.money_threshold":"basis": "Agreed"- "note": "Reception, housing and shortages: condition fraction / Money per resident per fraction below threshold; Agreed linear rule. Source: #1668 balance.md at 605277df."+ "note": "Reception, housing and shortages: condition fraction below which the housing surcharge applies (R-HOUSE-005, #1703); its Money rate is housing.money_slope; Agreed linear rule. Source: #1668 balance.md at 605277df.""values": [0.50]"housing.money_slope":"basis": "Agreed"- "note": "Reception, housing and shortages: condition fraction / Money per resident per fraction below threshold; Agreed linear rule. Source: #1668 balance.md at 605277df."- "values": [1]+ "note": "Reception, housing and shortages: Money per housed population unit per condition fraction below money_threshold, a turn (R-HOUSE-005, #1703). Owner, 2 November 2026: \"Scale it to unit size (Recommended)\"; the option read: \"0.1 per unit (as #2112 did for Industry), about 7.6 Money a turn at start.\" #1668's 1 Money per resident was sized for 10,000 people a unit; at D2's 1,000 people a unit it is 0.1. Agreed linear rule; a labelled design value; a balance playtest follows. Source: #1668 balance.md at 605277df."+ "values": [0.1]"housing.cohesion_threshold":"basis": "Agreed""note": "Reception, housing and shortages: condition fraction below which cohesion declines; Agreed. Source: #1668 balance.md at 605277df."@@ -244,8 +244,8 @@"note": "Reception, housing and shortages: national displayed points per turn at maximal weighted severity; Agreed. Source: #1668 balance.md at 605277df.""values": [2]"housing.overflow_deterioration":- "basis": "Default"- "note": "Reception, housing and shortages: condition pp per turn multiplied by ordinary resident overflow share; Default rate; retained overcrowding principle. Source: #1668 balance.md at 605277df."+ "basis": "Agreed"+ "note": "Reception, housing and shortages: condition pp per turn multiplied by ordinary resident overflow share; under gdd-0.3 in place of R-HOUSE-002's overflow_condition_loss 0.15 (R-HOUSE-005, #1703). Owner, 2 November 2026: \"Yes, 5 pp under GDD 0.3 (Recommended)\"; Agreed; retained overcrowding principle. Source: #1668 balance.md at 605277df.""values": [5]"housing.max_deterioration":"basis": "Default"diff --git a/docs/gdd/balance.md b/docs/gdd/balance.mdindex 65052cd2d..e741029b6 100644--- a/docs/gdd/balance.md+++ b/docs/gdd/balance.md@@ -92,10 +92,10 @@ Amir's farmer/pioneer work XP, counting actual qualifying turns and allowing pro| `reception.basic_credit` | `3` | reception turns credited by completed basic military training | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists it as `3` (basis Agreed, transcribed from #1668); live conversion follows `R-CITY-004` (`docs/rules/mvp.md:105`); the reception model is post-MVP (owner, 1 November 2026, "Keep R-CITY-004 (Recommended)") [S12] || `housing.condition_max` | `1` | unitless fraction; display as percent | Agreed || `start.housing_condition` | `0.35` | unitless fraction; one starting condition for every city | Owner, 1 November 2026, 27M-16: "0.35, your 15 Oct value (Recommended)" [S12]; main's `mvp.housing_start_condition` (`R-HOUSE-001`, `Q-START-3`); `content/gdd03-balance.yaml` holds this `0.35`, Agreed (#2115), in place of #1668's Default of 70 percentage points per region (unitless) |-| `housing.money_threshold` / `housing.money_slope` | `0.50 / 1` | condition fraction / Money per resident per fraction below threshold | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists `housing.money_threshold` / `housing.money_slope` as `0.50 / 1` (basis Agreed, transcribed from #1668) for the inactive `gdd-0.3` housing arithmetic (`docs/rules/mvp.md:133`); live housing follows `R-HOUSE-001` to `R-HOUSE-004` |-| `housing.cohesion_threshold` | `0.25` | condition fraction below which cohesion declines | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists `housing.cohesion_threshold` as `0.25` (basis Agreed, transcribed from #1668) for the inactive `gdd-0.3` housing arithmetic (`docs/rules/mvp.md:133`); live housing follows `R-HOUSE-001` to `R-HOUSE-004` |-| `housing.max_cohesion_loss` | `2` | national displayed points per turn at maximal weighted severity | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists `housing.max_cohesion_loss` as `2` (basis Agreed, transcribed from #1668) for the inactive `gdd-0.3` housing arithmetic (`docs/rules/mvp.md:133`); live housing follows `R-HOUSE-001` to `R-HOUSE-004` |-| `housing.overflow_deterioration` | `5` | condition pp per turn multiplied by ordinary-resident overflow share | Default (non-operative; not an owner ruling) |+| `housing.money_threshold` / `housing.money_slope` | `0.50 / 0.1` | condition fraction / Money per housed population unit per condition fraction below the threshold, a turn | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; the owner scaled the slope from #1668's `1` to the unit size on 2 November 2026: "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as #2112 did for Industry), about 7.6 Money a turn at start." [S15]. `content/gdd03-balance.yaml` lists them as `0.50 / 0.1` (basis Agreed). Under `gdd-0.3` they are live, per city, through `R-HOUSE-005` (`docs/rules/mvp.md:143`): the opening turn charges 7.665 Money; `gdd-0.1` and legacy housing follow `R-HOUSE-001` to `R-HOUSE-004` (unitless) |+| `housing.cohesion_threshold` | `0.25` | condition fraction below which cohesion declines | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists `housing.cohesion_threshold` as `0.25` (basis Agreed, transcribed from #1668); live under `gdd-0.3` through `R-HOUSE-005` (`docs/rules/mvp.md:143`), the issue's term, kept by the owner on 2 November 2026: "Keep the 2-point loss (Recommended)"; the option read: "As issue #1703 specifies, GDD 0.3 only."; `gdd-0.1` and legacy housing follow `R-HOUSE-001` to `R-HOUSE-004` [S15] (unitless) |+| `housing.max_cohesion_loss` | `2` | national displayed points per turn at maximal weighted severity | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists `housing.max_cohesion_loss` as `2` (basis Agreed, transcribed from #1668); live under `gdd-0.3` through `R-HOUSE-005` (`docs/rules/mvp.md:143`), the issue's term, kept by the owner on 2 November 2026: "Keep the 2-point loss (Recommended)"; the option read: "As issue #1703 specifies, GDD 0.3 only."; `gdd-0.1` and legacy housing follow `R-HOUSE-001` to `R-HOUSE-004` [S15] (unitless) |+| `housing.overflow_deterioration` | `5` | condition pp per turn multiplied by ordinary-resident overflow share | Owner, 2 November 2026 (Q1): "Yes, 5 pp under GDD 0.3 (Recommended)". Live under `gdd-0.3` only through `R-HOUSE-005` (`docs/rules/mvp.md:143`), in place of `R-HOUSE-002`'s `overflow_condition_loss` `0.15`; `gdd-0.1` and legacy keep `0.15`. `content/gdd03-balance.yaml` lists it as `5`, basis Agreed with the ruling in its note [S15] (unitless) || `housing.max_deterioration` | `10` | condition pp per turn with all housing upkeep unpaid | Amir's proposal, declined by the owner on 30 October 2026 [S1] (non-operative; basis Default in `content/gdd03-balance.yaml`, #2115) || `transit.cost` | `0.50` | Money per civilian population unit ending turn in transit | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists `transit.cost` as `0.50`, basis Default and not operative in the MVP (#2115); main has no live transit charge, and transit is post-MVP (owner, 1 November 2026: "30 Oct wins for the MVP (Recommended)") [S12] || `reception.queue_cohesion_loss` | `1` | national displayed point with a port reception queue | Amir's proposal; the owner's 30 October 2026 conflict review did not rule on this [S11]; `content/gdd03-balance.yaml` lists `reception.queue_cohesion_loss` as `1`, basis Default and not operative in the MVP (#2115); main has no live port queue, and port queues are post-MVP (owner, 1 November 2026: "30 Oct wins for the MVP (Recommended)") [S12] |@@ -204,6 +204,7 @@ Historical census estimates, real camp opening dates, authored region borders, a- [S12] Owner's 1 November 2026 answers, [GDD 1 November 2026 answers](../GDD.md#1-november-2026-answers).- [S13] Owner's 2 November 2026 ruling on #813, "Spend the dollars (Recommended)", [GDD later rulings, 2 November 2026](../GDD.md#later-rulings-2-november-2026); the $100m is the Export-Import Bank's 1949 credit (FRUS 1949 vol. VI, editorial note d407).- [S14] Israel's dollar rates, 1948-1952: IMF, Annual Report 1950, Appendix I, pp. 88-89; Federal Reserve Bulletin, November 1949, p. 1336; Michaely, *Israel's Foreign Exchange Rate System* (1971), p. 10 and Table 2-1; Patinkin, *The Israel Economy: The First Decade*, Table 43, p. 121 ([#813](https://github.com/eyalgolan/statecraft-israel/issues/813#issuecomment-6565039439), checked 2026-11-02).+- [S15] Owner's 2 November 2026 ruling on the housing surcharge slope (#1703), recorded in `content/gdd03-balance.yaml` (`housing.money_slope`) and `docs/rules/mvp.md` (`R-HOUSE-005`); and the owner's 2 November 2026 answers on #2291, "Yes, 5 pp under GDD 0.3 (Recommended)" for the overflow and "Keep the 2-point loss (Recommended)" for the cohesion term, recorded in `docs/rules/mvp.md` (`R-HOUSE-005`).## Open questionsdiff --git a/docs/gdd/cities.md b/docs/gdd/cities.mdindex 3bc81e9fc..c82d81050 100644--- a/docs/gdd/cities.md+++ b/docs/gdd/cities.md@@ -43,7 +43,7 @@ Farm work, Industry, building, teaching, courses and active service cannot run s### Housing and condition-**Amir's proposal, declined by the owner on 30 October 2026 (Regional pooling and Upkeep conflicts, option A) [S1]:** the regional-capacity model, regional resident formula and proportional housing upkeep are non-operative. For housing-only shortfall effects, the owner's 30 October 2026 conflict review did not rule; borrowing under `R-MONEY-003` (`docs/rules/mvp.md:399`) stays operative (owner, 1 November 2026, D1) [S21]. Every city starts at the one housing condition 0.35 (`R-HOUSE-001`; owner, 1 November 2026, 27M-16: "0.35, your 15 Oct value (Recommended)") [S21] (unitless). A housing repair costs 0.5 Money and 1 work and raises the condition by 10 percentage points, a labelled design value (owner, 1 November 2026, "Fixed price 0.5 Money + 1 work") [S21]. The retained per-city housing, refugee-conversion and exhausted-resource defeat rules control.+**Amir's proposal, declined by the owner on 30 October 2026 (Regional pooling and Upkeep conflicts, option A) [S1]:** the regional-capacity model, regional resident formula and proportional housing upkeep are non-operative. For housing-only shortfall effects, the owner's 30 October 2026 conflict review did not rule; borrowing under `R-MONEY-003` (`docs/rules/mvp.md:399`) stays operative (owner, 1 November 2026, D1) [S21]. Every city starts at the one housing condition 0.35 (`R-HOUSE-001`; owner, 1 November 2026, 27M-16: "0.35, your 15 Oct value (Recommended)") [S21] (unitless). A housing repair costs 0.5 Money and 1 work and raises the condition by 10 percentage points, a labelled design value (owner, 1 November 2026, "Fixed price 0.5 Money + 1 work") [S21]. The retained per-city housing, refugee-conversion and exhausted-resource defeat rules control. Under `gdd-0.3` the per-city housing rules add `R-HOUSE-005` (`docs/rules/mvp.md:143`): a surcharge of 0.1 Money per housed unit per condition fraction below 0.50, priced before the turn's deterioration (owner, 2 November 2026: "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as #2112 did for Industry), about 7.6 Money a turn at start."), 5 pp overflow deterioration in place of `R-HOUSE-002`'s `0.15`, and a Social cohesion loss of up to 2 points a turn below 0.25. The owner ruled on both on 2 November 2026: the 5 pp overflow, "Yes, 5 pp under GDD 0.3 (Recommended)", and the cohesion term, "Keep the 2-point loss (Recommended)" (the option read: "As issue #1703 specifies, GDD 0.3 only.") [S22].### City projects and builders@@ -116,6 +116,7 @@ Individual workforce screens per kibbutz, enemy resident workforce, mothballing,- [S19] Population eligibility, docs/gdd/training.md.- [S20] Retained availability/winery decisions, docs/superpowers/plans/2026-10-15-gdd-phase-3.md, historical Q-HOUSE-3 and Q-SPEC-1/2.- [S21] Owner's 1 November 2026 answers, [GDD 1 November 2026 answers](../GDD.md#1-november-2026-answers).+- [S22] Owner's 2 November 2026 ruling on the housing surcharge slope (#1703), recorded in `content/gdd03-balance.yaml` (`housing.money_slope`) and `docs/rules/mvp.md` (`R-HOUSE-005`); and the owner's 2 November 2026 answers on #2291, "Yes, 5 pp under GDD 0.3 (Recommended)" for the overflow and "Keep the 2-point loss (Recommended)" for the cohesion term, recorded in `docs/rules/mvp.md` (`R-HOUSE-005`).## Open questionsdiff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 32c8f2854..1d3c91988 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -128,18 +128,20 @@ R-CITY-007: A city starts with `civilians` = `people / people_per_unit` to the nR-HOUSE-001: Each city has a housing condition from 0 to 1, an average over the city (D-D2, Q-HOUSE-2, owner, 15 October 2026). Every city starts at `mvp.housing_start_condition` (Q-START-3: one design value for all the cities, 0.35, `model.yaml`'s `housing` base). The condition is per city: one city's counts never change another's. It is in the state hash (R-LOOP-002).-For R-HOUSE-001, the preceding legacy/gdd-0.1 wording remains unchanged. The inactive gdd-0.3 cross-reference is `Gdd03HousingFormula`, detached synthetic arithmetic with an explicit condition input, no initial condition or state commit (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:5-6@7ec122145`). It snapshots labelled Agreed/Default catalogue scalars, preserves the Default basis of overflow deterioration, and refuses missing, Deferred, unlabelled or malformed required scalars and incompatible catalogue identity. Condition is bounded to 0..1 after deterioration and each explicit project effect; repair uses the catalogue's condition-pp part without implementing repair cost, work or availability (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:13-62@7ec122145`, `:80-103`; `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:78-98@7ec122145`, `:119-141`). Source: `docs/gdd/cities.md:27@605277dfa511dc512562ececeb273b8393b21d35`, `"Project capacity/condition effects live in [balance](balance.md#project-catalogue), clamped to condition bounds."` (quoted verbatim from that pinned file; its balance.md is not in this repository) Initial-condition integration remains pending: the #1703 status comment of 27 October 2026 leaves initial-condition and resident-policy questions with #1668, "rather than becoming fallback values".+For R-HOUSE-001, the preceding legacy/gdd-0.1 wording remains unchanged. The inactive gdd-0.3 cross-reference is `Gdd03HousingFormula`, detached synthetic arithmetic with an explicit condition input, no initial condition or state commit (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:5-6@7ec122145`). It snapshots labelled Agreed/Default catalogue scalars, preserves the Default basis of overflow deterioration, and refuses missing, Deferred, unlabelled or malformed required scalars and incompatible catalogue identity. Condition is bounded to 0..1 after deterioration and each explicit project effect; repair uses the catalogue's condition-pp part without implementing repair cost, work or availability (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:13-62@7ec122145`, `:80-103`; `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:78-98@7ec122145`, `:119-141`). Source: `docs/gdd/cities.md:27@605277dfa511dc512562ececeb273b8393b21d35`, `"Project capacity/condition effects live in [balance](balance.md#project-catalogue), clamped to condition bounds."` (quoted verbatim from that pinned file; its balance.md is not in this repository) Initial-condition integration remains pending: the #1703 status comment of 27 October 2026 leaves initial-condition and resident-policy questions with #1668, "rather than becoming fallback values". Under `gdd-0.3` the live game now starts every city at the same `mvp.housing_start_condition` 0.35 (27M-16, owner-approved 1 November 2026: "Uniform: one value for every city, 0.35."), and the condition moves by R-HOUSE-005 (#1703).R-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, PreArrivalResidents - Capacity) / PreArrivalResidents`; unpaid loss is `(max_deterioration / 100) * (UpkeepDue - UpkeepPaid) / UpkeepDue`. Zero pre-arrival 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:65-85@7ec122145`; worked-number, distinct-count, post-deterioration and zero-denominator fixtures in `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:16-75@7ec122145`). Source: `docs/gdd/cities.md:29-35@605277dfa511dc512562ececeb273b8393b21d35`; #1703 says, "Price the surcharge from pre-deterioration condition, then deteriorate once, then apply cohesion once." These are returned calculations only: Money settlement (#1702), repairs (#1700), national indicator application and removal of duplicate legacy penalties (#1715), and monthly snapshot/commit-once timing (#1716) remain pending under the #1703 status comment; the preceding active rule is unchanged.+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, PreArrivalResidents - Capacity) / PreArrivalResidents`; unpaid loss is `(max_deterioration / 100) * (UpkeepDue - UpkeepPaid) / UpkeepDue`. Zero pre-arrival 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:65-85@7ec122145`; worked-number, distinct-count, post-deterioration and zero-denominator fixtures in `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:16-75@7ec122145`). 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 (#1700) and monthly snapshot timing (#1716) remain 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, pre-arrival and cohesion resident counts plus own population; it selects no residents and substitutes none of those counts for another (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:68-85@7ec122145`, `:107-125`; `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:39-47@7ec122145`). 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 says, "use pre-arrival residents for overcrowding deterioration". Those are producer requirements, not resident-selection behavior implemented here. Live status selection (#1689), regions/approved housing locations (#1690/#1691) 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.+For R-HOUSE-003, the inactive gdd-0.3 helper takes independently supplied surcharge, pre-arrival and cohesion resident counts plus own population; it selects no residents and substitutes none of those counts for another (`sim/Statecraft.Sim/Gdd03HousingFormula.cs:68-85@7ec122145`, `:107-125`; `sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs:39-47@7ec122145`). 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 says, "use pre-arrival residents for overcrowding deterioration". Those are producer requirements, not resident-selection behavior implemented here. Live status selection (#1689), regions/approved housing locations (#1690/#1691) 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."). `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).+R-HOUSE-005: Under `gdd-0.3` only (#1703, the MVP's per-city housing condition), the housing step after R-CITY-004 settles, in #1703's order ("Price the surcharge from pre-deterioration condition, then deteriorate once, then apply cohesion once."), for every city with a condition, with R its housed people (R-HOUSE-003) and P all own population (every city's housed people and refugees plus the strength of every player unit, halutz units included): (1) a surcharge of `R * max(0, money_threshold - c) * money_slope` Money a turn from the condition c before this turn's deterioration, summed over the cities into one Money line (`housing_surcharge`) and borrowed when the Treasury is short (R-MONEY-003); `money_threshold` is 0.50 and `money_slope` is 0.1 Money per housed population unit (owner, 2 November 2026: "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as #2112 did for Industry), about 7.6 Money a turn at start."), so the shipped census start charges 511 housed units x 0.15 x 0.1 = 7.665 Money on the opening turn; (2) overflow deterioration of `overflow_deterioration * max(0, R - housing_capacity) / R` percentage points (5 pp; owner, 2 November 2026: "Yes, 5 pp under GDD 0.3 (Recommended)"), never below 0, in place of R-HOUSE-002's `overflow_condition_loss`; zero housed loses nothing; (3) a Social cohesion loss of `max_cohesion_loss * sum((R / P) * max(0, (cohesion_threshold - c') / cohesion_threshold))` displayed points (`max_cohesion_loss` 2, `cohesion_threshold` 0.25; owner, 2 November 2026: "Keep the 2-point loss (Recommended)") from the condition c' after deterioration, applied once to `morale` through its permanent shift with one cause line (`housing_cohesion`); zero own population loses nothing. The legacy `homes_lift_morale` link from `housing` into `morale` adds nothing under `gdd-0.3`, so housing lowers Social cohesion only through (3) (#1703 Done-when, with #1715; the Food term stays #1715's). There is no housing upkeep (27M-17, IL 0m), so no unpaid-upkeep deterioration. Values: `content/gdd03-balance.yaml` (`housing.*`), read by `Gdd03HousingFormula`; code: `Cities.UpdateCondition` and `Cities.SettleGdd03`, `EffectsSystem.RetiredGdd03Link`; tests: `Gdd03HousingConditionTests`, `Gdd03MoneyLedgerTests`. The issue's three rules run under `gdd-0.3`: the 5 pp overflow (owner, 2 November 2026: "Yes, 5 pp under GDD 0.3 (Recommended)") and the cohesion term (owner, 2 November 2026: "Keep the 2-point loss (Recommended)"; the option read: "As issue #1703 specifies, GDD 0.3 only."). P is the 12 cities' people as built, plus the player units (owner, 2 November 2026: "The 12 cities' people (Recommended)"; the option read: "As built: only the cities whose housing is tracked."). R is counted after the step's housing arrivals (owner, 2 November 2026: "After housing arrivals (Recommended)"; 27M-15). Formations not housed is a default pending the owner's confirmation on #1703; repairs wait on #1700.+## City projectsA city project is built in a city (GDD "Cities and construction"; Phase 3 PR 4, #735). The kinds are in `content/projects.yaml`, every number a design value (Q-PROJ-1, Q-PROJ-5, owner, 15 October 2026, #375: "Take all recommendations", with agent-proposed values the owner may override): permanent housing (`housing`), the transit camp (`transit_camp`, D-D3, Q-HOUSE-3) and `industry`, and, under gdd-0.3 only, the arms workshop (`arms_workshop`, R-ARMS-004). They replace the legacy map actions, which the GDD loop refuses (R-PROJ-004).diff --git a/sim/Statecraft.Sim.Tests/DesignValuesGdd03Tests.cs b/sim/Statecraft.Sim.Tests/DesignValuesGdd03Tests.csindex 8dc73f2ee..e617f01e9 100644--- a/sim/Statecraft.Sim.Tests/DesignValuesGdd03Tests.cs+++ b/sim/Statecraft.Sim.Tests/DesignValuesGdd03Tests.cs@@ -197,6 +197,7 @@ public partial class DesignValuesTests[InlineData("transit.cost", "Default", "0.50", PostMvp, Nov1)][InlineData("reception.queue_cohesion_loss", "Default", "1", PostMvp, Nov1)][InlineData("housing.max_deterioration", "Default", "10", "declined by the owner", Oct30)]+ [InlineData("housing.overflow_deterioration", "Agreed", "5", "\"Yes, 5 pp under GDD 0.3 (Recommended)\"", "2 November 2026")]public void Gdd03RowsFollowTheOwnersLaterRulings(string key, string basis, string values, string ruling, string date){var row=ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!.Values[key];@@ -294,5 +295,18 @@ public partial class DesignValuesTestsAssert.Contains(basis,row.Note);Assert.Contains("Source: #1668 balance.md at 605277df.",row.Note);}+ // R-HOUSE-005, #1703 (owner, 2 November 2026: "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as+ // #2112 did for Industry), about 7.6 Money a turn at start."): the surcharge's slope is 0.1 Money per housed unit.+ [Fact]+ public void Gdd03HousingSurchargeSlopeIsScaledToUnitSize()+ {+ var row=ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!.Values["housing.money_slope"];+ Assert.Equal("Agreed",row.Basis);+ Assert.Equal(new[]{0.1m},row.Values);+ Assert.Contains("\"Scale it to unit size (Recommended)\"",row.Note);+ Assert.Contains("2 November 2026",row.Note);+ Assert.Contains("design value",row.Note);+ Assert.Contains("Source: #1668 balance.md at 605277df.",row.Note);+ }}diff --git a/sim/Statecraft.Sim.Tests/Gdd03HousingConditionTests.cs b/sim/Statecraft.Sim.Tests/Gdd03HousingConditionTests.csnew file mode 100644index 000000000..3334093d4--- /dev/null+++ b/sim/Statecraft.Sim.Tests/Gdd03HousingConditionTests.cs@@ -0,0 +1,246 @@+using System;+using System.Collections.Generic;+using System.Linq;+using Statecraft.Sim;++/// <summary>#1703 (GDD 0.3, the MVP's per-city housing condition), gdd-0.3 only: the surcharge, the cohesion term and the+/// 5 pp overflow (R-HOUSE-002, R-HOUSE-005), housed without formations (R-HOUSE-003, 27M-18), and gdd-0.1 unchanged. The+/// real-content tests run the shipped content with only eras.yaml's ruleset switched to gdd-0.3 (Gdd03MoneyLedgerTests'+/// pattern); the synthetic ones put their own counts and condition on a real city id.</summary>+public class Gdd03HousingConditionTests+{+ static readonly Content Real03 = Load(true);+ static readonly Content Real01 = Load(false);++ static Content Load(bool gdd03)+ {+ var root = RealContentTests.ContentRoot();+ return ContentLoader.Load(rel =>+ {+ var path = System.IO.Path.Combine(root, rel);+ var text = System.IO.File.Exists(path) ? System.IO.File.ReadAllText(path) : null;+ return gdd03 && rel == "eras.yaml" ? text!.Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3") : text;+ }, System.IO.Directory.GetFiles(System.IO.Path.Combine(root, "events"), "*.yaml").Select(p => "events/" + System.IO.Path.GetFileName(p)));+ }++ const double Tolerance = 1e-9;++ /// <summary>A new game of <paramref name="c"/> with one city only (the first city's id), with no training groups and no+ /// units: <paramref name="civilians"/> civilians, <paramref name="refugees"/> refugees, <paramref name="capacity"/> housing+ /// and <paramref name="condition"/>. TEST-ONLY SYNTHETIC counts.</summary>+ static GameState OneCity(Content c, int civilians, int capacity, double condition, int refugees = 0)+ {+ var s = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);+ var id = s.Cities.Keys.First();+ s.Cities.Clear(); s.Cohorts.Clear(); s.Units.Clear();+ s.Cities[id] = new City(id, capacity, 0, civilians, 0, refugees, condition: condition);+ return s;+ }++ static List<Cause> UpdateCondition(Content c, GameState s)+ {+ var why = new List<Cause>();+ Cities.UpdateCondition(c, s, c.RulesAt(s.Date).Mvp!, why);+ return why;+ }++ // R-HOUSE-002 (#1703 Q1, owner, 2 November 2026: "Yes, 5 pp under GDD 0.3 (Recommended)"): housed 10 over a+ // capacity of 8 loses 5 pp x 2/10 = 0.01 of condition under gdd-0.3; gdd-0.1 keeps overflow_condition_loss 0.15, so 0.15 x 2/10 = 0.03.+ [Fact]+ public void Gdd03OverflowLosesFivePpTimesTheOverflowShare()+ {+ var s = OneCity(Real03, civilians: 10, capacity: 8, condition: 0.60);+ UpdateCondition(Real03, s);+ Assert.Equal(0.59, s.Cities.Values.Single().Condition!.Value, 12);++ var legacy = OneCity(Real01, civilians: 10, capacity: 8, condition: 0.60);+ UpdateCondition(Real01, legacy);+ Assert.Equal(0.57, legacy.Cities.Values.Single().Condition!.Value, 12);+ }++ // R-HOUSE-002: zero housed has no overflow share, so it loses nothing.+ [Fact]+ public void Gdd03ZeroHousedLosesNothing()+ {+ var s = OneCity(Real03, civilians: 0, capacity: 0, condition: 0.60, refugees: 3);+ UpdateCondition(Real03, s);+ Assert.Equal(0.60, s.Cities.Values.Single().Condition!.Value);+ }++ // R-HOUSE-005 (owner, 2 November 2026, "Scale it to unit size (Recommended)": 0.1 Money per unit): the surcharge is+ // housed x max(0, 0.50 - condition) x 0.1 a turn, one Money line (Target treasury) and borrowed when the Treasury is short.+ // 10 housed at 0.35: 10 x 0.15 x 0.1 = 0.15.+ [Fact]+ public void Gdd03SurchargeIsATenthOfMoneyPerUnitBelowHalfCondition()+ {+ var s = OneCity(Real03, civilians: 10, capacity: 10, condition: 0.35);+ s.Treasury = 0; s.Debt = 0;+ var why = UpdateCondition(Real03, s);+ var line = Assert.Single(why, w => w.Key == CauseKeys.HousingSurcharge);+ Assert.Equal("treasury", line.Target);+ Assert.Equal(-0.15, line.Delta, 12);+ Assert.True(EconomySystem.MovesMoney(line));+ var borrowed = Assert.Single(why, w => w.Key == CauseKeys.Borrowed);+ Assert.Equal(CauseKeys.Purpose.HousingSurcharge, borrowed.Args[0]);+ Assert.Equal(0.15, s.Debt, 12);+ Assert.Equal(0.0, s.Treasury);+ }++ // R-HOUSE-005, #1703 ("Price the surcharge from pre-deterioration condition, then deteriorate once"): 10 housed in no+ // housing at 0.49 lose 5 pp (to 0.44); the surcharge is priced at 0.49: 10 x 0.01 x 0.1 = 0.01, not 10 x 0.06 x 0.1.+ [Fact]+ public void Gdd03SurchargeIsPricedBeforeTheTurnsDeterioration()+ {+ var s = OneCity(Real03, civilians: 10, capacity: 0, condition: 0.49);+ s.Treasury = 100;+ var why = UpdateCondition(Real03, s);+ Assert.Equal(0.44, s.Cities.Values.Single().Condition!.Value, 12);+ Assert.Equal(-0.01, Assert.Single(why, w => w.Key == CauseKeys.HousingSurcharge).Delta, 12);+ Assert.Equal(100 - 0.01, s.Treasury, 12);+ }++ // R-HOUSE-005: at or above 0.50 there is no surcharge and no line.+ [Fact]+ public void Gdd03NoSurchargeAtHalfConditionOrAbove()+ {+ var s = OneCity(Real03, civilians: 10, capacity: 10, condition: 0.50);+ var t = s.Treasury;+ Assert.DoesNotContain(UpdateCondition(Real03, s), w => w.Key == CauseKeys.HousingSurcharge);+ Assert.Equal(t, s.Treasury);+ }++ // R-HOUSE-005 (#1703, the cohesion term; owner, 2 November 2026: "Keep the 2-point loss (Recommended)"):+ // 2 x sum((R/P) x max(0, (0.25 - c) / 0.25)) points, from the condition after the turn's deterioration, applied once.+ // One city with all the population at 0.125: 2 x 1 x 0.5 = 1 point, so Social cohesion (morale) falls by 0.01.+ [Fact]+ public void Gdd03CohesionLosesTwoPointsAtMostWeightedByResidents()+ {+ var s = OneCity(Real03, civilians: 10, capacity: 10, condition: 0.125);+ var before = s.Indicators["morale"];+ var why = UpdateCondition(Real03, s);+ var line = Assert.Single(why, w => w.Key == CauseKeys.HousingCohesion);+ Assert.Equal("morale", line.Target);+ Assert.Equal(-0.01, line.Delta, 12);+ Assert.Equal(before - 0.01, s.Indicators["morale"], 12);+ }++ // R-HOUSE-005: P is all own population, so refugees (not housed, 27M-18) weigh the city's residents down: 10 housed of+ // 20 at 0.125 is 2 x 0.5 x 0.5 = 0.5 points. At or above 0.25 there is no loss and no line.+ [Fact]+ public void Gdd03CohesionWeighsResidentsOverAllOwnPopulation()+ {+ var s = OneCity(Real03, civilians: 10, capacity: 10, condition: 0.125, refugees: 10);+ Assert.Equal(-0.005, Assert.Single(UpdateCondition(Real03, s), w => w.Key == CauseKeys.HousingCohesion).Delta, 12);+ var fine = OneCity(Real03, civilians: 10, capacity: 10, condition: 0.25);+ Assert.DoesNotContain(UpdateCondition(Real03, fine), w => w.Key == CauseKeys.HousingCohesion);+ }++ // R-HOUSE-005, #1703 Done-when "the legacy homes link is off (#1715)": under gdd-0.3 homes_lift_morale adds nothing to+ // Social cohesion, so the cohesion term is the only housing penalty; gdd-0.1 keeps the link.+ [Fact]+ public void Gdd03TurnsTheLegacyHomesLinkOff()+ {+ var s = Simulation.NewGame(Real03, GoldenRun.Seed, Mode.Historical);+ for (int t = 0; t < 3; t++) s = Simulation.Step(Real03, s, Array.Empty<Command>()).State;+ Assert.Equal(0.0, s.EffectContributions["homes_lift_morale"]);++ var legacy = Simulation.NewGame(Real01, GoldenRun.Seed, Mode.Historical);+ for (int t = 0; t < 3; t++) legacy = Simulation.Step(Real01, legacy, Array.Empty<Command>()).State;+ Assert.NotEqual(0.0, legacy.EffectContributions["homes_lift_morale"]);+ }++ // R-HOUSE-003 (27M-18, owner-approved 1 November 2026: "Housed = civilians, craftsmen, recruits and groups in training.+ // Refugees and pioneer units are not housed."): under gdd-0.3 a city's formations are not housed; gdd-0.1 still counts+ // them (Q-HOUSE-5).+ [Fact]+ public void Gdd03FormationsAreNotHousedButGdd01StillCountsThem()+ {+ foreach (var (c, counted) in new[] { (Real03, false), (Real01, true) })+ {+ var s = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);+ var x = s.Cities.Values.First();+ var type = c.UnitTypes.First(u => u.Side == "israel" && u.Id != "halutz").Id;+ var home = new Unit(9999, type, 0, 0, side: "israel", strength: 3, homeCity: x.Id);+ s.Units[home.Id] = home;+ var people = x.Civilians + x.Craftsmen + x.Recruits + s.Cohorts.Values.Where(k => k.City == x.Id).Sum(k => k.Count);+ Assert.True(Cities.Soldiers(s, x) >= 3, c.Ruleset);+ Assert.Equal(counted ? people + Cities.Soldiers(s, x) : people, Cities.Housed(s, x));+ }+ }++ // R-HOUSE-005 (owner, 2 November 2026, "Scale it to unit size (Recommended)"; the option read: "0.1 per unit (as #2112+ // did for Industry), about 7.6 Money a turn at start."): the opening turn of the real gdd-0.3 game charges every city's+ // housed x (0.50 - 0.35) x 0.1, about 7.6 Money.+ [Fact]+ public void Gdd03OpeningTurnSurchargeIsAboutSevenPointSixMoney()+ {+ var s = Simulation.NewGame(Real03, GoldenRun.Seed, Mode.Historical);+ Assert.All(s.Cities.Values, x => Assert.Equal(0.35, x.Condition!.Value));+ var r = Simulation.Step(Real03, s, Array.Empty<Command>());+ // Nothing after step 8 changes who is housed under gdd-0.3 (step 9's arrivals are refugees, and formations do not count).+ var housed = r.State.Cities.Values.Sum(x => Cities.Housed(r.State, x));+ var line = Assert.Single(r.Why, w => w.Key == CauseKeys.HousingSurcharge);+ Assert.Equal(-housed * 0.15 * 0.1, line.Delta, 9);+ // The shipped census start: 511 housed units x 0.15 x 0.1 = 7.665 Money (the ruling's "about 7.6").+ Assert.Equal(511, housed);+ Assert.Equal(-7.665, line.Delta, 9);+ }++ // R-HOUSE-005 in double, the sim's state type (docs/determinism.md: doubles are hashed as IEEE bits). The opening+ // surcharge is each city's housed x (0.50 - 0.35) x 0.1, summed in double in ordinal city order. Its exact IEEE value+ // is 7.665000000000002 (bits 0x401EA8F5C28F5C2B), not the double nearest 7.665 (0x401EA8F5C28F5C29), which a decimal+ // round trip of the city's double condition gave. Computed independently with python3 floats over cities.yaml's 12+ // cities (511 housed units).+ [Fact]+ public void Gdd03OpeningSurchargeIsTheExactDoubleSumOfTheCities()+ {+ var r = Simulation.Step(Real03, Simulation.NewGame(Real03, GoldenRun.Seed, Mode.Historical), Array.Empty<Command>());+ var line = Assert.Single(r.Why, w => w.Key == CauseKeys.HousingSurcharge);+ Assert.Equal(0x401EA8F5C28F5C2BL, BitConverter.DoubleToInt64Bits(-line.Delta));+ }++ // R-HOUSE-005 in a whole gdd-0.3 turn: with every city below cohesion_threshold, the cohesion loss settles once, as one+ // housing_cohesion line on morale, however many cities contribute (#1703: "then apply cohesion once").+ [Fact]+ public void Gdd03WholeTurnHasExactlyOneHousingCohesionLine()+ {+ var s = Simulation.NewGame(Real03, GoldenRun.Seed, Mode.Historical);+ foreach (var id in s.Cities.Keys.ToList()) s.Cities[id] = s.Cities[id].WithCondition(0.10); // TEST-ONLY SYNTHETIC condition+ Assert.True(s.Cities.Count > 1);+ var r = Simulation.Step(Real03, s, Array.Empty<Command>());+ var line = Assert.Single(r.Why, w => w.Key == CauseKeys.HousingCohesion);+ Assert.Equal("morale", line.Target);+ Assert.True(line.Delta < 0, line.Delta.ToString(System.Globalization.CultureInfo.InvariantCulture));+ }++ // R-HOUSE-005 on the live path, where the turn's deterioration crosses cohesion_threshold: 10 housed in no housing at+ // 0.27 lose 5 pp to 0.22. The surcharge is priced at 0.27 (10 x 0.23 x 0.1 = 0.23 Money); the cohesion term reads+ // the 0.22 after deterioration: 2 x (10 / 10) x (0.25 - 0.22) / 0.25 = 0.24 points, so morale falls by 0.0024. Priced+ // from 0.27 instead, there would be no cohesion loss at all.+ [Fact]+ public void Gdd03DeteriorationBelowTheCohesionThresholdCostsCohesionThatTurn()+ {+ var s = OneCity(Real03, civilians: 10, capacity: 0, condition: 0.27);+ s.Treasury = 100;+ var before = s.Indicators["morale"];+ var why = UpdateCondition(Real03, s);+ Assert.Equal(0.22, s.Cities.Values.Single().Condition!.Value, 12);+ Assert.Equal(-0.23, Assert.Single(why, w => w.Key == CauseKeys.HousingSurcharge).Delta, 12);+ Assert.Equal(100 - 0.23, s.Treasury, 12);+ Assert.Equal(-0.0024, Assert.Single(why, w => w.Key == CauseKeys.HousingCohesion).Delta, 12);+ Assert.Equal(before - 0.0024, s.Indicators["morale"], 12);+ }++ // gdd-0.1 unchanged: a whole turn has no surcharge and no cohesion line.+ [Fact]+ public void Gdd01HasNoSurchargeAndNoCohesionLine()+ {+ var s = Simulation.NewGame(Real01, GoldenRun.Seed, Mode.Historical);+ var r = Simulation.Step(Real01, s, Array.Empty<Command>());+ Assert.DoesNotContain(r.Why, w => w.Key == CauseKeys.HousingSurcharge || w.Key == CauseKeys.HousingCohesion);+ var low = OneCity(Real01, civilians: 10, capacity: 10, condition: 0.10);+ var t = low.Treasury; var m = low.Indicators["morale"];+ Assert.Empty(UpdateCondition(Real01, low));+ Assert.Equal((t, m), (low.Treasury, low.Indicators["morale"]));+ }+}diff --git a/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs b/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.csindex 1f10bd2a7..add96b9fd 100644--- a/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs+++ b/sim/Statecraft.Sim.Tests/Gdd03HousingFormulaTests.cs@@ -29,13 +29,13 @@ public class Gdd03HousingFormulaTests// R-HOUSE-001: catches moneyThreshold replaced by the shipped literal 0.50m.const decimal threshold = 0.70m;var f = FormulaWithSyntheticScalar("housing.money_threshold", threshold);- var expected = 10m * Math.Max(0m, threshold - 0.40m) * 1m;+ var expected = 10m * Math.Max(0m, threshold - 0.40m) * 0.1m; // the shipped money_slope, 0.1 since #1703 (owner, 2 November 2026)Assert.Equal(expected, f.Evaluate(Input(condition: 0.40m)).SurchargeMoney);}[Fact] public void SyntheticMoneySlopeComesFromSuppliedCatalogue(){- // R-HOUSE-001: catches moneySlope replaced by the shipped literal 1m.+ // R-HOUSE-001: catches moneySlope replaced by the shipped literal 0.1m.const decimal slope = 2.5m;var f = FormulaWithSyntheticScalar("housing.money_slope", slope);var expected = 10m * Math.Max(0m, 0.50m - 0.40m) * slope;@@ -102,7 +102,7 @@ public class Gdd03HousingFormulaTests{// R-HOUSE-001, R-HOUSE-002: price first, deteriorate once, return arithmetic only.var r = Formula().Evaluate(Input());- Assert.Equal(1m, r.SurchargeMoney);+ 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);@@ -111,7 +111,7 @@ public class Gdd03HousingFormulaTests}[Theory]- [InlineData("0.499", "0.01")]+ [InlineData("0.499", "0.001")] // 10 x 0.001 x money_slope 0.1 (#1703; was 0.01 at slope 1)[InlineData("0.50", "0")][InlineData("0.60", "0")]public void SurchargeIsContinuous(string condition, string expected)@@ -126,7 +126,7 @@ public class Gdd03HousingFormulaTests// R-HOUSE-002, R-HOUSE-003: does not select residents or settle timing.var r = Formula().Evaluate(Input(surcharge: 10, beforeArrival: 20,cohesion: 5, population: 20, capacity: 15m, condition: 0.125m, due: 0m, paid: 0m));- Assert.Equal(3.75m, r.SurchargeMoney);+ 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);Assert.Equal(0.275m, r.CohesionLossPoints);@@ -190,7 +190,7 @@ public class Gdd03HousingFormulaTestsInput(paid: -1m), Input(paid: 5m), Input(due: 0m, paid: 1m) })Assert.Throws<ArgumentOutOfRangeException>(() => f.Evaluate(input));Assert.Throws<ArgumentNullException>(() => f.Evaluate(null!));- Assert.Equal(1m, f.Evaluate(Input()).SurchargeMoney);+ Assert.Equal(0.1m, f.Evaluate(Input()).SurchargeMoney); // money_slope 0.1 (#1703; was 1)}[Theory]@@ -228,7 +228,12 @@ public class Gdd03HousingFormulaTests{var c = ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance ?? throw new InvalidOperationException("GDD 0.3 catalogue required");var f = Gdd03HousingFormula.FromCatalogue(c);- Assert.Equal("Default", f.OverflowBasis);+ // The shipped row is Agreed since the owner's 2 November 2026 ruling ("Yes, 5 pp under GDD 0.3 (Recommended)");+ // the reader carries whichever basis the row has, so a Default row still reads as Default.+ Assert.Equal("Agreed", f.OverflowBasis);+ var labelledDefault = ContentLoader.Load(RealContentTests.ContentRoot()).Gdd03Balance!;+ labelledDefault.Values["housing.overflow_deterioration"].Basis = "Default"; // TEST-ONLY SYNTHETIC provenance+ Assert.Equal("Default", Gdd03HousingFormula.FromCatalogue(labelledDefault).OverflowBasis);c.Values["housing.overflow_deterioration"].Values[0] = 99m; // TEST-ONLY SYNTHETIC mutationAssert.Equal(0.025m, f.Evaluate(Input()).OverflowConditionLoss);c.Ruleset = SaveGame.GddRuleset;@@ -236,6 +241,41 @@ public class Gdd03HousingFormulaTestsAssert.Throws<ArgumentNullException>(() => Gdd03HousingFormula.FromCatalogue(null!));}+ // 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+ // 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()+ {+ var formulas = new[]+ {+ Formula(),+ FormulaWithSyntheticScalar("housing.money_threshold", 0.70m),+ FormulaWithSyntheticScalar("housing.money_slope", 2.5m),+ FormulaWithSyntheticScalar("housing.cohesion_threshold", 0.50m),+ FormulaWithSyntheticScalar("housing.max_cohesion_loss", 3m),+ FormulaWithSyntheticScalar("housing.overflow_deterioration", 12.5m),+ };+ var conditions = new List<decimal> { 0m, 0.01m, 0.125m, 0.235m, 0.26m, 0.40m, 0.499m, 0.50m, 0.60m, 0.95m, 1m };+ for (int i = 0; i <= 60; i++) conditions.Add(i / 100m);+ var checkedCases = 0;+ foreach (var f in formulas)+ foreach (var population in new[] { 0, 10, 20, 511, 600 })+ foreach (var residents in new[] { 0, 1, 5, 10, 20, 248, 511 })+ foreach (var capacity in new[] { 0, 5, 8, 10, 15, 248 })+ foreach (var condition in conditions)+ {+ if (residents > population) continue;+ var d = f.Evaluate(new Gdd03HousingInput(residents, residents, residents, population, capacity, condition, 0m, 0m));+ 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);+ Assert.True(Math.Abs((double)d.ConditionAfter - live.ConditionAfter) <= 1e-9, "condition " + at);+ Assert.True(Math.Abs((double)d.CohesionLossPoints - live.Cohesion) <= 1e-9, "cohesion " + at);+ checkedCases++;+ }+ Assert.True(checkedCases > 10000, checkedCases.ToString(CultureInfo.InvariantCulture));+ }+// R-HOUSE-001: a valid numeric child cannot authorize an unresolved parent repair row.[Fact]public void ReaderRejectsDeferredRepairParentWithAnIntactNumericPart()diff --git a/sim/Statecraft.Sim.Tests/Gdd03MoneyLedgerTests.cs b/sim/Statecraft.Sim.Tests/Gdd03MoneyLedgerTests.csindex 83b9a3680..b1d1d6e34 100644--- a/sim/Statecraft.Sim.Tests/Gdd03MoneyLedgerTests.cs+++ b/sim/Statecraft.Sim.Tests/Gdd03MoneyLedgerTests.cs@@ -118,7 +118,8 @@ public class Gdd03MoneyLedgerTestsAssert.True(turns >= 40, $"the run lasts {turns} turns");Assert.Subset(paid, new HashSet<string> { CauseKeys.Purpose.Training, CauseKeys.Purpose.Project, CauseKeys.Purpose.Yishuv, CauseKeys.Purpose.Arms });Assert.Subset(borrowed, new HashSet<string> { CauseKeys.Purpose.Deficit, CauseKeys.Purpose.Project, CauseKeys.Purpose.Yishuv, CauseKeys.Purpose.Arms, CauseKeys.Purpose.Event });- Assert.Subset(keys, new HashSet<string> { CauseKeys.MoneyFlows, CauseKeys.WagesPaid, CauseKeys.MilitaryUpkeep, CauseKeys.Paid, CauseKeys.EventAmount, CauseKeys.DollarsConverted });+ Assert.Subset(keys, new HashSet<string> { CauseKeys.MoneyFlows, CauseKeys.WagesPaid, CauseKeys.MilitaryUpkeep, CauseKeys.Paid, CauseKeys.EventAmount, CauseKeys.DollarsConverted,+ CauseKeys.HousingSurcharge }); // #1703 (R-HOUSE-005): the housing surcharge is its own Money line, so it reconciles too// R-MONEY-002: civilian upkeep stays IL 0m under gdd-0.3 (the owner's 30 October 2026 "Keep ruling" on UPKEEP), so the// whole game, with its built yishuvim and housing, never charges it.Assert.DoesNotContain(CauseKeys.CivilianUpkeep, keys);diff --git a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.csindex e1fc306c1..eaaed0084 100644--- a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs+++ b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs@@ -115,7 +115,7 @@ public class RemainingCauseKeysTestssites++;}}- Assert.Equal(112, sites); // 112 with the arms workshops' five (R-ARMS-005 with its job-default line, R-ARMS-006; #1701); 107 with R-MONEY-004's DollarsConverted (#813); 106 since #2212: EconomySystem.OtherMoney's line (105 since #2199: PayOrBorrow's Paid line)+ Assert.Equal(114, sites); // 114 with #1703's gdd-0.3 housing surcharge and housing cohesion lines; 112 with the arms workshops' five (R-ARMS-005 with its job-default line, R-ARMS-006; #1701); 107 with R-MONEY-004's DollarsConverted (#813); 106 since #2212: EconomySystem.OtherMoney's line (105 since #2199: PayOrBorrow's Paid line)}[Fact]diff --git a/sim/Statecraft.Sim/Cause.cs b/sim/Statecraft.Sim/Cause.csindex c401a6ba3..f5cac29cd 100644--- a/sim/Statecraft.Sim/Cause.cs+++ b/sim/Statecraft.Sim/Cause.cs@@ -87,6 +87,12 @@ namespace Statecraft.SimEventSetRung = "event_set_rung", EventRejoin = "event_rejoin";// Grant: context then city id. City: context then city id, field. Rejoin: context then EN/HE title.public const string MilitaryUpkeep = "military_upkeep";+ /// <summary>#1703, gdd-0.3 only (R-HOUSE-005): the cities' housing surcharge, a Money line (Target treasury) of minus+ /// Delta. No args.</summary>+ public const string HousingSurcharge = "housing_surcharge";+ /// <summary>#1703, gdd-0.3 only (R-HOUSE-005): Social cohesion (Target morale) moved by Delta by the cities' housing+ /// condition. No args.</summary>+ public const string HousingCohesion = "housing_cohesion";// #1682: immutable values in Args; no current-state lookup is needed to word an old report.@@ -233,7 +239,8 @@ namespace Statecraft.Sim{public const string Deficit = "deficit", CivilianUpkeep = "civilian_upkeep", MilitaryUpkeep = "military_upkeep",Corridor = "corridor", Arms = "arms", Training = "training", Prisoners = "prisoners", TrainingCamp = "training_camp",- Plow = "plow", Drain = "drain", Yishuv = "yishuv", Deport = "deport", Occupation = "occupation";+ Plow = "plow", Drain = "drain", Yishuv = "yishuv", Deport = "deport", Occupation = "occupation",+ HousingSurcharge = "housing_surcharge";/// <summary>Args: the project kind's id.</summary>public const string Project = "project";/// <summary>A map action's cost (MapActions.Apply), a Paid line only: its borrowing is CauseKeys.MapBorrowed.@@ -247,7 +254,7 @@ namespace Statecraft.Simpublic static readonly IReadOnlyList<string> All = new[]{Deficit, CivilianUpkeep, MilitaryUpkeep, Corridor, Arms, Training, Prisoners, TrainingCamp, Plow, Drain, Yishuv,- Deport, Occupation, Project, MapAction, Event, Workshop,+ Deport, Occupation, Project, MapAction, Event, Workshop, HousingSurcharge,};}@@ -256,7 +263,7 @@ namespace Statecraft.SimMoneyFlows, FxFlows, Borrowed, Paid, MoneyOther, CivilianUpkeep, FxCrisisBegan, FxCrisisEased, FxCrisisFood, Arrived, EffectChange,SituationBegan, SituationEnded, RungChanged, CallUpSet, CallUpRaised, CallUpLowered, Ceasefire,EventNew, EventChosen, EventDelegated, EventDelegatedPartial, EventAmount, EventStock, EventGrant, EventCity,- EventUnlock, EventPolicy, EventSetRung, EventRejoin, MilitaryUpkeep,+ EventUnlock, EventPolicy, EventSetRung, EventRejoin, MilitaryUpkeep, HousingSurcharge, HousingCohesion,ObjectiveCompleted, PrisonersReturned, SoldiersReturned,WorkersAssigned, WagesPaid, ImmigrantsHoused, HousingShortage, ImmigrantsWaiting, RecruitsVeteran, CorridorStarted, CorridorCancelled, CorridorCompleted, PioneersVeteran, MapBorrowed, MapBuilt, LandWorkStarted, SiteStarted, SiteCancelled, SiteCompleted, ProjectStarted, ProjectCancelled, ProjectCompleted, ArmsBought, WorkshopWorkers, WorkshopArms, WorkshopPaused, DollarsConverted, FoodHarvest, FoodShortage, FoodWithoutImports, PrisonerFood, PrisonerFoodShortage, CraftsmenReturned, CraftsmenReassigned, PioneerReturned, PioneersReassigned, TrainingStarted, TrainingArms, TrainingCancelled, TrainingArmsReturned, ReplacementsStopped, ReplacementsJoined, MilitaryTrained, PioneersTrained, CraftsmenTrained, Appointed, Reshuffle, AppointmentsEnded, ApprovalStability, CoalitionCollapsed, LegislatureConvened, GovernmentTookOffice, CoalitionChanged, EraEnded, AdvisoryPolicyRejected, PolicyRejected, PolicySet, AdvisoryBudgetRejected, BudgetRejected, PlaceCaptured, EnemyRegained, PlaceAnnexed, PlaceWithdrawn, PlaceDeported, DeportEffect, DeportCost, OccupationStarted, PendingBecameRaid, OccupationLostUnit, OccupationCountdown, DepopulationSupport,};diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.csindex 601fd8b00..f19c8bda8 100644--- a/sim/Statecraft.Sim/Cities.cs+++ b/sim/Statecraft.Sim/Cities.cs@@ -177,13 +177,15 @@ namespace Statecraft.Sim/// <summary>R-HOUSE-003 (Q-HOUSE-5): the people who take the city's housing: its civilians, craftsmen, recruits and groups/// in training (a halutz group too, until it becomes a movable unit and leaves). Refugees wait for housing and are not- /// in it. Israeli formations retain their home city's housing after graduation, including when they move or become- /// veterans. Summed as integers, so the order of the training groups and formations cannot change it.</summary>+ /// in it. Under gdd-0.1 Israeli formations retain their home city's housing after graduation, including when they move+ /// or become veterans. Under gdd-0.3 they do not (#1703; 27M-18, owner-approved 1 November 2026: "Housed = civilians,+ /// craftsmen, recruits and groups in training. Refugees and pioneer units are not housed."). Summed as integers, so the+ /// order of the training groups and formations cannot change it.</summary>public static int Housed(GameState s, City x){var n = x.Civilians + x.Craftsmen + x.Recruits;foreach (var k in s.Cohorts.Values) if (k.City == x.Id) n += k.Count;- return n + Soldiers(s, x);+ return s.Ruleset == SaveGame.Gdd03Ruleset ? n : n + Soldiers(s, x);}/// <summary>R-HOUSE-003, R-UNIT-004 (Q-HOUSE-5): the Israeli formations the city houses, their strength summed:@@ -224,18 +226,78 @@ namespace Statecraft.Sim/// <summary>R-HOUSE-002 (D-D1, Q-HOUSE-1): after the housing step, each city with overflow loses/// <c>overflow_condition_loss * overflow / housed</c> of its housing condition, never below 0. A city with none keeps/// its condition; nothing in this rule raises it (housing projects do, Phase 3 PR 4). Each city reads only its own- /// counts (R-HOUSE-001: the condition is per city).</summary>+ /// counts (R-HOUSE-001: the condition is per city). Under gdd-0.3 the condition follows <see cref="SettleGdd03"/>'s+ /// rules instead (#1703: the surcharge, 5 pp overflow and the cohesion term).</summary>public static void UpdateCondition(Content c, GameState s, MvpRules r, List<Cause> why){PopulationLedger.RefuseAggregate(s);+ var gdd03 = c.Ruleset == SaveGame.Gdd03Ruleset ? Gdd03HousingFormula.FromCatalogue(c.Gdd03Balance!) : null;+ var people = gdd03 == null ? 0 : OwnPopulation(s);+ double surcharge = 0.0, cohesion = 0.0;foreach (var x in s.Cities.Values.ToList()){var over = Overflow(s, x);+ if (gdd03 != null && x.Condition is double was)+ {+ // R is the city's housed people after this step's housing arrivals (27M-15; owner, 2 November 2026:+ // "After housing arrivals (Recommended)"), for the surcharge, the overflow and the cohesion term alike.+ var h = gdd03.EvaluateTurn(Housed(s, x), people, x.HousingCapacity, was);+ surcharge += h.Surcharge;+ cohesion += h.Cohesion;+ if (h.ConditionAfter != was) s.Cities[x.Id] = x.WithCondition(h.ConditionAfter);+ }if (over == 0) continue;- if (x.Condition is double now)+ if (gdd03 == null && x.Condition is double now)s.Cities[x.Id] = x.WithCondition(Math.Max(0.0, now - r.OverflowConditionLoss!.Value * over / Housed(s, x)));why.Add(new Cause("city", x.Id, over, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {over} groups more than its homes hold"), key: CauseKeys.HousingShortage, args: new[] { CauseKeys.Number(over) }));}+ if (gdd03 != null) SettleGdd03(c, s, surcharge, cohesion, why);+ }++ /// <summary>R-HOUSE-002 and R-HOUSE-005 under gdd-0.3 (#1703), in its order: "Price the surcharge from pre-deterioration+ /// condition, then deteriorate once, then apply cohesion once." <see cref="UpdateCondition"/> evaluates each city with a+ /// condition by <see cref="Gdd03HousingFormula"/>, with its <see cref="Housed"/> people as R (after this step's arrivals+ /// became civilians, 27M-15) and <see cref="OwnPopulation"/> as P:+ /// - the surcharge, <c>R * max(0, money_threshold - c) * money_slope</c> Money from the condition before this turn's+ /// deterioration. money_slope is 0.1 per population unit (owner, 2 November 2026: "Scale it to unit size+ /// (Recommended)"; the option read: "0.1 per unit (as #2112 did for Industry), about 7.6 Money a turn at start.");+ /// - overflow deterioration, <c>overflow_deterioration pp * max(0, R - capacity) / R</c> (5 pp), in place of gdd-0.1's+ /// overflow_condition_loss, never below 0;+ /// - the cohesion loss, <c>max_cohesion_loss * sum((R / P) * max(0, (cohesion_threshold - c') / cohesion_threshold))</c>+ /// displayed points of Social cohesion, from the condition c' after deterioration.+ /// There is no housing upkeep (27M-17, IL 0m), so no unpaid deterioration. The sums run in ordinal city order, in+ /// double, the state type (<see cref="Gdd03HousingFormula.EvaluateTurn"/>). This settles them once: the surcharge as one+ /// Money line, borrowed when the Treasury is short (R-MONEY-003), and the cohesion loss once on `morale` through its+ /// permanent shift. The legacy `housing` to `morale` link adds nothing under gdd-0.3 (EffectsSystem.Apply).</summary>+ static void SettleGdd03(Content c, GameState s, double surcharge, double cohesion, List<Cause> why)+ {+ if (surcharge > 0.0)+ {+ why.Add(new Cause("economy", "treasury", -surcharge, $"{PlayerText.Change(c, "treasury", -surcharge)} (housing surcharge)", key: CauseKeys.HousingSurcharge));+ EconomySystem.PayNamedOrBorrow(c, s, surcharge, "for the housing surcharge", why, CauseKeys.Purpose.HousingSurcharge);+ }+ if (cohesion > 0.0)+ {+ var moved = EffectsSystem.Shift(c, s, CohesionIndicator, -cohesion / 100.0);+ if (moved != 0)+ why.Add(new Cause("city", CohesionIndicator, moved, $"{PlayerText.Change(c, CohesionIndicator, moved)} (housing condition)", key: CauseKeys.HousingCohesion));+ }+ }++ /// <summary>Social cohesion's indicator id (R-NAT-001), which the gdd-0.3 housing cohesion term moves (R-HOUSE-005).</summary>+ public const string CohesionIndicator = "morale";++ /// <summary>R-HOUSE-005 (#1703): P, all own population in units: every city's housed people and refugees, and the+ /// strength of every player unit, wherever it stands: the Israeli formations and the halutz units, which have no side+ /// (R-UNIT-001). Summed as integers. The owner was asked: "Should P be the 12 cities' people plus units (the PR today),+ /// or the national population (649,400 at start, which cuts the loss by ~20%)?" and answered, 2 November 2026: "The 12+ /// cities' people (Recommended)"; the option read: "As built: only the cities whose housing is tracked."</summary>+ public static int OwnPopulation(GameState s)+ {+ var n = 0;+ foreach (var x in s.Cities.Values) n += Housed(s, x) + x.Refugees;+ foreach (var u in s.Units.Values) if (u.Side == "" || u.Side == Movement.PlayerSide) n += u.Strength;+ return n;}/// <summary>The effect source id of the cities' employed share (R-CITY-005): a GDD-only source of `morale`, Socialdiff --git a/sim/Statecraft.Sim/EffectsSystem.cs b/sim/Statecraft.Sim/EffectsSystem.csindex b47a47c51..671887f68 100644--- a/sim/Statecraft.Sim/EffectsSystem.cs+++ b/sim/Statecraft.Sim/EffectsSystem.cs@@ -78,7 +78,7 @@ namespace Statecraft.Sim// Read every source before writing anything, so effect order cannot change results.var v = c.At(s.Date);var targets = v.Effects.ToDictionary(e => e.Id, e =>- e.K * Source(s, e.Source) * Multiplier(c, s, e.Office));+ RetiredGdd03Link(c, e) ? 0.0 : e.K * Source(s, e.Source) * Multiplier(c, s, e.Office));var moved = new HashSet<string>();foreach (var e in v.Effects){@@ -102,6 +102,13 @@ namespace Statecraft.SimUpdateSituations(c, s, why);}+ /// <summary>#1703, R-HOUSE-005 (with #1715's "Disable `homes_lift_morale` ... under 0.3"): under gdd-0.3 the legacy link+ /// from the national `housing` indicator into `morale` (homes_lift_morale) adds nothing, because the cities' housing+ /// cohesion term (Cities.UpdateCondition) is the one housing penalty on Social cohesion. Its contribution starts at 0 and+ /// stays there. gdd-0.1 and legacy keep it.</summary>+ static bool RetiredGdd03Link(Content c, Effect e) =>+ c.Ruleset == SaveGame.Gdd03Ruleset && e.Source == Cities.HousingIndicator && e.Target == Cities.CohesionIndicator;+/// <summary>An effect's source level: a policy, an indicator, or the cities' employed share (R-CITY-005). The legacy/// loop has no cities, so there the share reads 0 and the effect adds nothing (not 1, which would lift morale).</summary>static double Source(GameState s, string id) =>diff --git a/sim/Statecraft.Sim/Gdd03HousingFormula.cs b/sim/Statecraft.Sim/Gdd03HousingFormula.csindex c0430de73..8feb82ed1 100644--- a/sim/Statecraft.Sim/Gdd03HousingFormula.cs+++ b/sim/Statecraft.Sim/Gdd03HousingFormula.cs@@ -2,8 +2,9 @@ using System;namespace Statecraft.Sim{- /// <summary>Unwired arithmetic for #1703 synthetic fixtures. No state, resident selection,- /// initial condition, snapshot timing, Money settlement or indicator commit.</summary>+ /// <summary>#1703's housing arithmetic. <see cref="Evaluate"/> is the decimal form for synthetic fixtures;+ /// <see cref="EvaluateTurn"/> is the live gdd-0.3 step in double. Neither holds state, selects residents, sets the+ /// initial condition, settles Money or commits an indicator: Cities.UpdateCondition does.</summary>internal sealed class Gdd03HousingFormula{readonly decimal conditionMax, moneyThreshold, moneySlope, cohesionThreshold;@@ -86,6 +87,27 @@ namespace Statecraft.Simreturn new Gdd03HousingResult(surcharge, overflow, unpaid, after, cohesion);}+ /// <summary>R-HOUSE-005's live step for one city (#1703; Cities.UpdateCondition): Evaluate's surcharge, overflow+ /// and cohesion terms in the same order, with no upkeep (27M-17), in double. A city's condition, the Treasury and the+ /// indicators are doubles, hashed as IEEE bits (docs/determinism.md), so the live step stays in double rather than+ /// round-trip state through decimal; only the catalogue's one- and two-digit scalars are cast, as Workshops casts+ /// its catalogue price.</summary>+ internal (double Surcharge, double ConditionAfter, double Cohesion) EvaluateTurn(int residents, int ownPopulation,+ int capacity, double condition)+ {+ if (residents < 0 || capacity < 0 || residents > ownPopulation)+ throw new ArgumentOutOfRangeException(nameof(residents), "counts must be nonnegative; residents cannot exceed own population");+ if (condition < 0.0 || condition > (double)conditionMax)+ throw new ArgumentOutOfRangeException(nameof(condition), "condition must be within catalogue bounds");+ var surcharge = residents * Math.Max(0.0, (double)moneyThreshold - condition) * (double)moneySlope;+ var overflow = residents == 0 ? 0.0 : ((double)overflowPp / 100.0) * Math.Max(0, residents - capacity) / residents;+ var after = Math.Max(0.0, Math.Min((double)conditionMax, condition - overflow));+ var threshold = (double)cohesionThreshold;+ var cohesion = ownPopulation == 0 ? 0.0 : (double)maxCohesionLoss+ * ((double)residents / ownPopulation) * Math.Max(0.0, (threshold - after) / threshold);+ return (surcharge, after, cohesion);+ }+// Explicit single project-effect arithmetic; caller owns command/payment/application-once.internal decimal ApplyConditionEffect(decimal condition, decimal deltaFraction){diff --git a/unity/Assets/Scripts/UI/CauseText.cs b/unity/Assets/Scripts/UI/CauseText.csindex 5141e6cdb..160b58249 100644--- a/unity/Assets/Scripts/UI/CauseText.cs+++ b/unity/Assets/Scripts/UI/CauseText.cs@@ -30,6 +30,8 @@ namespace Statecraft.Game.UIcase CauseKeys.CivilianUpkeep:case CauseKeys.MoneyOther:case CauseKeys.MilitaryUpkeep:+ case CauseKeys.HousingSurcharge:+ case CauseKeys.HousingCohesion:case CauseKeys.FxCrisisFood:return text.Format(key, Name(text, cause.Target), Change(c, cause.Target, cause.Delta));case CauseKeys.Borrowed:diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.csindex f2f191daa..fec88ab17 100644--- a/unity/Assets/Scripts/UI/GddHexPanel.cs+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs@@ -92,7 +92,8 @@ namespace Statecraft.Game.UIstatic void City(VisualElement host, SimBridge bridge, UiText text, string id){var c = bridge.Content; var s = bridge.State; var city = s.Cities[id];- // R-HOUSE-003: the housed are the civilians, the recruits and the groups in training (Cities.Housed), against the+ // R-HOUSE-003: the housed are the civilians, craftsmen, recruits and groups in training, and under gdd-0.1 the+ // city's Israeli formations too (Cities.Housed), against the// capacity; R-HOUSE-001: the city's housing condition, 0 to 1, through the one percent formatter, on the same line// so the panel is no taller (the GDD loop always has a condition; the plain form is for a city without one).var housed = Cities.Housed(s, city); var capacity = Groups(text, city.HousingCapacity);@@ -109,9 +110,12 @@ namespace Statecraft.Game.UIvar waiting = Row(host, "city-waiting-row"); waiting.AddToClassList(PairsClass);Line(waiting, "city-refugees", text.Format("city.refugees", Groups(text, city.Refugees)));Line(waiting, "city-overflow", text.Format("city.overflow", Cities.Overflow(s, city)));- // #1345: trained recruits are formations housed in their home city since #1130, so the line counts every Israeli- // formation the city houses (Cities.Soldiers, part of Cities.Housed), not City.Recruits, which nothing writes now.- Line(host, "city-soldiers", text.Format("city.soldiers", Groups(text, Cities.Soldiers(s, city))));+ // #1345: under gdd-0.1 trained recruits are formations housed in their home city since #1130, so the line counts+ // every Israeli formation the city houses (Cities.Soldiers, part of Cities.Housed), not City.Recruits, which nothing+ // writes now. Under gdd-0.3 formations are not housed (R-HOUSE-003, 27M-18; #1703), so there is no such line: the+ // housing line above already shows the gdd-0.3 housed count.+ if (c.Ruleset != SaveGame.Gdd03Ruleset)+ Line(host, "city-soldiers", text.Format("city.soldiers", Groups(text, Cities.Soldiers(s, city))));// The Assign stepper: the ordered count (or the current one), one group a press, within R-CITY-001's limits as// the sim gives them with this turn's Train orders; stepping back to the current count withdraws the order.diff --git a/unity/Assets/Tests/EditMode/CauseTextTests.cs b/unity/Assets/Tests/EditMode/CauseTextTests.csindex b92db72d3..fe2765433 100644--- a/unity/Assets/Tests/EditMode/CauseTextTests.cs+++ b/unity/Assets/Tests/EditMode/CauseTextTests.cs@@ -154,6 +154,7 @@ public class CauseTextTests(CauseKeys.Purpose.Occupation, $"for the occupation of {placeName}", new[] { place }),(CauseKeys.Purpose.Event, $"for {ev.Title}", new[] { ev.Id, ev.Title, "1" }),(CauseKeys.Purpose.Workshop, "for an arms workshop cycle", new string[0]), // R-ARMS-006+ (CauseKeys.Purpose.HousingSurcharge, "for the housing surcharge", new string[0]), // #1703, gdd-0.3 (Cities.SettleGdd03)};// A map action borrows with its own key (CauseKeys.MapBorrowed): its purpose names only its Paid line (#2199).CollectionAssert.AreEquivalent(CauseKeys.Purpose.All.Where(p => p != CauseKeys.Purpose.Deficit && p != CauseKeys.Purpose.MapAction),@@ -199,7 +200,7 @@ public class CauseTextTests(CauseKeys.Purpose.Workshop, "for an arms workshop cycle", new string[0]), // R-ARMS-006};CollectionAssert.AreEquivalent(CauseKeys.Purpose.All.Except(new[] { CauseKeys.Purpose.Deficit, CauseKeys.Purpose.CivilianUpkeep,- CauseKeys.Purpose.MilitaryUpkeep, CauseKeys.Purpose.Deport, CauseKeys.Purpose.Event }), purposes.Select(p => p.Key), "every paying purpose");+ CauseKeys.Purpose.MilitaryUpkeep, CauseKeys.Purpose.Deport, CauseKeys.Purpose.Event, CauseKeys.Purpose.HousingSurcharge }), purposes.Select(p => p.Key), "every paying purpose");var en = En; var he = He;foreach (var (key, english, args) in purposes){@@ -290,6 +291,27 @@ public class CauseTextTests}}+ /// <summary>#1703 (R-HOUSE-005, gdd-0.3 only): the housing surcharge's Money line and the housing condition's Social+ /// cohesion line, worded as Cities.SettleGdd03 writes them: English is the Message, Hebrew is Hebrew.</summary>+ [Test]+ public void TheGdd03HousingLinesAreWordedInBothLanguages()+ {+ var lines = new[]+ {+ new Cause("economy", "treasury", -7.665, $"{PlayerText.Change(C, "treasury", -7.665)} (housing surcharge)", key: CauseKeys.HousingSurcharge),+ new Cause("city", "morale", -0.01, $"{PlayerText.Change(C, "morale", -0.01)} (housing condition)", key: CauseKeys.HousingCohesion),+ };+ var en = En; var he = He;+ foreach (var line in lines)+ {+ Assert.AreEqual(line.Message, CauseText.Line(line, C, NoRows, en), line.Key);+ AssertHebrew(CauseText.Line(line, C, NoRows, he), line.Key);+ }+ // The owner's word for the surcharge, 2 Nov 2026: "היטל דיור (Recommended)".+ var surcharge = CauseText.Line(lines[0], C, NoRows, he);+ Assert.IsTrue(surcharge.IndexOf("היטל דיור", StringComparison.Ordinal) >= 0, surcharge);+ }+static void AssertHebrew(string line, string key){Assert.IsTrue(UiDirection.RightToLeft(line), $"{key}: '{line}' reads right to left");@@ -505,7 +527,8 @@ public class CauseTextTestsCauseKeys.EventAmount, CauseKeys.EventChosen, CauseKeys.EventCity, CauseKeys.EventDelegated,CauseKeys.EventDelegatedPartial, CauseKeys.EventGrant, CauseKeys.EventNew, CauseKeys.EventPolicy,CauseKeys.EventRejoin, CauseKeys.EventSetRung, CauseKeys.EventStock, CauseKeys.EventUnlock,- CauseKeys.MilitaryUpkeep, CauseKeys.ObjectiveCompleted, CauseKeys.PrisonersReturned, CauseKeys.SoldiersReturned }), rows.Select(x => x.Key), "all remaining keys");+ CauseKeys.MilitaryUpkeep, CauseKeys.HousingSurcharge, CauseKeys.HousingCohesion,+ CauseKeys.ObjectiveCompleted, CauseKeys.PrisonersReturned, CauseKeys.SoldiersReturned }), rows.Select(x => x.Key), "all remaining keys");var appointed = rows.Single(x => x.Key == CauseKeys.Appointed);StringAssert.Contains("התפקיד שנשמר", CauseText.Line(appointed, c, NoRows, he, names), "historical title, not current title");}diff --git a/unity/Assets/Tests/EditMode/CityPanelTests.cs b/unity/Assets/Tests/EditMode/CityPanelTests.csindex 0f90a4922..88a913742 100644--- a/unity/Assets/Tests/EditMode/CityPanelTests.cs+++ b/unity/Assets/Tests/EditMode/CityPanelTests.cs@@ -122,6 +122,44 @@ public class CityPanelTestsAssert.AreEqual(t.Format("city.soldiers", t.Format("city.groups", 7)), ui.Q<Label>("city-soldiers").text);}+ /// <summary>The real content with only eras.yaml's ruleset switched to gdd-0.3 (DollarConversionTests' pattern).</summary>+ static Content Gdd03Content()+ {+ var dir = Paths.Content;+ return ContentLoader.Load(rel =>+ {+ var path = Path.Combine(dir, rel);+ if (!File.Exists(path)) return null;+ var value = File.ReadAllText(path);+ return rel == "eras.yaml" ? value.Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3") : value;+ }, Directory.GetFiles(Path.Combine(dir, "events"), "*.yaml").Select(x => "events/" + Path.GetFileName(x)));+ }++ [Test]+ public void TheSoldiersLineShowsOnlyWhereFormationsAreHoused([Values] bool hebrew, [Values] bool gdd03)+ {+ // #1703 (R-HOUSE-003; 27M-18, owner-approved 1 November 2026: "Housed = civilians, craftsmen, recruits and groups in+ // training. Refugees and pioneer units are not housed."): under gdd-0.3 a city's formations are not housed, so the+ // panel has no "Soldiers housed" line and the housing line counts no formation. gdd-0.1 keeps the line (#1345).+ var t = hebrew ? He : En;+ var c = gdd03 ? Gdd03Content() : C;+ Assert.AreEqual(gdd03 ? SaveGame.Gdd03Ruleset : SaveGame.GddRuleset, c.Ruleset, "precondition: the ruleset under test");+ var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);+ var id = g.State.NextId++;+ g.State.Units.Add(id, new Unit(id, "veteran_soldier", CityHex.q, CityHex.r, 0, "israel", 3, "", "", City));+ var bridge = new SimBridge(g, t);+ using var ui = new UiTestKit();+ using var panel = new InfoPanelPresenter(ui.Root, bridge, t, Towns.ToDictionary(x => x.Id, x => x.Name));+ panel.Show(CityHex.q, CityHex.r);+ var s = bridge.State; var city = s.Cities[City];+ var people = city.Civilians + city.Craftsmen + city.Recruits + s.Cohorts.Values.Where(k => k.City == City).Sum(k => k.Count);+ Assert.AreEqual(gdd03 ? people : people + 3, Cities.Housed(s, city), "precondition: the sim's housed count");+ Assert.AreEqual(t.Format("city.housing_condition", Cities.Housed(s, city), t.Format("city.groups", city.HousingCapacity),+ PlayerText.Percent(city.Condition!.Value)), ui.Q<Label>("city-housing").text);+ if (gdd03) Assert.IsNull(ui.Root.Q<Label>("city-soldiers"), "no soldiers line under gdd-0.3");+ else Assert.AreEqual(t.Format("city.soldiers", t.Format("city.groups", 3)), ui.Q<Label>("city-soldiers").text);+ }+[Test]public void TheCityHexShowsItsHousingConditionFromTheSim(){diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex e59c68a01..61b80adaa 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -406,6 +406,7 @@ why.cause.civilian_upkeep: "{0} {1} (civilian upkeep)"why.cause.borrowed.deficit: "Borrowed {0} to cover the deficit"why.cause.borrowed.civilian_upkeep: "Borrowed {0} for civilian upkeep"why.cause.borrowed.military_upkeep: "Borrowed {0} for military upkeep"+why.cause.borrowed.housing_surcharge: "Borrowed {0} for the housing surcharge"why.cause.borrowed.corridor: "Borrowed {0} to build a corridor segment"why.cause.borrowed.arms: "Borrowed {0} for Arms"why.cause.borrowed.training: "Borrowed {0} for training"@@ -970,6 +971,8 @@ share.site_downloaded: "Attach the downloaded picture to the post."# Event/upkeep cause templates (#1680).why.cause.military_upkeep: "{0} {1} (military upkeep)"+why.cause.housing_surcharge: "{0} {1} (housing surcharge)"+why.cause.housing_cohesion: "{0} {1} (housing condition)"why.cause.event_new: "New: {0}"why.cause.event_chosen: "Chosen: {0}"why.cause.event_delegated: "Delegated to {0}: {1}"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 321f22498..98636f692 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -456,6 +456,10 @@ why.cause.borrowed.occupation: "הלוואה של {0} לעלות ההחזקה ({why.cause.borrowed.event: "הלוואה של {0} עבור {1}"# The gdd-0.3 arms workshop's cycle (#1701, R-ARMS-006). Agent-drafted Hebrew; native review pending (#564).why.cause.borrowed.workshop: "הלוואה של {0} למחזור עבודה בסדנת נשק"+# The gdd-0.3 housing surcharge (#1703, R-HOUSE-005), not part of #1642's owner review above. The word "היטל דיור" is the+# owner's choice (2 Nov 2026: "היטל דיור (Recommended)"); the rest of the line is agent-drafted Hebrew, native review+# pending (#564).+why.cause.borrowed.housing_surcharge: "הלוואה של {0} להיטל הדיור"# #2199: the why.cause.paid.* lines below are agent-drafted Hebrew, not part of #1642's owner review above. Each reuses# its why.cause.borrowed.* purpose phrase, except paid.occupation, which is newly worded. Native review pending (#564).why.cause.paid.corridor: "{0}: שינוי {1} (לבניית קטע של כביש או מסילה)"@@ -1061,6 +1065,11 @@ share.site_downloaded: "אפשר לצרף לפוסט את התמונה שהור# Event/upkeep cause templates (#1680, #564), review state per key.# agent-drafted Hebrew; native review: owner, in chat on 25 Oct 2026 (approved recommendation).why.cause.military_upkeep: "{0}: שינוי {1} (תחזוקה צבאית)"+# The gdd-0.3 housing surcharge and cohesion lines (#1703, R-HOUSE-005). Agent-drafted Hebrew; native review pending (#564).+# The surcharge's word "היטל דיור" is the owner's choice (2 Nov 2026: "היטל דיור (Recommended)"), and "מצב הדיור" is+# Q-UI-2's approved term for housing condition; the rest of each line awaits the native read.+why.cause.housing_surcharge: "{0}: שינוי {1} (היטל דיור)"+why.cause.housing_cohesion: "{0}: שינוי {1} (מצב הדיור)"# agent-drafted Hebrew; native review: owner, in chat on 25 Oct 2026 (approved as drafted).why.cause.event_new: "אירוע חדש: {0}"# agent-drafted Hebrew; native review: owner, in chat on 25 Oct 2026 (approved as drafted).