Skip to content

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 Phase 7 PR 4, the ministers on the GDD systems (R-MIN-001 to R-MIN-003; refs #808) (#1147)

agamrafaeli-instinct2d3e13c098e1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7c5bcea9..5e0beafd4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,18 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [Unreleased]
+### Added
+- The ministers reach the GDD systems (D-H3's first slice, refs #808): the Labour minister's office scales housing and
+ industry construction, the Agriculture minister's office pioneer and field work, and the Immigration minister's
+ office refugee absorption, each at the cabinet multiplier (competence x budget share) on the turn's date. Prices and
+ stated durations are unchanged, a build's fractional progress is carried on its record, and an office that does not
+ exist on the date reads its named successor's multiplier. In the historical run every build and absorption moves:
+ the reference player builds Mefalsim on 15 February 1951 (was 15 March 1950), the camps are never started, and every
+ golden is re-pinned.
+
### Fixed
+- Fractional site and city-project carry is hashed as IEEE bits on every runtime, avoiding different decimal spellings on .NET and Unity Mono; gameplay progress is unchanged.
+- Site construction forecasts use the current minister rate and saved fractional work, including pioneer promotion.
- On a notched phone the HUD and the panels keep clear of the notch and the home indicator: the root is padded by
the browser's `env(safe-area-inset-*)` values (the camera's top inset and the map labels follow as before), and it
follows the insets even when the root bounds do not change, as a same-size landscape flip moves the notch with no
diff --git a/content/rules.yaml b/content/rules.yaml
index de0821cdd..72d3b82c4 100644
--- a/content/rules.yaml
+++ b/content/rules.yaml
@@ -41,6 +41,19 @@ mvp:
transit_camp_upkeep_per_year: 0.0 # DESIGN VALUE: owner-set balance, not a historical figure (D-C6: IL millions per transit camp a year)
military_camp_upkeep_per_year: 0.0 # DESIGN VALUE: owner-set balance, not a historical figure (D-C6: IL millions per military camp a year)
hakhshara_upkeep_per_year: 0.0 # DESIGN VALUE: owner-set balance, not a historical figure (D-C6: IL millions per Hakhshara a year)
+
+ # R-MIN-001 (D-H3; Q-MIN-1, owner, 17 October 2026, #784): the office whose multiplier (competence times budget
+ # factor, EffectsSystem.Multiplier) scales each GDD system. Q-MIN-1's mapping, "each with its office's sourced remit
+ # in a comment": the Ministry of Labour ran housing and public construction; the Ministry of Agriculture, the fields
+ # and the new settlements; the Ministry of Immigration, the immigrants' housing (the offices and their terms are the
+ # sourced rows of offices.yaml; the remits are as the decision names them). Corridors (Transportation) and military
+ # training (Defense) join the map when their integrations land (#870, #742).
+ minister_systems:
+ housing_construction: labour_minister
+ industry_construction: labour_minister
+ field_work: agriculture_minister
+ yishuv_work: agriculture_minister
+ absorption: immigration_minister
# The day the cities start taking arrivals (R-CITY-003; Q-ARRV-3, owner, 15 October 2026, #375): the census day of their
# start values, 8 November 1948 (CBS Statistical Abstract of Israel No. 14, Table 11, pp. 30-31). The census already
# counts the people who arrived from 15 May, so the cities take none before it; the national head count takes them all.
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index 08ada636d..b0a0efbc8 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -19,8 +19,8 @@ GitHub Releases page (and, from M4, on itch.io). Steps 1–3 are a normal pull r
"$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -buildTarget WebGL -executeMethod Statecraft.Game.EditorTools.Build.Web -compression gzip -shareable -logFile "$PWD/unity-build-web-gz.log"
git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset
golden_expect=(); while read -r name hash; do [[ -z "$name" || "$name" == \#* ]] || golden_expect+=(--expect "GOLDEN OK $name $hash"); done < sim/Statecraft.Sim.Tests/golden/manifest.txt
- # one GOLDEN OK line per manifest golden (#394), e.g. "GOLDEN OK hash1950 4f1202cfa20e1f3cc7521c7b3baac386330b77fdbacc25928d781b1659747340"
- # and "GOLDEN OK hash1952 283349502eb580123fcea6bf64ca174f913627132a1325f3dbf00743435623e2"
+ # one GOLDEN OK line per manifest golden (#394), e.g. "GOLDEN OK hash1950 e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a"
+ # and "GOLDEN OK hash1952 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde"
uv run tools/web_check.py unity/Builds/Web-gzip --query "golden&smoke=5" "${golden_expect[@]}" \
--expect "SMOKE OK 5 turns 1948-10-15 8d000459d26a08a49583adfc88c14799ce6e6f653dcecff1e30b5e737f0959aa"
uv run tools/web_check.py unity/Builds/Web-gzip --startscreen new --timeout 300 --stall 90
diff --git a/docs/determinism.md b/docs/determinism.md
index 6ff56205c..29f5455f2 100644
--- a/docs/determinism.md
+++ b/docs/determinism.md
@@ -12,7 +12,11 @@ The simulation must produce the same state, bit for bit, on .NET, Unity Mono and
- **No trigonometry in the sim:** the sim calls only `Math.Abs`, `Math.Min` and `Math.Max`. Geometry that needs
cos/sin (which hex owns a settlement) is precomputed by `tools/settlement_hexes.py` and read as content.
- **Canonical hash:** `GameState.Hash()` is SHA-256 over a canonical text. Keys are sorted ordinally. Doubles are
- written as IEEE bit patterns, with -0.0 written as 0.0. Culture is invariant.
+ written as IEEE bit patterns, with -0.0 written as 0.0. Culture is invariant. Fractional site and city-project
+ carry follows the same rule: nonzero carry is written as 16 hexadecimal digits of its IEEE bit pattern, and zero carry is omitted.
+ Round-trip decimal formatting is only a display concern: .NET and Unity Mono can spell the same carry bits
+ differently. The Phase 7 minister carry correction re-pins hash1950, hash1952 and mvp-end for this representation
+ only; stored values, gameplay and completion dates are unchanged.
## Golden playthroughs
@@ -28,9 +32,9 @@ final `GameState.Hash()` is pinned:
| Run | Ends | Hash |
|---|---|---|
-| to 1950-01-01 (`Hash1950`) | 1950-01-15, turn 20 | `4f1202cfa20e1f3cc7521c7b3baac386330b77fdbacc25928d781b1659747340` |
-| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `283349502eb580123fcea6bf64ca174f913627132a1325f3dbf00743435623e2` |
-| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `283349502eb580123fcea6bf64ca174f913627132a1325f3dbf00743435623e2` |
+| to 1950-01-01 (`Hash1950`) | 1950-01-15, turn 20 | `e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a` |
+| to 1952-01-01 (`Hash1952`) | 1952-01-15, turn 44 (the game's end) | `37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde` |
+| to the game's end (`mvp-end`) | 1952-01-15, turn 44 | `37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde` |
`hash1952` stops at the first turn on or after 1 January 1952, which is the game's last turn, so it is the same run as
`mvp-end` (`DeterminismTests.TheWholeGameToItsEndIsFixed`). Both names are kept (spec 2026-10-12 section 3 step 6): a
@@ -306,3 +310,13 @@ The hash reads the state keys, so it never sees a record outside its window. An
| GDD Phase 2 PR 3b | scenario-reckless | `a0f094a1` | same (was `8041988a`) |
| GDD Phase 2 PR 3b | scenario-mvp-absorb-first | `dee4f039` | same (was `be13c409`) |
| GDD Phase 2 PR 3b | scenario-mvp-defeat | `e71076f7` | same; the defeat run is unchanged apart from `arms=12` (was `19143463`) |
+| GDD Phase 7 PR 4 | 1950 | `25ea8fbf` | the ministers on the GDD systems (R-MIN-001 to R-MIN-003; Q-MIN-1 to Q-MIN-3, owner, 17 and 18 October 2026, #784; #808): construction, pioneer and field work and absorption run at their office's multiplier, with the build's fractional carry kept on the record (an in-progress site writes it, `gilat=b,1,4,0.652...`). At the cut the veteran group has built Beit Kama on 1949-06-15 (was 1949-03-15) and Beit Shemesh on 1949-11-15 (was 1949-06-15) and is on Gilat, so two fewer yishuvim are borrowed and the debt is IL 87.5m (was 91.5m); slower absorption houses fewer civilians, so the cities' overflow is smaller and `housing` 0.1062 (was 0.0932) and `morale` 0.5050 (was 0.5018) rise (was `4f1202cf`) |
+| GDD Phase 7 PR 4 | 1952 | `ef8c5fea` | same; the veteran's builds take 5 turns at 2 x 0.624 = 1.248 a turn, so Gilat is built on 1950-04-15, Kiryat Shmona on 1950-09-15, Mefalsim on 1951-02-15 and Re'im on 1951-07-15 (were 1949-09-15, 1949-12-15, 1950-03-15 and 1950-06-15), only two fields are plowed (Beit Kama 1951-10-15, Beit Shemesh 1952-01-15) and the camps never start. The debt is IL 211.9m (was 223.9m) and the Food stock 2734 (was 2738). The first-new-yishuv objective completes on 1951-02-15, after its reference date, so the score stays 100 (was `28334950`) |
+| GDD Phase 7 PR 4 | mvp-end | `ef8c5fea` | same; the same run as hash1952 (was `28334950`) |
+| GDD Phase 7 PR 4 | scenario-cautious | `9a3d241e` | the absorption and construction multipliers: the cities' housed counts and conditions move, and `housing`, `morale` and stability with them; no order or date changes (was `a6108c91`) |
+| GDD Phase 7 PR 4 | scenario-reckless | `d7dbcf75` | same; each city houses fewer of its refugees a turn, so more wait (was `a0f094a1`) |
+| GDD Phase 7 PR 4 | scenario-mvp-absorb-first | `234e32ee` | same; the scenario's one order stands, and every city's housed count moves (was `dee4f039`) |
+| GDD Phase 7 PR 4 | scenario-mvp-defeat | `f3daaa70` | same; only the housing web's numbers move, in the third decimal and below - the defeat is unchanged, still `defeat_economy` on 15 January 1952 (was `e71076f7`) |
+| Phase 7 PR 4 carry canonical fix | 1950 | `e3c76f5f` | Nonzero site and city-project carry is written as IEEE bits, consistently on .NET and Unity Mono, instead of runtime-dependent round-trip decimal text. Only canonical representation changes; the stored progress, all other snapshot lines, completion dates and gameplay are unchanged (was `25ea8fbf`). |
+| Phase 7 PR 4 carry canonical fix | 1952 | `37866907` | Nonzero site and city-project carry is written as IEEE bits, consistently on .NET and Unity Mono, instead of runtime-dependent round-trip decimal text. Only canonical representation changes; the stored progress, all other snapshot lines, completion dates and gameplay are unchanged (was `ef8c5fea`). |
+| Phase 7 PR 4 carry canonical fix | mvp-end | `37866907` | Nonzero site and city-project carry is written as IEEE bits, consistently on .NET and Unity Mono, instead of runtime-dependent round-trip decimal text. Only canonical representation changes; the stored progress, all other snapshot lines, completion dates and gameplay are unchanged (was `ef8c5fea`). |
diff --git a/docs/gdd/ministers-events-end.md b/docs/gdd/ministers-events-end.md
index 49102e51d..ef47abb75 100644
--- a/docs/gdd/ministers-events-end.md
+++ b/docs/gdd/ministers-events-end.md
@@ -7,10 +7,10 @@ As a player of the MVP, I want the game to run its events and my chosen minister
## Rules
- The MVP runs 44 turns (monthly), from 15 May 1948 to 15 January 1952: D-B1 fixes the start and the monthly grid [S2], and the owner ended the MVP on 15 January 1952, keeping the 15th grid with no adjusted turn (D-E5, decided 15 October 2026 [S2]). The GDD text still says "approximately 48 turns" [S1]; the owner settled 44 turns [S2].
-- Objective cards and scoring belong to the first phase (#379, `objectives-and-score.md`; D-B2, D-B6 [S2]) and are not restated here. This section covers only what the final phase adds: every card complete, the end screen (D-H4, open), defeat (D-B5, decided 15 October 2026 [S2]), the events (D-H1 and D-H2, decided 17 October 2026 [S5]) and the ministers (D-H3, open) [S2].
+- Objective cards and scoring belong to the first phase (#379, `objectives-and-score.md`; D-B2, D-B6 [S2]) and are not restated here. This section covers only what the final phase adds: every card complete, the end screen (D-H4, open), defeat (D-B5, decided 15 October 2026 [S2]), the events (D-H1 and D-H2, decided 17 October 2026 [S5]) and the ministers (D-H3, first slice decided 17 October and 18 October 2026 and built as R-MIN-001 to R-MIN-003; the rest open) [S2].
- Defeat: not all objectives are required to finish. The game is lost when Money and Food are exhausted for several turns in a row or on a war loss, and coalition collapse is off in the MVP (D-B5, decided 15 October 2026 [S2]). The defeat is built in this phase, with the counter set then (`Q-GOV-2`, decided 15 October 2026 [S4]). A war loss is enemy units holding the hex of one of the player's cities at turn end (`Q-WAR-5`, decided 15 October 2026 [S4]); what "Money exhausted" means now that borrowing is allowed stays open.
- The war-survival objective completes on the last armistice event, the Syria-Israel agreement of 20 July 1949 (D-B2 [S2]; [S3]). The four signings were Egypt on 24 February 1949, Lebanon on 23 March 1949, Jordan on 3 April 1949 and Syria on 20 July 1949 [S3].
-- The existing cabinet and Attention stay (D-C5 [S2]). Minister roles, candidates and effects are D-H3, open [S2].
+- The existing cabinet and Attention stay (D-C5 [S2]). Minister roles, candidates and effects are D-H3 [S2]: the first slice is decided and built - each office's competence scales the GDD systems in its remit (`Q-MIN-1` to `Q-MIN-3`, owner, 17 October and 18 October 2026; R-MIN-001 to R-MIN-003, `docs/rules/mvp.md`) - and the rest stays open.
- Events (D-H1): the owner took the recommendations for `Q-EVT-1` to `Q-EVT-4` on 17 October 2026 [S5]. Windows, hard anchors and a cap of three soft events a turn stay; an unanswered event is delegated to its office's holder; no effect is delayed; the card shows every effect of every option from the sim (`R-EVT-001` to `R-EVT-005`, `docs/rules/mvp.md`). An early armistice's place ahead of the other soft events comes with `front_quiet`, in the war-objective PR of the military phase (#752).
- Event effects (D-H2): the owner took the recommendations for `Q-HFX-1` to `Q-HFX-3` on 17 October 2026 [S5]. An option can grant units, free, at the military camp or a named city (a site once sites carry a date), and change a city's housing capacity or job slots; a sensitive option gains nothing from them; each is checked at load (`R-EFX-003` to `R-EFX-006`, `docs/rules/mvp.md`). Housing condition and project unlock come with the records they act on (#734, #735).
@@ -28,7 +28,7 @@ As a player of the MVP, I want the game to run its events and my chosen minister
## Out of scope
-- Minister roles and effects (D-H3): open.
+- Minister roles and effects (D-H3) beyond the first slice (R-MIN-001 to R-MIN-003): open.
- The objectives panel UI and the score's presentation in Phase 1.
- The exact completion conditions of each objective (GDD "MVP completion rules" [S1]): open.
- Objective 1's bonus for capturing enemy soldiers lands at the prisoners' return (the plan, section 4.3 [S2]): Phase 5/6.
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 53f4fdf78..0cc09128a 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -54,7 +54,7 @@ R-CITY-003: Arrivals from the CBS series (`aliyah.yaml`) become refugees in the
R-CITY-008: `GameState.Population` is the one record of the nation's people: it takes every arrival from 15 May 1948 and is the count the CBS anchors check. The cities are the part of it placed in towns, so their people (civilians, craftsmen, refugees, recruits and the groups in training, times `people_per_unit`) never exceed it (Q-ARRV-2, owner, 15 October 2026). No person is counted twice.
-R-CITY-004: Each turn, on the housing step, all of a city's refugees become civilians without a job (R-CITY-009's default may then give them jobs). There is no hard cap (D-D1, Q-HOUSE-1, owner, 15 October 2026): the people beyond the city's housing stay in the city as its overflow (R-HOUSE-002), and residents are housed automatically (Q-HOUSE-4).
+R-CITY-004: Each turn, on the housing step, a city's refugees become civilians without a job (R-CITY-009's default may then give them jobs), `floor(pool x m)` of them at the Immigration minister's multiplier since the ministers (R-MIN-002; all of them before); the rest wait as refugees for the next turns. There is no hard cap (D-D1, Q-HOUSE-1, owner, 15 October 2026): the people beyond the city's housing stay in the city as its overflow (R-HOUSE-002), and residents are housed automatically (Q-HOUSE-4).
R-CITY-009: The job default (Q-JOBS-1, owner, 15 October 2026). On each housing step, after the refugees become civilians (R-CITY-004), each city whose default is on sets its employed to `min(job slots, civilians + craftsmen)`, in ascending city id, at no Attention cost. Every city's default is on at the start; an accepted `AssignWorkers` order fixes that city's number and turns its default off for the rest of the game. Each change is a `city` cause on the Why screen ("Town: N groups in work"). A city's record writes `jobs=manual` into the state hash only when its default is off.
@@ -80,7 +80,7 @@ R-PROJ-001: `StartProject(kind, city, q, r)` starts a city project of a `project
R-PROJ-002: `CancelProject(id)` removes a city project that is being built. The Money paid is not returned, and there are no people to return (D-A3, Q-PROJ-3). An unknown or built project is refused with the state unchanged. Its Attention cost is `attention_cost.cancel_project` (0.5, Q-PROJ-5).
-R-PROJ-003: On step 5 of the turn (D-A6), after the pioneer work, every city project being built has one turn less to go, in ascending id. One that reaches 0 is built on the turn's end date and adds its kind's `capacity` to the city's housing capacity, its `condition` to the city's housing condition (kept from 0 to 1, R-HOUSE-001) and its `job_slots` to the city's job slots, once: a built project keeps its record, with its hex, and is never advanced again. `GameState.CityProjects` is hashed as `cproj[...]` only when it has a project (R-LOOP-002).
+R-PROJ-003: On step 5 of the turn (D-A6), after the pioneer work, every city project being built has one turn of work less to go, in ascending id - `1 x m` of one at the system's office multiplier since the ministers (R-MIN-002), the fraction carried on the record as on R-SITE-003. One that reaches 0 is built on the turn's end date and adds its kind's `capacity` to the city's housing capacity, its `condition` to the city's housing condition (kept from 0 to 1, R-HOUSE-001) and its `job_slots` to the city's job slots, once: a built project keeps its record, with its hex, and is never advanced again. `GameState.CityProjects` is hashed as `cproj[...]` only when it has a project (R-LOOP-002).
R-PROJ-005: A specialised project is allowed only in a city that has its resource (D-D8: "A winery requires areas for grapes"; Phase 3 PR 6, #737). A `projects.yaml` kind may name a `requires:` resource; a `cities.yaml` city lists its `resources:`, each with an id and sources (a url and a checked date each), and may say what the sources leave open (`to_verify`). `StartProject` of such a kind in a city without the resource is refused like the other R-PROJ-001 refusals, before the hex checks; a city founded in play has no resources. The loader refuses a resource without sources and a kind whose resource no city has. Otherwise the kind is an ordinary city project (R-PROJ-003). The one such kind is the winery, which needs vineyards, in Zikhron Ya'akov with its vineyards flagged `to_verify` (owner, 18 October 2026, on #737, "all defaults"); its content rows enter once a person has checked the vineyards' source (CONTENT_POLICY section 2, rule 6).
@@ -108,7 +108,7 @@ R-SITE-001: `PioneerWork(unit, build_yishuv, site)` starts building a yishuv at
R-SITE-002: `StopWork(unit)` ends the unit's build: the site is available again, the unit is idle, and the progress and the Money paid are lost (D-A3). A unit that does not exist or is not building is refused with the state unchanged. Its Attention cost is 0.
-R-SITE-003: Each turn, in ordinal site id order, every site being built has one turn less to go. A site that reaches 0 is built, on the turn's end date, and its unit is idle again. A veteran's site has `veteran_progress` turns less to go (R-VET-002), and the unit's type changes only by R-VET-001. No city, housing, job, population or Social cohesion changes. Sites being built or built are written into the state hash only when there are some.
+R-SITE-003: Each turn, in ordinal site id order, every site being built has one turn of work less to go - `progress x m` of one, the system's office multiplier m since the ministers (R-MIN-002): the integer part at once, the fraction carried on the record and written after it (as 16 hexadecimal digits of its IEEE bit pattern) only while non-zero. A site that reaches 0 is built, on the turn's end date, and its unit is idle again. A veteran's site has `veteran_progress` times as much work a turn (R-VET-002), and the unit's type changes only by R-VET-001. No city, housing, job, population or Social cohesion changes. Sites being built or built are written into the state hash only when there are some.
## Veteran pioneers
@@ -198,6 +198,14 @@ R-GOV-001: In the GDD loop the coalition's stability never ends the game: it sti
R-GOV-002: Every GDD order kind has an `attention_cost` in the real rules (a design value, R-LOOP-005), the unit orders `pioneer_work` and `stop_work` cost 0 (D-A6: unit orders are free), and a refused order costs nothing: its Attention is refunded before the next order in the turn is priced.
+D-H3's first slice in the GDD loop (GDD Phase 7 PR 4, #808): each office's competence scales the GDD systems in its remit. Q-MIN-1 and Q-MIN-3 were decided as recommended, Q-MIN-2 as "Output" (owner, 17 and 18 October 2026, #784): competence scales output and progress a turn, and the base price and stated duration stay unchanged. The system-to-office map is `mvp.minister_systems` in `content/rules.yaml`, each entry a labelled design value; the corridors (#870) and military training (#742) join with their own phases. Candidates and appointment stay `Cabinet.Appoint`'s.
+
+R-MIN-001: Each GDD system named in `mvp.minister_systems` reads its office's cabinet multiplier on the turn's date - the holder's competence factor times the budget factor, `EffectsSystem.Multiplier` - through `EffectsSystem.GddSystemMultiplier` (Q-MIN-1). A system the map does not name is neutral (1.0), and a multiplier within 1e-9 of 1.0 reads as exactly 1.0, so float noise never stalls a neutral system. The loader refuses a map entry whose office `offices.yaml` does not define.
+
+R-MIN-002: The multiplier scales output and progress a turn (Q-MIN-2): a site being built adds `progress x m` of a turn's work (yishuv and field work, R-SITE-003; a veteran's `veteran_progress` is the progress), a city project adds `1 x m` (housing and industry construction, R-PROJ-003), and absorption houses `floor(refugees x m)` groups a turn (R-CITY-004). The base price and the stated duration stay unchanged. The rounding rule is one: the integer part of the work applies at once, the fraction is carried on the record (R-SITE-003), so no fraction of a turn's work is lost and no whole group is housed early; the hash of a build with no carry is unchanged.
+
+R-MIN-003: When the office does not exist on the date - ended, or not yet created - the system reads the multiplier of the office's named successor, or is neutral (1.0) with none (Q-MIN-3); the absent-holder 0.5 of `EffectsSystem.Multiplier` stays the rule for an office that exists but has no holder on the date.
+
## National parameters
The GDD's Social cohesion and International Support (D-C1, decided 15 October 2026: "0–1 indicators through the effects web. Cohesion replaces `morale` on screen. Thresholds as situations"). Their numbers are labelled design values in `model.yaml` (Reading 1).
diff --git a/sim/Statecraft.Sim.Tests/CitiesTests.cs b/sim/Statecraft.Sim.Tests/CitiesTests.cs
index 05bae0b70..596b6b944 100644
--- a/sim/Statecraft.Sim.Tests/CitiesTests.cs
+++ b/sim/Statecraft.Sim.Tests/CitiesTests.cs
@@ -192,8 +192,16 @@ public class CitiesTests
var arrived = one.Cities["tel_aviv"].Refugees;
Assert.True(arrived > 0);
Assert.Equal(228, one.Cities["tel_aviv"].Civilians); // the housing step ran before they came
- var two = Step(Mvp, one).State.Cities["tel_aviv"];
- Assert.Equal(228 + arrived, two.Civilians); // no hard cap (Q-HOUSE-1): all of them, on the next turn
+ var twoState = Step(Mvp, one).State;
+ var two = twoState.Cities["tel_aviv"];
+ // R-MIN-002 (Q-MIN-2) amends R-CITY-004's "all of them": the Immigration minister's multiplier scales how many
+ // are housed - on 15 December 1948 Shapira's is (0.5 + 7/20) x (0.5 + 0.15 x 8/2) = 0.85 x 1.1 = 0.935, floored
+ // to whole groups (no hard cap stays: Q-HOUSE-1). The rest wait as refugees with the next turn's own arrivals,
+ // and the multiplier takes the same share of that pool the turn after.
+ var housed = (int)Math.Floor(arrived * 0.935);
+ Assert.Equal(228 + housed, two.Civilians);
+ var three = Step(Mvp, twoState).State.Cities["tel_aviv"];
+ Assert.Equal(228 + housed + (int)Math.Floor(two.Refugees * 0.935), three.Civilians);
}
/// <summary>D-A6: housing comes before Social cohesion in the turn. The effects web reads the cities' employed share after
diff --git a/sim/Statecraft.Sim.Tests/EventRetimingTests.cs b/sim/Statecraft.Sim.Tests/EventRetimingTests.cs
index ef914010f..9fc67041d 100644
--- a/sim/Statecraft.Sim.Tests/EventRetimingTests.cs
+++ b/sim/Statecraft.Sim.Tests/EventRetimingTests.cs
@@ -69,7 +69,7 @@ public class EventRetimingTests
[InlineData("austerity_1949", "1949-05-15")]
[InlineData("armistice_syria", "1949-08-15")]
[InlineData("frumkin_commission", "1950-01-15")]
- [InlineData("first_new_yishuv", "1950-03-15")] // R-OBJ-003: the turn the reference player builds Mefalsim (1949-09-15 before Kiryat Shmona and Beit Shemesh joined the sites, #785; 1950-03-15 before GDD Phase 4 PR 6's veteran; 1949-03-15 before GDD Phase 4 PR 1, when it was the only site; 1949-06-15 before GDD Phase 3 PR 1)
+ [InlineData("first_new_yishuv", "1951-02-15")] // R-OBJ-003: the turn the reference player builds Mefalsim (1950-03-15 before the ministers' GDD-system multipliers, R-MIN-002, #808; 1949-09-15 before Kiryat Shmona and Beit Shemesh joined the sites, #785; 1950-03-15 before GDD Phase 4 PR 6's veteran; 1949-03-15 before GDD Phase 4 PR 1, when it was the only site; 1949-06-15 before GDD Phase 3 PR 1)
[InlineData("maabarot_policy", "1950-04-15")]
[InlineData("law_of_return", "1950-07-15")]
[InlineData("clothing_rationing_1950", "1950-07-15")]
diff --git a/sim/Statecraft.Sim.Tests/MinistersGddTests.cs b/sim/Statecraft.Sim.Tests/MinistersGddTests.cs
new file mode 100644
index 000000000..800fea552
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/MinistersGddTests.cs
@@ -0,0 +1,295 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+using Xunit;
+
+/// <summary>The ministers on the GDD systems (D-H3; #808's first slice: Phase 7 PR 4 of
+/// docs/superpowers/plans/2026-10-15-gdd-phase-7.md): R-MIN-001 (each named system reads its office's multiplier,
+/// Q-MIN-1), R-MIN-002 (the multiplier scales output and progress per turn, rounded by the one stated rule: floor with
+/// carry, so no fraction of a turn or a person enters the state, Q-MIN-2) and R-MIN-003 (an ended office reads its named
+/// successor, or is neutral 1.0 with none, Q-MIN-3). Corridors and military training stay unmapped until #870 and #742.</summary>
+public class MinistersGddTests
+{
+ /// <summary>The base GDD fixture plus the three offices of the slice, each with a budget line, and the
+ /// minister_systems map. The budget gives the named office the whole budget (a factor of 1.5), so a competence-10
+ /// holder multiplies by 1.5, a competence-4 one by 1.05 and a vacant office by 0.75.</summary>
+ const string Offices = @"
+offices:
+ - id: prime_minister
+ title: Prime Minister
+ - id: defense_minister
+ title: Minister of Defense
+ - id: finance_minister
+ title: Minister of Finance
+ - id: agriculture_minister
+ title: Minister of Agriculture
+ - id: immigration_minister
+ title: Minister of Immigration
+";
+
+ static readonly string Able = @"
+ - id: able_agri
+ name: Able Agri
+ living: false
+ competence: 10
+ loyalty: 9
+ offices:
+ - office: agriculture_minister
+ from: 1948-05-14
+";
+ static readonly string Lazy = @"
+ - id: lazy_agri
+ name: Lazy Agri
+ living: false
+ competence: 4
+ loyalty: 5
+ offices:
+ - office: agriculture_minister
+ from: 1948-05-14
+";
+
+ static readonly string Map = @"
+ minister_systems:
+ housing_construction: labour_minister
+ industry_construction: labour_minister
+ field_work: agriculture_minister
+ yishuv_work: agriculture_minister
+ absorption: immigration_minister
+";
+
+ /// <summary>The GDD fixture with the map and the named office holders; the named office owns a fully funded budget
+ /// line (a 1.5 factor), the other line unfunded.</summary>
+ static Content Town(string people = "", string offices = Offices, string budget = "agriculture_minister",
+ string? sites = null, string? prefix = null)
+ {
+ var extra = new Dictionary<string, string>
+ {
+ ["offices.yaml"] = offices + " - id: labour_minister\n title: Minister of Labour\n",
+ ["people.yaml"] = Fixture.Files["people.yaml"] + people,
+ ["rules.yaml"] = Fixture.Files["rules.yaml"]
+ .Replace("map_action: 1 }", Fixture.GddCosts)
+ .Replace("budget_start: { finance_minister: 1.0 }", $"budget_start: {{ {budget}: 1.0, finance_minister: 0.0 }}")
+ + Fixture.GddRules + Map,
+ };
+ if (sites != null) extra["sites.yaml"] = (prefix ?? "") + sites;
+ return ContentLoader.Load(Fixture.Write(Fixture.Gdd(extra)));
+ }
+
+ static StepResult Step(Content c, GameState s, params Command[] commands) => Simulation.Step(c, s, commands);
+
+ static GameState WithHalutz(Content c, out int id)
+ {
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ id = s.NextId++;
+ s.Units.Add(id, new Unit(id, "halutz", 1, 0));
+ return s;
+ }
+
+ // R-MIN-001, R-MIN-002
+ [Fact]
+ public void AnAbleMinisterChangesTheSystem()
+ {
+ // Two states that differ only in who holds agriculture_minister. A yishuv takes build_yishuv_turns = 3 turns.
+ // The able holder multiplies progress by 1.5: 1.5, then 3.0 accumulated - built in 2 turns, 0.5 carried nowhere
+ // once built. The lazy holder multiplies by 1.05: 1.05, 2.10, 3.15 - built in 3 turns. No minister: 3 turns.
+ var ableC = Town(Able);
+ var s = WithHalutz(ableC, out var id);
+ s = Step(ableC, s, new PioneerWork(id, Projects.BuildYishuv, "site_a")).State;
+ Assert.Equal(2, s.Sites["site_a"].TurnsLeft);
+ Assert.Equal(0.5, s.Sites["site_a"].Progress, 9);
+ s = Step(ableC, s).State;
+ Assert.NotNull(s.Sites["site_a"].BuiltOn); // built on the second turn
+
+ var lazyC = Town(Lazy);
+ s = WithHalutz(lazyC, out id);
+ s = Step(lazyC, s, new PioneerWork(id, Projects.BuildYishuv, "site_a")).State;
+ Assert.Equal(2, s.Sites["site_a"].TurnsLeft);
+ Assert.Equal(0.05, s.Sites["site_a"].Progress, 9);
+ s = Step(lazyC, s).State;
+ Assert.Null(s.Sites["site_a"].BuiltOn); // still building after two turns
+ s = Step(lazyC, s).State;
+ Assert.NotNull(s.Sites["site_a"].BuiltOn); // built on the third
+
+ var noneC = Town();
+ s = WithHalutz(noneC, out id);
+ s = Step(noneC, s, new PioneerWork(id, Projects.BuildYishuv, "site_a")).State;
+ Assert.Equal(3, s.Sites["site_a"].TurnsLeft); // a vacant office multiplies by 0.75: no whole turn yet
+ Assert.Equal(0.75, s.Sites["site_a"].Progress, 9);
+ }
+
+ // R-MIN-002
+ [Fact]
+ public void RoundingIsStated()
+ {
+ // A vacant office multiplies by 0.75 (competence 0, budget 1.5): the yishuv gains 0.75 a turn, and only whole
+ // turns leave the accumulator: 3, 2, 1 turns to go with 0.75, 0.5, 0.25 carried, built on the fourth turn. No
+ // fraction of a turn is ever a turn to go, and the people below stay whole groups.
+ var c = Town();
+ var s = WithHalutz(c, out var id);
+ s = Step(c, s, new PioneerWork(id, Projects.BuildYishuv, "site_a")).State;
+ Assert.Equal((3, 0.75), (s.Sites["site_a"].TurnsLeft, s.Sites["site_a"].Progress));
+ s = Step(c, s).State;
+ Assert.Equal((2, 0.5), (s.Sites["site_a"].TurnsLeft, s.Sites["site_a"].Progress));
+ s = Step(c, s).State;
+ Assert.Equal((1, 0.25), (s.Sites["site_a"].TurnsLeft, s.Sites["site_a"].Progress));
+ s = Step(c, s).State;
+ Assert.NotNull(s.Sites["site_a"].BuiltOn);
+
+ // The same floor with carry houses whole groups: 5 refugees at 0.75 house 3, and 2 wait.
+ c = Town(budget: "immigration_minister");
+ s = Simulation.NewGame(c, 1, Mode.Historical);
+ var x = s.Cities["town_a"];
+ s.Cities["town_a"] = x.WithCounts(x.Civilians, x.Employed, 5);
+ var before = x.Civilians + 5;
+ var res = Step(c, s);
+ s = res.State;
+ x = s.Cities["town_a"];
+ Assert.Equal(2, x.Refugees);
+ Assert.Equal(before, x.Civilians + x.Refugees);
+ Assert.Contains(res.Why, w => w.System == "city" && w.Message == "Town A: 3 groups of immigrants housed");
+ }
+
+ // R-MIN-003
+ [Fact]
+ public void AVacantOrEndedOfficeIsAsStated()
+ {
+ // A vacant office that exists on the date keeps Multiplier's absent-holder rule: 0.5 competence. Here with the
+ // 1.5 budget factor, 5 refugees house floor(5 * 0.75) = 3.
+ var c = Town(budget: "immigration_minister");
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ var r = c.RulesAt(s.Date).Mvp!;
+ Assert.Equal(0.75, EffectsSystem.GddSystemMultiplier(c, s, r, EffectsSystem.AbsorptionSystem), 9);
+
+ // The office ended on the state's date (immigration_minister's real until is 8 October 1951): neutral 1.0,
+ // not the absent-holder 0.5 - every refugee is housed, as R-CITY-004 says.
+ var ended = Town(offices: Offices.Replace("- id: immigration_minister\n title: Minister of Immigration",
+ "- id: immigration_minister\n title: Minister of Immigration\n until: 1951-10-08"));
+ s = Simulation.NewGame(ended, 1, Mode.Historical);
+ s.Date = new DateTime(1951, 11, 15);
+ r = c.RulesAt(s.Date).Mvp!;
+ Assert.Equal(1.0, EffectsSystem.GddSystemMultiplier(ended, s, ended.RulesAt(s.Date).Mvp!, EffectsSystem.AbsorptionSystem), 9);
+ var x = s.Cities["town_a"];
+ s.Cities["town_a"] = x.WithCounts(x.Civilians, x.Employed, 5);
+ s = Step(ended, s).State;
+ Assert.Equal(0, s.Cities["town_a"].Refugees);
+
+ // An ended office with a named successor reads the successor's multiplier (Q-MIN-3).
+ var succeeded = Town(Able.Replace("agriculture_minister", "interior_minister"), budget: "interior_minister",
+ offices: Offices.Replace("- id: immigration_minister\n title: Minister of Immigration",
+ "- id: immigration_minister\n title: Minister of Immigration\n until: 1951-10-08\n successor: interior_minister")
+ + " - id: interior_minister\n title: Minister of Internal Affairs\n");
+ s = Simulation.NewGame(succeeded, 1, Mode.Historical);
+ s.Date = new DateTime(1951, 11, 15);
+ Assert.Equal(1.5, EffectsSystem.GddSystemMultiplier(succeeded, s, succeeded.RulesAt(s.Date).Mvp!, EffectsSystem.AbsorptionSystem), 9);
+ }
+
+ // R-MIN-001: a system the map does not name is neutral.
+ [Fact]
+ public void AnUnmappedSystemIsNeutral()
+ {
+ // A camp is no mapped system's work in this slice: it takes build_camp_turns = 2 turns, able minister or not.
+ var c = Town(Able, sites: Fixture.GddSites.Replace("sites:\n", "") + @"
+ - id: site_camp
+ name: Site Camp
+ name_he: אתר ג
+ q: 3
+ r: 0
+ kinds: [military_camp]
+ city: town_a
+ sources:
+ - { url: ""https://example.org/site_camp"", checked: 2026-10-14 }
+ status: fact-checked
+", prefix: "sites:\n");
+ var s = WithHalutz(c, out var id);
+ s = Step(c, s, new PioneerWork(id, Projects.BuildCamp, "site_camp")).State;
+ Assert.Equal((1, 0.0), (s.Sites["site_camp"].TurnsLeft, s.Sites["site_camp"].Progress));
+ s = Step(c, s).State;
+ Assert.NotNull(s.Sites["site_camp"].BuiltOn);
+ }
+
+ // R-MIN-001: the loader refuses a map that names an unknown office.
+ [Fact]
+ public void TheLoaderRefusesAnUnknownOfficeInTheMap()
+ {
+ var bad = new Dictionary<string, string>
+ {
+ ["rules.yaml"] = Fixture.Files["rules.yaml"].Replace("map_action: 1 }", Fixture.GddCosts)
+ + Fixture.GddRules + " minister_systems:\n absorption: no_such_minister\n",
+ };
+ var e = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(Fixture.Gdd(bad))));
+ Assert.Contains("unknown office 'no_such_minister'", e.Message);
+ }
+
+ // R-MIN-001 (Q-MIN-1): the real content maps the decided systems.
+ [Fact]
+ public void TheRealContentMapsTheDecidedSystems()
+ {
+ var m = ContentLoader.Load(RealContentTests.ContentRoot()).Rules.Mvp!.MinisterSystems;
+ Assert.Equal(new Dictionary<string, string>
+ {
+ ["housing_construction"] = "labour_minister",
+ ["industry_construction"] = "labour_minister",
+ ["field_work"] = "agriculture_minister",
+ ["yishuv_work"] = "agriculture_minister",
+ ["absorption"] = "immigration_minister",
+ }, m);
+ }
+
+ // The live site ETA must match the resolver, including saved carry and promotion after this turn's work.
+ [Theory]
+ [InlineData(false, "halutz", 0)]
+ [InlineData(true, "halutz", 0)]
+ [InlineData(false, "halutz", 3)]
+ [InlineData(false, "veteran_halutz", 0)]
+ [InlineData(true, "veteran_halutz", 0)]
+ public void AScaledSiteForecastMatchesEveryRemainingTurn(bool able, string type, int service)
+ {
+ var c = Town(able ? Able : "");
+ var s = WithHalutz(c, out var id);
+ s.Units[id] = new Unit(id, type, 1, 0, service);
+ var site = c.Sites.Single(x => x.Id == "site_a");
+ int Forecast(int left, double carry)
+ {
+ var hash = s.Hash();
+ var result = Projects.TurnsToBuild(c, s, id, site, left, carry);
+ Assert.Equal(hash, s.Hash()); // a forecast never advances the real state
+ return result;
+ }
+ var forecasts = new List<int> { Forecast(c.Rules.Mvp!.BuildYishuvTurns, 0) };
+ s = Step(c, s, new PioneerWork(id, Projects.BuildYishuv, site.Id)).State;
+ int actual = 1;
+ while (s.Sites[site.Id].BuiltOn == null && actual < 20)
+ {
+ var work = s.Sites[site.Id];
+ forecasts.Add(Forecast(work.TurnsLeft, work.Progress));
+ s = Step(c, s).State; actual++;
+ }
+ Assert.NotNull(s.Sites[site.Id].BuiltOn);
+ for (int i = 0; i < forecasts.Count; i++) Assert.Equal(actual - i, forecasts[i]);
+ }
+
+ [Fact]
+ public void AChangedMinisterUpdatesTheRemainingForecastWithoutLosingCarry()
+ {
+ var candidate = Lazy.Replace(" offices:\n - office: agriculture_minister\n from: 1948-05-14\n", "");
+ var c = Town(Able + candidate);
+ var s = WithHalutz(c, out var id);
+ var site = c.Sites.Single(x => x.Id == "site_a");
+ s = Step(c, s, new PioneerWork(id, Projects.BuildYishuv, site.Id)).State;
+ var work = s.Sites[site.Id];
+ Assert.Equal((2, 0.5), (work.TurnsLeft, work.Progress));
+ var before = s.Hash();
+ Assert.Equal(1, Projects.TurnsToBuild(c, s, id, site, work.TurnsLeft, work.Progress));
+ Assert.Equal(before, s.Hash());
+ Assert.Null(Cabinet.Appoint(c, s, "agriculture_minister", "lazy_agri", new List<Cause>()));
+ before = s.Hash();
+ Assert.Equal(2, Projects.TurnsToBuild(c, s, id, site, work.TurnsLeft, work.Progress));
+ Assert.Equal(before, s.Hash());
+ s = Step(c, s).State;
+ Assert.Null(s.Sites[site.Id].BuiltOn);
+ s = Step(c, s).State;
+ Assert.NotNull(s.Sites[site.Id].BuiltOn);
+ }
+
+}
diff --git a/sim/Statecraft.Sim.Tests/ObjectivesTests.cs b/sim/Statecraft.Sim.Tests/ObjectivesTests.cs
index a5c34d6bd..291ea31bb 100644
--- a/sim/Statecraft.Sim.Tests/ObjectivesTests.cs
+++ b/sim/Statecraft.Sim.Tests/ObjectivesTests.cs
@@ -270,7 +270,7 @@ eras:
Assert.Equal("absorb_immigrants", Real.Events.Single(e => e.Id == o.Card).Objective);
}
- // R-OBJ-001 to R-OBJ-003 in the golden run: the reference player builds Mefalsim on 15 March 1950, after its 12 June 1949
+ // R-OBJ-001 to R-OBJ-003 in the golden run: the reference player builds Mefalsim on 15 February 1951, after its 12 June 1949
// founding, so the first new yishuv scores 100 with no early bonus (D-B2), and its card fires and is answered.
// Since GDD Phase 3 PR 1 the cities start with every job filled (Q-START-1), so the player trains its halutz group on the
// first turn instead of on 15 August 1948 (ReferencePlayerTests); before, it built on 15 June 1949 and scored 100.
@@ -280,10 +280,11 @@ eras:
var s = GoldenRun.Play(Real, GoldenRun.Until1952);
var built = s.Sites["mefalsim"].BuiltOn!.Value;
// Since Phase 4 PR 1 (#785) the reference player builds the yishuv sites in id order, one after another as its halutzim
- // come free: Beit Kama and Gilat first. Since Phase 4 PR 6 (#790) its group is a veteran after Beit Kama and builds in
- // 3 turns, so Mefalsim was built in September 1949 (March 1950 before that). Since Beit Shemesh and Kiryat Shmona joined
- // the sites (#785), they come before Mefalsim in id order, so it is built in March 1950, after its 12 June 1949 founding.
- Assert.Equal(new DateTime(1950, 3, 15), built);
+ // come free: Beit Kama and Gilat first. Since Phase 4 PR 6 (#790) its group is a veteran after Beit Kama; with the
+ // Agriculture minister's multiplier (R-MIN-002, #808) a veteran's build is 5 turns (2 x 0.624 = 1.248 a turn, the carry
+ // kept), so Mefalsim is built in February 1951 (March 1950 before the ministers, September 1949 before that) - still
+ // after its 12 June 1949 founding.
+ Assert.Equal(new DateTime(1951, 2, 15), built);
Assert.Equal(built, s.Objectives["first_new_yishuv"]);
Assert.Equal(100, s.Score); // D-B6; no D-B2 bonus, as it is built after the reference date
Assert.Equal("continue", s.ChosenOptions["first_new_yishuv"]);
diff --git a/sim/Statecraft.Sim.Tests/ProjectsTests.cs b/sim/Statecraft.Sim.Tests/ProjectsTests.cs
index 105429e46..995e422df 100644
--- a/sim/Statecraft.Sim.Tests/ProjectsTests.cs
+++ b/sim/Statecraft.Sim.Tests/ProjectsTests.cs
@@ -198,24 +198,30 @@ public class ProjectsTests
}
/// <summary>The timing rule, the same reading of D-A6 as training's (R-TRAIN-003): the turn of the order is the first build
- /// turn, so with build_yishuv_turns 6 an order on turn T is built at the end of turn T+5.</summary>
- // R-SITE-001, R-SITE-003
+ /// turn. R-MIN-002 scales the progress: Zisling's Agriculture multiplier is (0.5 + 6/20) x (0.5 + 0.07 x 8/2) = 0.8 x 0.78 =
+ /// 0.624, so the 6 turns of work accumulate 0.624, 1.248, 1.872, 2.496, 3.12, 3.744 - the halutz is a veteran from the end
+ /// of the sixth turn (R-VET-001, 6 turns of service) and adds 2 x 0.624 = 1.248 a turn from the seventh (R-VET-002):
+ /// 4.992, 6.24 - so an order on turn T is built at the end of turn T+7. (Six turns, and T+5, before the ministers.)</summary>
+ // R-SITE-001, R-SITE-003, R-MIN-002
[Fact]
- public void AnOrderOnTurnTWithSixTurnsIsBuiltAtTheEndOfTurnTPlusFive()
+ public void AnOrderOnTurnTWithSixTurnsIsBuiltAtTheEndOfTurnTPlusSeven()
{
Assert.Equal(6, Mvp.RulesAt(Mvp.Eras[0].From).Mvp!.BuildYishuvTurns);
var s = Simulation.NewGame(Mvp, GoldenRun.Seed, Mode.Historical);
var id = s.NextId++;
s.Units.Add(id, new Unit(id, "halutz", -3, 19));
s = Step(Mvp, s, Build(id, "mefalsim")).State; // the end of turn T
- for (int turn = 1; turn <= 4; turn++) s = Step(Mvp, s).State; // T+1 to T+4
+ for (int turn = 1; turn <= 6; turn++) s = Step(Mvp, s).State; // T+1 to T+6
Assert.Null(s.Sites["mefalsim"].BuiltOn);
- var built = Step(Mvp, s).State; // T+5
+ var built = Step(Mvp, s).State; // T+7
Assert.Equal(built.Date, built.Sites["mefalsim"].BuiltOn);
+ Assert.Equal(new DateTime(1949, 1, 15), built.Sites["mefalsim"].BuiltOn);
}
- /// <summary>Q-SITE-1 (#782): every MVP yishuv site builds as Mefalsim does, in build_yishuv_turns from the order.</summary>
- // R-SITE-001, R-SITE-003, R-SITE-004
+ /// <summary>Q-SITE-1 (#782): every MVP yishuv site builds as Mefalsim does: build_yishuv_turns of work from the
+ /// order, at the Agriculture minister's R-MIN-002 multiplier (0.624 while Zisling holds it), so T+7 as
+ /// AnOrderOnTurnTWithSixTurnsIsBuiltAtTheEndOfTurnTPlusSeven pins.</summary>
+ // R-SITE-001, R-SITE-003, R-SITE-004, R-MIN-002
[Theory]
[InlineData("beit_kama")]
[InlineData("beit_shemesh")]
@@ -231,7 +237,7 @@ public class ProjectsTests
var r = Step(Mvp, s, Build(id, site));
Assert.Empty(r.Rejected);
s = r.State;
- for (int turn = 1; turn <= 4; turn++) s = Step(Mvp, s).State;
+ for (int turn = 1; turn <= 6; turn++) s = Step(Mvp, s).State;
Assert.Null(s.Sites[site].BuiltOn);
var built = Step(Mvp, s).State;
Assert.Equal(built.Date, built.Sites[site].BuiltOn);
diff --git a/sim/Statecraft.Sim.Tests/VeteranTests.cs b/sim/Statecraft.Sim.Tests/VeteranTests.cs
index 14f35411f..ce28fed84 100644
--- a/sim/Statecraft.Sim.Tests/VeteranTests.cs
+++ b/sim/Statecraft.Sim.Tests/VeteranTests.cs
@@ -52,8 +52,11 @@ public class VeteranTests
Assert.NotNull(built.Sites["site_a"].BuiltOn);
}
- // R-VET-001: one completed yishuv makes a veteran pioneer in the real content (veteran_halutz_service is
- // build_yishuv_turns), and the turn the build finishes counts.
+ // R-VET-001: veteran_halutz_service turns of service make a veteran pioneer in the real content, and the count is
+ // turns worked, not the build's length: with the Agriculture minister's R-MIN-002 multiplier (0.624, Zisling) the
+ // first yishuv takes 8 turns, so the promotion lands mid-build at the end of the sixth - and the veteran's faster
+ // progress (R-VET-002: 2 x 0.624 a turn from the seventh) is what finishes the build on the eighth. (The build
+ // finished on the sixth turn before the ministers, the promotion with it.)
[Fact]
public void OneYishuvMakesAVeteranInTheRealContent()
{
@@ -63,9 +66,13 @@ public class VeteranTests
var s = WithUnit(c, "halutz", out var id);
var site = c.Sites.First(x => x.Kinds.Contains(Projects.YishuvKind)).Id;
s = Step(c, s, new PioneerWork(id, Projects.BuildYishuv, site)).State;
- for (int i = 1; i < r.BuildYishuvTurns; i++) s = Step(c, s).State;
- Assert.NotNull(s.Sites[site].BuiltOn);
+ for (int i = 1; i < r.VeteranHalutzService; i++) s = Step(c, s).State; // 6 turns of service
+ Assert.Null(s.Sites[site].BuiltOn); // the build is still going: 3.744 of 6 turns of work
Assert.Equal("veteran_halutz", s.Units[id].Type);
+ s = Step(c, s).State; // the veteran's 1.248: 4.992
+ Assert.Null(s.Sites[site].BuiltOn);
+ s = Step(c, s).State; // 6.24: built
+ Assert.NotNull(s.Sites[site].BuiltOn);
}
// R-VET-002: a veteran may start pioneer work, and the same build finishes sooner, by veteran_progress turns a turn.
@@ -107,12 +114,12 @@ public class VeteranTests
var s = Simulation.NewGame(c, 1, Mode.Historical);
var id = s.NextId++;
s.Units.Add(id, new Unit(id, type, 1, 0, service));
- Assert.Equal(expected, Projects.TurnsToBuild(c, s, id, c.Rules.Mvp!.BuildYishuvTurns));
+ Assert.Equal(expected, Projects.TurnsToBuild(c, s, id, c.Sites.Single(x => x.Id == "site_a"), c.Rules.Mvp!.BuildYishuvTurns, 0));
s = Step(c, s, Build(id)).State;
for (int done = 1; ; done++)
{
if (s.Sites["site_a"].BuiltOn != null) { Assert.Equal(expected, done); break; }
- Assert.Equal(expected - done, Projects.TurnsToBuild(c, s, id, s.Sites["site_a"].TurnsLeft)); // the turns left under way
+ Assert.Equal(expected - done, Projects.TurnsToBuild(c, s, id, c.Sites.Single(x => x.Id == "site_a"), s.Sites["site_a"].TurnsLeft, s.Sites["site_a"].Progress)); // the turns left under way
s = Step(c, s).State;
}
}
diff --git a/sim/Statecraft.Sim.Tests/golden/hash1950.txt b/sim/Statecraft.Sim.Tests/golden/hash1950.txt
index 707f28340..3e225c10c 100644
--- a/sim/Statecraft.Sim.Tests/golden/hash1950.txt
+++ b/sim/Statecraft.Sim.Tests/golden/hash1950.txt
@@ -1,9 +1,9 @@
1950-01-15;1948;Historical;20;
ind{
food_supply=0.8886718750000001 [3FEC700000000001]
- housing=0.09316824128271463 [3FB7D9DFB555C8E1]
+ housing=0.106156810303452 [3FBB2D17BC8041AE]
intl_standing=0.8100000000000003 [3FE9EB851EB851EE]
- morale=0.5017933100237988 [3FE00EB0D7FCEBF8]
+ morale=0.5049571214041069 [3FE0289BD64A039C]
security=0.5042220244102726 [3FE022963A187B2A]
pol{
border_settlement=0.2 [3FC999999999999A]
@@ -14,11 +14,11 @@ eff{
border_villages_secure=0.03922202441027243 [3FA414E8C040046D]
building_houses=0.08452919104400287 [3FB5A3B47F17614D]
food_lifts_cohesion=0.08774605560302737 [3FB67686872B020E]
- homes_lift_morale=0.025196874385530456 [3F99CD359DCA020A]
+ homes_lift_morale=0.02793111941413326 [3F9C99F9B1B28ED8]
rationing_feeds=0.33867187500000007 [3FD5ACCCCCCCCCCE]
rationing_grates=-0.15 [BFC3333333333333]
safety_lifts_morale=0.050367774522404846 [3FA9C9CE10B12AF4]
- work_lifts_cohesion=0.028482605512836157 [3F9D2A8B4CBAE170]
+ work_lifts_cohesion=0.028912171864541484 [3F9D9B2702754931]
shift{
food_supply=0.15000000000000002 [3FC3333333333334]
housing=0 [0000000000000000]
@@ -44,11 +44,11 @@ pop{
sit[
housing_crisis
treasury=0 [0000000000000000]
-debt=91.50032828298674 [4056E00560EB2C48]
+debt=87.50032828298674 [4055E00560EB2C48]
fx=94.52989672613671 [4057A1E9D3F540F0]
rung=2;cf=0;
mob=0.05 [3FA999999999999A]
-stab=0.5002035568980255 [3FE001AAE3C70961]
+stab=0.5039736980546528 [3FE0208D72E60B92]
att=4 [4010000000000000]
fired[
altalena
@@ -98,32 +98,30 @@ chosen{
appt{
under=;
map[
-mapturn=1949-08-15:1;
+mapturn=1949-10-15:1;
over=
city{
- hadera=12,5,18,5,0,c0 [0000000000000000]
- haifa=99,42,148,42,3,c0 [0000000000000000]
- jerusalem=84,29,125,29,3,c0 [0000000000000000]
- netanya=12,5,18,5,0,c0 [0000000000000000]
- petah_tikva=22,10,33,10,1,c0 [0000000000000000]
- rehovot=13,5,19,5,1,c0 [0000000000000000]
- rishon_lezion=10,5,15,5,1,c0 [0000000000000000]
+ hadera=12,5,17,5,1,c0.0835197155785391 [3FB5618C4EFB25E8]
+ haifa=99,42,147,42,4,c0 [0000000000000000]
+ jerusalem=84,29,124,29,4,c0 [0000000000000000]
+ netanya=12,5,17,5,1,c0.09340982546864895 [3FB7E9B4D1834E68]
+ petah_tikva=22,10,32,10,2,c0.035572641445731024 [3FA23693C7489350]
+ rehovot=13,5,18,5,2,c0.06768557422969179 [3FB153D77FBA3DE0]
+ rishon_lezion=10,5,14,5,2,c0.08316683316683317 [3FB54A6BEC903D61]
rosh_pinna=1,0,1,0,0,c0.35 [3FD6666666666666]
- safed=2,1,3,1,0,c0 [0000000000000000]
- tel_aviv=253,106,370,106,9,c0.016845827788914483 [3F9140085DB5B1B4]
- tiberias=6,2,9,2,0,c0 [0000000000000000]
- zikhron_yaakov=2,1,3,1,0,c0 [0000000000000000]
+ safed=2,1,2,1,1,c0.35 [3FD6666666666666]
+ tel_aviv=253,106,369,106,10,c0.017477652100338414 [3F91E5A960BA2ED0]
+ tiberias=6,2,8,2,1,c0.18928571428571433 [3FC83A83A83A83AA]
+ zikhron_yaakov=2,1,2,1,1,c0.35 [3FD6666666666666]
units[
1:veteran_halutz@-3,19/6
site{
- beit_kama=done,1949-03-15
- beit_shemesh=done,1949-06-15
- gilat=done,1949-09-15
- kiryat_shmona=done,1949-12-15
- mefalsim=b,1,4
+ beit_kama=done,1949-06-15
+ beit_shemesh=done,1949-11-15
+ gilat=b,1,4,3FE4DD2F1A9FBE78
cproj[
- 2:housing@tel_aviv,-4,20/done,1949-08-15
- 3:housing@tel_aviv,-3,19/1
+ 2:housing@tel_aviv,-4,20/done,1949-10-15
+ 3:housing@tel_aviv,-3,19/4,3FDB851EB851EB88
next=4
food=3003,1001,0
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim.Tests/golden/hash1952.txt b/sim/Statecraft.Sim.Tests/golden/hash1952.txt
index 3f1e57c5d..7380859be 100644
--- a/sim/Statecraft.Sim.Tests/golden/hash1952.txt
+++ b/sim/Statecraft.Sim.Tests/golden/hash1952.txt
@@ -1,9 +1,9 @@
1952-01-15;1948;Historical;44;
ind{
- food_supply=0.8556594723429 [3FEB618FF947363F]
- housing=0.08504947742483628 [3FB5C5CD7414E141]
+ food_supply=0.8555635490815091 [3FEB60C6CEDE8D7F]
+ housing=0.08527449992708651 [3FB5D48CB45E9D83]
intl_standing=0.8300000000000003 [3FEA8F5C28F5C292]
- morale=0.4915607767294802 [3FDF75BB55032A9A]
+ morale=0.49164470757140455 [3FDF771B5D115298]
security=0.5061322526321603 [3FE0323C441030A6]
pol{
border_settlement=0.2 [3FC999999999999A]
@@ -14,14 +14,14 @@ eff{
border_villages_secure=0.04113225263216018 [3FA50F495FBB5C36]
building_houses=0.08504947742483629 [3FB5C5CD7414E142]
food_lifts_cohesion=0.08899999973526929 [3FB6C8B43834FD50]
- homes_lift_morale=0.01276719658700311 [3F8A25B01E6C188A]
+ homes_lift_morale=0.012822260189952167 [3F8A428EA169C610]
rationing_feeds=0.3399999999208376 [3FD5C28F5C133334]
rationing_grates=-0.15 [BFC3333333333333]
safety_lifts_morale=0.05054370052651369 [3FA9E0DD298F75A0]
- work_lifts_cohesion=0.019249879880694112 [3F93B63D92287534]
+ work_lifts_cohesion=0.019278747119669364 [3F93BDCED18C1E3E]
shift{
food_supply=0.15000000000000002 [3FC3333333333334]
- housing=-1.3877787807814457E-17 [BC70000000000000]
+ housing=0 [0000000000000000]
intl_standing=0.3300000000000003 [3FD51EB851EB8524]
morale=-0.08000000000000007 [BFB47AE147AE1480]
security=0.16500000000000015 [3FC51EB851EB8524]
@@ -45,11 +45,11 @@ sit[
fx_crisis
housing_crisis
treasury=0 [0000000000000000]
-debt=223.89012071283815 [406BFC7BDE6EE43A]
+debt=211.89012071283815 [406A7C7BDE6EE43A]
fx=-12.990431328096559 [C029FB19D0A63796]
rung=2;cf=0;
mob=0.05 [3FA999999999999A]
-stab=0.44359186096314507 [3FDC63CF1DE6F174]
+stab=0.44381788073928824 [3FDC67831CC9EFF7]
att=4 [4010000000000000]
fired[
altalena
@@ -119,7 +119,7 @@ chosen{
appt{
under=;
map[
-mapturn=1951-08-15:1;
+mapturn=1951-10-15:1;
over=mvp_ended
city{
hadera=12,5,26,5,0,c0 [0000000000000000]
@@ -129,38 +129,31 @@ city{
petah_tikva=22,10,48,10,0,c0 [0000000000000000]
rehovot=13,5,28,5,0,c0 [0000000000000000]
rishon_lezion=10,5,22,5,0,c0 [0000000000000000]
- rosh_pinna=1,0,2,0,0,c0 [0000000000000000]
+ rosh_pinna=1,0,2,0,0,c0.12499999999999996 [3FBFFFFFFFFFFFFD]
safed=2,1,5,1,0,c0 [0000000000000000]
- tel_aviv=273,106,540,106,4,c0 [0000000000000000]
+ tel_aviv=268,106,540,106,4,c0 [0000000000000000]
tiberias=6,2,13,2,0,c0 [0000000000000000]
zikhron_yaakov=2,1,4,1,0,c0 [0000000000000000]
units[
1:veteran_halutz@-3,19/6
site{
- beit_kama=done,1949-03-15
- beit_kama_field=done,1950-08-15
- beit_shemesh=done,1949-06-15
- beit_shemesh_field=done,1950-10-15
- camp_80=done,1951-09-15
- gilat=done,1949-09-15
- gilat_field=done,1950-12-15
- kiryat_shmona=done,1949-12-15
- kiryat_shmona_field=done,1951-02-15
- mefalsim=done,1950-03-15
- mefalsim_field=done,1951-04-15
- reim=done,1950-06-15
- reim_field=done,1951-06-15
- tzrifin=done,1951-12-15
+ beit_kama=done,1949-06-15
+ beit_kama_field=done,1951-10-15
+ beit_shemesh=done,1949-11-15
+ beit_shemesh_field=done,1952-01-15
+ gilat=done,1950-04-15
+ kiryat_shmona=done,1950-09-15
+ mefalsim=done,1951-02-15
+ reim=done,1951-07-15
cproj[
- 2:housing@tel_aviv,-4,20/done,1949-08-15
- 3:housing@tel_aviv,-3,19/done,1950-02-15
- 4:housing@tel_aviv,-3,20/done,1950-08-15
- 5:housing@tel_aviv,-2,18/done,1951-02-15
- 6:housing@tel_aviv,-2,19/done,1951-08-15
- 7:housing@haifa,4,9/1
-next=8
+ 2:housing@tel_aviv,-4,20/done,1949-10-15
+ 3:housing@tel_aviv,-3,19/done,1950-06-15
+ 4:housing@tel_aviv,-3,20/done,1951-02-15
+ 5:housing@tel_aviv,-2,18/done,1951-10-15
+ 6:housing@tel_aviv,-2,19/4,3FDB851EB851EB88
+next=7
obj{
- first_new_yishuv=1950-03-15
+ first_new_yishuv=1951-02-15
score=100
-food=2738,1390,0
+food=2734,1390,0
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim.Tests/golden/manifest.txt b/sim/Statecraft.Sim.Tests/golden/manifest.txt
index abc786676..bdf3f4590 100644
--- a/sim/Statecraft.Sim.Tests/golden/manifest.txt
+++ b/sim/Statecraft.Sim.Tests/golden/manifest.txt
@@ -2,11 +2,11 @@
# Tests read this file. To accept a deliberate change: STATECRAFT_UPDATE_GOLDEN=1 dotnet test sim/Statecraft.sln
# rewrites this file, the snapshots and the GoldenRun.cs constants; then update docs/determinism.md and tools/web_check.py
# (GoldenManifestTests names any place that is out of date) and add a row to the rebaseline history.
-hash1950 4f1202cfa20e1f3cc7521c7b3baac386330b77fdbacc25928d781b1659747340
-hash1952 283349502eb580123fcea6bf64ca174f913627132a1325f3dbf00743435623e2
+hash1950 e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a
+hash1952 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde
smoke5 8d000459d26a08a49583adfc88c14799ce6e6f653dcecff1e30b5e737f0959aa
-scenario-reckless a0f094a16688042d2b71a02c29e2c637acad574391bfc8a22f38f2ebf15f42ba
-scenario-cautious a6108c91ccdea0977dc7937583378c2aefa1060f380566ae76f75ad719ea759d
-scenario-mvp-absorb-first dee4f0397b176ea6e9919dedc8f5b153370e4e6c3e9267a66d673fdb3d4f7adb
-mvp-end 283349502eb580123fcea6bf64ca174f913627132a1325f3dbf00743435623e2
-scenario-mvp-defeat e71076f7754e2a6da1eb91db7b509d4b87c02d1cb74ffb2db5ea60b97a0ecf48
+scenario-reckless d7dbcf75d3767cf2de0621de15f67c37068363060e3a0267cc185a590d01fe2d
+scenario-cautious 9a3d241ece9c896367c75c66e094019cd9b8e946bd14f7b083b19a3b483301ee
+scenario-mvp-absorb-first 234e32ee5219b7cc8f4a9e7a03c16c9f408b54c2ffe34e0face14cd1a2be4fbb
+mvp-end 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde
+scenario-mvp-defeat f3daaa70500cf86e741f5cc32475f9aa78d3b73b93fa87911f69e72f35a61eab
diff --git a/sim/Statecraft.Sim.Tests/golden/mvp-end.txt b/sim/Statecraft.Sim.Tests/golden/mvp-end.txt
index 3f1e57c5d..7380859be 100644
--- a/sim/Statecraft.Sim.Tests/golden/mvp-end.txt
+++ b/sim/Statecraft.Sim.Tests/golden/mvp-end.txt
@@ -1,9 +1,9 @@
1952-01-15;1948;Historical;44;
ind{
- food_supply=0.8556594723429 [3FEB618FF947363F]
- housing=0.08504947742483628 [3FB5C5CD7414E141]
+ food_supply=0.8555635490815091 [3FEB60C6CEDE8D7F]
+ housing=0.08527449992708651 [3FB5D48CB45E9D83]
intl_standing=0.8300000000000003 [3FEA8F5C28F5C292]
- morale=0.4915607767294802 [3FDF75BB55032A9A]
+ morale=0.49164470757140455 [3FDF771B5D115298]
security=0.5061322526321603 [3FE0323C441030A6]
pol{
border_settlement=0.2 [3FC999999999999A]
@@ -14,14 +14,14 @@ eff{
border_villages_secure=0.04113225263216018 [3FA50F495FBB5C36]
building_houses=0.08504947742483629 [3FB5C5CD7414E142]
food_lifts_cohesion=0.08899999973526929 [3FB6C8B43834FD50]
- homes_lift_morale=0.01276719658700311 [3F8A25B01E6C188A]
+ homes_lift_morale=0.012822260189952167 [3F8A428EA169C610]
rationing_feeds=0.3399999999208376 [3FD5C28F5C133334]
rationing_grates=-0.15 [BFC3333333333333]
safety_lifts_morale=0.05054370052651369 [3FA9E0DD298F75A0]
- work_lifts_cohesion=0.019249879880694112 [3F93B63D92287534]
+ work_lifts_cohesion=0.019278747119669364 [3F93BDCED18C1E3E]
shift{
food_supply=0.15000000000000002 [3FC3333333333334]
- housing=-1.3877787807814457E-17 [BC70000000000000]
+ housing=0 [0000000000000000]
intl_standing=0.3300000000000003 [3FD51EB851EB8524]
morale=-0.08000000000000007 [BFB47AE147AE1480]
security=0.16500000000000015 [3FC51EB851EB8524]
@@ -45,11 +45,11 @@ sit[
fx_crisis
housing_crisis
treasury=0 [0000000000000000]
-debt=223.89012071283815 [406BFC7BDE6EE43A]
+debt=211.89012071283815 [406A7C7BDE6EE43A]
fx=-12.990431328096559 [C029FB19D0A63796]
rung=2;cf=0;
mob=0.05 [3FA999999999999A]
-stab=0.44359186096314507 [3FDC63CF1DE6F174]
+stab=0.44381788073928824 [3FDC67831CC9EFF7]
att=4 [4010000000000000]
fired[
altalena
@@ -119,7 +119,7 @@ chosen{
appt{
under=;
map[
-mapturn=1951-08-15:1;
+mapturn=1951-10-15:1;
over=mvp_ended
city{
hadera=12,5,26,5,0,c0 [0000000000000000]
@@ -129,38 +129,31 @@ city{
petah_tikva=22,10,48,10,0,c0 [0000000000000000]
rehovot=13,5,28,5,0,c0 [0000000000000000]
rishon_lezion=10,5,22,5,0,c0 [0000000000000000]
- rosh_pinna=1,0,2,0,0,c0 [0000000000000000]
+ rosh_pinna=1,0,2,0,0,c0.12499999999999996 [3FBFFFFFFFFFFFFD]
safed=2,1,5,1,0,c0 [0000000000000000]
- tel_aviv=273,106,540,106,4,c0 [0000000000000000]
+ tel_aviv=268,106,540,106,4,c0 [0000000000000000]
tiberias=6,2,13,2,0,c0 [0000000000000000]
zikhron_yaakov=2,1,4,1,0,c0 [0000000000000000]
units[
1:veteran_halutz@-3,19/6
site{
- beit_kama=done,1949-03-15
- beit_kama_field=done,1950-08-15
- beit_shemesh=done,1949-06-15
- beit_shemesh_field=done,1950-10-15
- camp_80=done,1951-09-15
- gilat=done,1949-09-15
- gilat_field=done,1950-12-15
- kiryat_shmona=done,1949-12-15
- kiryat_shmona_field=done,1951-02-15
- mefalsim=done,1950-03-15
- mefalsim_field=done,1951-04-15
- reim=done,1950-06-15
- reim_field=done,1951-06-15
- tzrifin=done,1951-12-15
+ beit_kama=done,1949-06-15
+ beit_kama_field=done,1951-10-15
+ beit_shemesh=done,1949-11-15
+ beit_shemesh_field=done,1952-01-15
+ gilat=done,1950-04-15
+ kiryat_shmona=done,1950-09-15
+ mefalsim=done,1951-02-15
+ reim=done,1951-07-15
cproj[
- 2:housing@tel_aviv,-4,20/done,1949-08-15
- 3:housing@tel_aviv,-3,19/done,1950-02-15
- 4:housing@tel_aviv,-3,20/done,1950-08-15
- 5:housing@tel_aviv,-2,18/done,1951-02-15
- 6:housing@tel_aviv,-2,19/done,1951-08-15
- 7:housing@haifa,4,9/1
-next=8
+ 2:housing@tel_aviv,-4,20/done,1949-10-15
+ 3:housing@tel_aviv,-3,19/done,1950-06-15
+ 4:housing@tel_aviv,-3,20/done,1951-02-15
+ 5:housing@tel_aviv,-2,18/done,1951-10-15
+ 6:housing@tel_aviv,-2,19/4,3FDB851EB851EB88
+next=7
obj{
- first_new_yishuv=1950-03-15
+ first_new_yishuv=1951-02-15
score=100
-food=2738,1390,0
+food=2734,1390,0
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt b/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt
index 1da77e8d3..04e5ca80b 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-cautious.txt
@@ -1,9 +1,9 @@
1949-01-15;11400714819323200433;Historical;8;
ind{
food_supply=0.47968750000000004 [3FDEB33333333334]
- housing=0.41685506903832104 [3FDAADC0E22C4014]
+ housing=0.41912251055925737 [3FDAD2E738F7A4A9]
intl_standing=0.5 [3FE0000000000000]
- morale=0.6175347284969844 [3FE3C2D830E13DBF]
+ morale=0.6178523929802675 [3FE3C57261B360FC]
security=0.5086917724609377 [3FE04733F7CED918]
pol{
border_settlement=0.2 [3FC999999999999A]
@@ -14,11 +14,11 @@ eff{
border_villages_secure=0.033691772460937505 [3FA1400C49BA5E36]
building_houses=0.0722834300994873 [3FB2812AB851EB85]
food_lifts_cohesion=0.04756250000000001 [3FA85A1CAC083128]
- homes_lift_morale=0.06191260485593446 [3FAFB3024A220066]
+ homes_lift_morale=0.06197826633453369 [3FAFBB9D85F06F69]
rationing_feeds=0.07968750000000002 [3FB4666666666668]
rationing_grates=-0.06 [BFAEB851EB851EB8]
safety_lifts_morale=0.04761640136718752 [3FA8612D4D4024B6]
- work_lifts_cohesion=0.04044322227386246 [3FA4B4F95A05AEA4]
+ work_lifts_cohesion=0.04069522527854631 [3FA4D6012B597372]
shift{
food_supply=0 [0000000000000000]
housing=0 [0000000000000000]
@@ -47,7 +47,7 @@ debt=26.960591926047705 [403AF5E95A3B2D32]
fx=80.85238326859616 [4054368D728D91CC]
rung=5;cf=40;
mob=0.8 [3FE999999999999A]
-stab=0.6253697794522252 [3FE403077BD4EDE5]
+stab=0.6255260111471207 [3FE4044F2015932B]
att=4 [4010000000000000]
fired[
altalena
@@ -89,15 +89,15 @@ mapturn=0001-01-01:0;
over=
city{
hadera=12,5,12,5,1,c0.35 [3FD6666666666666]
- haifa=99,42,102,42,3,c0.34408823529411764 [3FD6058AA961B39F]
- jerusalem=84,29,87,29,3,c0.3430628803245436 [3FD5F4BE02DDCA5E]
+ haifa=99,42,101,42,4,c0.347029702970297 [3FD635BC123FDF8E]
+ jerusalem=84,29,86,29,4,c0.3465116279069767 [3FD62D3F1B62D3F1]
netanya=12,5,12,5,1,c0.35 [3FD6666666666666]
- petah_tikva=22,10,23,10,0,c0.3434782608695652 [3FD5FB8C3E54975F]
- rehovot=13,5,14,5,0,c0.33928571428571425 [3FD5B6DB6DB6DB6D]
+ petah_tikva=22,10,22,10,1,c0.35 [3FD6666666666666]
+ rehovot=13,5,13,5,1,c0.35 [3FD6666666666666]
rishon_lezion=10,5,10,5,1,c0.35 [3FD6666666666666]
rosh_pinna=1,0,1,0,0,c0.35 [3FD6666666666666]
safed=2,1,2,1,0,c0.35 [3FD6666666666666]
- tel_aviv=248,106,256,106,8,c0.34471009036144573 [3FD60FBAE92D0804]
+ tel_aviv=248,106,255,106,9,c0.3458823529411765 [3FD622EFBC895623]
tiberias=6,2,6,2,0,c0.35 [3FD6666666666666]
zikhron_yaakov=2,1,2,1,0,c0.35 [3FD6666666666666]
food=2253,751,0
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt
index 199d013fe..7b7c6a224 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-absorb-first.txt
@@ -1,9 +1,9 @@
1949-06-15;11400714819323200433;Historical;13;
ind{
food_supply=0.7200000000000001 [3FE70A3D70A3D70B]
- housing=0.33477730272214257 [3FD56CFDC7A89ED4]
+ housing=0.3475166797185584 [3FD63DB6998D2A6E]
intl_standing=0.7600000000000002 [3FE851EB851EB854]
- morale=0.4961955804901623 [3FDFC1AB1BA7FFB8]
+ morale=0.49803308924391254 [3FDFDFC62DA83896]
security=0.500599903035164 [3FE004EA167D566E]
pol{
border_settlement=0.2 [3FC999999999999A]
@@ -14,11 +14,11 @@ eff{
border_villages_secure=0.03559990303516388 [3FA23A26868DB8BB]
building_houses=0.08114833839274943 [3FB4C62333858794]
food_lifts_cohesion=0.047495117187500005 [3FA85147AE147AE2]
- homes_lift_morale=0.05648611356478082 [3FACEBBF74E0B44D]
+ homes_lift_morale=0.05778026214101628 [3FAD955FE07FFC50]
rationing_feeds=0.17 [3FC5C28F5C28F5C3]
rationing_grates=-0.15 [BFC3333333333333]
safety_lifts_morale=0.049817294571876544 [3FA981A705EC3DAE]
- work_lifts_cohesion=0.03239705516600502 [3FA09658C8D97234]
+ work_lifts_cohesion=0.032940415343519776 [3FA0DD90ED3BF121]
shift{
food_supply=0.15000000000000002 [3FC3333333333334]
housing=0 [0000000000000000]
@@ -47,7 +47,7 @@ debt=59.72606782031707 [404DDCEFCA53784C]
fx=94.29191537516759 [405792AEBDD362D7]
rung=2;cf=0;
mob=0.8 [3FE999999999999A]
-stab=0.5718469643325106 [3FE24C9201440018]
+stab=0.5736568241454453 [3FE25B658E5A9F03]
att=4 [4010000000000000]
fired[
altalena
@@ -96,17 +96,17 @@ map[
mapturn=0001-01-01:0;
over=
city{
- hadera=12,5,15,5,0,c0.2540659340659341 [3FD0429DC375D0F7]
- haifa=99,42,120,42,4,c0.2538443449593976 [3FD03EFC59F8028B]
- jerusalem=84,29,102,29,4,c0.25059889032971866 [3FD009CFED985273]
- netanya=12,5,14,5,1,c0.26263736263736265 [3FD0CF0CF0CF0CF1]
- petah_tikva=22,10,27,10,1,c0.2556018208844295 [3FD05BC7BD5FC984]
- rehovot=13,5,16,5,0,c0.24044642857142845 [3FCEC6F2D593BF9E]
- rishon_lezion=10,5,12,5,1,c0.2590909090909091 [3FD094F2094F2095]
+ hadera=12,5,14,5,1,c0.30549450549450546 [3FD38D38D38D38D3]
+ haifa=99,42,119,42,5,c0.26271460756874115 [3FD0D050EDEC1C23]
+ jerusalem=84,29,101,29,5,c0.26099666612029404 [3FD0B42B5C568228]
+ netanya=12,5,13,5,2,c0.3153846153846153 [3FD42F42F42F42F3]
+ petah_tikva=22,10,26,10,2,c0.2899013377926421 [3FD28DBE5738B4FD]
+ rehovot=13,5,15,5,1,c0.29785714285714276 [3FD3101767DCE433]
+ rishon_lezion=10,5,11,5,2,c0.32272727272727275 [3FD4A7904A7904A8]
rosh_pinna=1,0,1,0,0,c0.35 [3FD6666666666666]
- safed=2,1,3,1,0,c0.25 [3FD0000000000000]
- tel_aviv=248,106,302,90,10,c0.253441763530126 [3FD03863CD735B73],jobs=manual
- tiberias=6,2,7,2,0,c0.26428571428571435 [3FD0EA0EA0EA0EA2]
- zikhron_yaakov=2,1,3,1,0,c0.3 [3FD3333333333333]
+ safed=2,1,2,1,1,c0.35 [3FD6666666666666]
+ tel_aviv=248,106,301,90,11,c0.25696059790315773 [3FD0720ADD16B2E4],jobs=manual
+ tiberias=6,2,6,2,1,c0.35 [3FD6666666666666]
+ zikhron_yaakov=2,1,2,1,1,c0.35 [3FD6666666666666]
food=2556,852,0
arms=12
\ No newline at end of file
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt
index bac1bc93f..9f898d719 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-mvp-defeat.txt
@@ -1,9 +1,9 @@
1952-01-15;8709371129873692656;Historical;44;
ind{
food_supply=0 [0000000000000000]
- housing=0.08504947742483629 [3FB5C5CD7414E142]
+ housing=0.08527429756872115 [3FB5D4894F3F3D56]
intl_standing=0.8100000000000003 [3FE9EB851EB851EE]
- morale=0.6946063955988723 [3FE63A3731161129]
+ morale=0.6946902205214107 [3FE63AE6FC3FB212]
security=0.5061322526321603 [3FE0323C441030A6]
pol{
border_settlement=0.2 [3FC999999999999A]
@@ -14,14 +14,14 @@ eff{
border_villages_secure=0.04113225263216018 [3FA50F495FBB5C36]
building_houses=0.08504947742483629 [3FB5C5CD7414E142]
food_lifts_cohesion=0.012063175589914928 [3F88B49405281EDE]
- homes_lift_morale=0.012767192434855364 [3F8A25AF8FC16B04]
+ homes_lift_morale=0.01282220528531898 [3F8A428742E78348]
rationing_feeds=0 [0000000000000000]
rationing_grates=0 [0000000000000000]
safety_lifts_morale=0.05054370052651369 [3FA9E0DD298F75A0]
- work_lifts_cohesion=0.0192323270475882 [3F93B1A39EC80E6F]
+ work_lifts_cohesion=0.019261139119662984 [3F93B9312A691F60]
shift{
food_supply=-0.04999999999999999 [BFA9999999999998]
- housing=0 [0000000000000000]
+ housing=-2.7755575615628914E-17 [BC80000000000000]
intl_standing=0.3100000000000003 [3FD3D70A3D70A3DC]
morale=0.050000000000000044 [3FA99999999999A0]
security=0.16500000000000015 [3FC51EB851EB8524]
@@ -50,7 +50,7 @@ debt=339.14012071283804 [4075323DEF37721B]
fx=-74.99043132809655 [C052BF633A14C6F2]
rung=2;cf=0;
mob=1 [3FF0000000000000]
-stab=0.4574069637698503 [3FDD4627DB96AA9F]
+stab=0.4576489406596934 [3FDD4A1EC84BACE6]
att=4 [4010000000000000]
fired[
altalena
@@ -128,7 +128,7 @@ city{
petah_tikva=22,10,48,10,0,c0 [0000000000000000]
rehovot=13,5,28,5,0,c0 [0000000000000000]
rishon_lezion=10,5,22,5,0,c0 [0000000000000000]
- rosh_pinna=1,0,2,0,0,c0 [0000000000000000]
+ rosh_pinna=1,0,2,0,0,c0.12499999999999996 [3FBFFFFFFFFFFFFD]
safed=2,1,5,1,0,c0 [0000000000000000]
tel_aviv=248,106,541,106,4,c0 [0000000000000000]
tiberias=6,2,13,2,0,c0 [0000000000000000]
diff --git a/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt b/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt
index ad0695a8c..a9a664311 100644
--- a/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt
+++ b/sim/Statecraft.Sim.Tests/golden/scenario-reckless.txt
@@ -1,9 +1,9 @@
1949-01-15;11400714819323200433;Historical;8;
ind{
food_supply=0.59921875 [3FE32CCCCCCCCCCD]
- housing=0.41685506903832104 [3FDAADC0E22C4014]
+ housing=0.41912251055925737 [3FDAD2E738F7A4A9]
intl_standing=0.38999999999999996 [3FD8F5C28F5C28F5]
- morale=0.5046675409969844 [3FE0263C8AFDE9C7]
+ morale=0.5049852054802675 [3FE028D6BBD00D04]
security=0.4636917724609376 [3FDDAD204189374E]
pol{
border_settlement=0.2 [3FC999999999999A]
@@ -14,11 +14,11 @@ eff{
border_villages_secure=0.033691772460937505 [3FA1400C49BA5E36]
building_houses=0.0722834300994873 [3FB2812AB851EB85]
food_lifts_cohesion=0.059140625 [3FAE47AE147AE148]
- homes_lift_morale=0.06191260485593446 [3FAFB3024A220066]
+ homes_lift_morale=0.06197826633453369 [3FAFBB9D85F06F69]
rationing_feeds=0.19921875 [3FC9800000000000]
rationing_grates=-0.15 [BFC3333333333333]
safety_lifts_morale=0.04317108886718751 [3FA61A855DA27288]
- work_lifts_cohesion=0.04044322227386246 [3FA4B4F95A05AEA4]
+ work_lifts_cohesion=0.04069522527854631 [3FA4D6012B597372]
shift{
food_supply=0 [0000000000000000]
housing=0 [0000000000000000]
@@ -47,7 +47,7 @@ debt=34.960591926047705 [40417AF4AD1D9699]
fx=80.85238326859616 [4054368D728D91CC]
rung=5;cf=40;
mob=1 [3FF0000000000000]
-stab=0.5916370073185946 [3FE2EEB0BBB12C74]
+stab=0.5917932390134901 [3FE2EFF85FF1D1BA]
att=4 [4010000000000000]
fired[
altalena
@@ -87,15 +87,15 @@ mapturn=0001-01-01:0;
over=
city{
hadera=12,5,12,5,1,c0.35 [3FD6666666666666]
- haifa=99,42,102,42,3,c0.34408823529411764 [3FD6058AA961B39F]
- jerusalem=84,29,87,29,3,c0.3430628803245436 [3FD5F4BE02DDCA5E]
+ haifa=99,42,101,42,4,c0.347029702970297 [3FD635BC123FDF8E]
+ jerusalem=84,29,86,29,4,c0.3465116279069767 [3FD62D3F1B62D3F1]
netanya=12,5,12,5,1,c0.35 [3FD6666666666666]
- petah_tikva=22,10,23,10,0,c0.3434782608695652 [3FD5FB8C3E54975F]
- rehovot=13,5,14,5,0,c0.33928571428571425 [3FD5B6DB6DB6DB6D]
+ petah_tikva=22,10,22,10,1,c0.35 [3FD6666666666666]
+ rehovot=13,5,13,5,1,c0.35 [3FD6666666666666]
rishon_lezion=10,5,10,5,1,c0.35 [3FD6666666666666]
rosh_pinna=1,0,1,0,0,c0.35 [3FD6666666666666]
safed=2,1,2,1,0,c0.35 [3FD6666666666666]
- tel_aviv=248,106,256,106,8,c0.34471009036144573 [3FD60FBAE92D0804]
+ tel_aviv=248,106,255,106,9,c0.3458823529411765 [3FD622EFBC895623]
tiberias=6,2,6,2,0,c0.35 [3FD6666666666666]
zikhron_yaakov=2,1,2,1,0,c0.35 [3FD6666666666666]
food=2253,751,0
diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.cs
index d4c8ca554..ab0adbc50 100644
--- a/sim/Statecraft.Sim/Cities.cs
+++ b/sim/Statecraft.Sim/Cities.cs
@@ -98,16 +98,22 @@ namespace Statecraft.Sim
}
/// <summary>R-CITY-004 (D-A5; D-D1, Q-HOUSE-1): no hard cap. Every refugee becomes a civilian, without a job, on the
- /// housing step; the people beyond the city's housing are its overflow (<see cref="Overflow"/>), still counted in it.
+ /// housing step - as many as R-MIN-002's absorption scaling houses this turn (all of them at a neutral
+ /// multiplier); the people beyond the city's housing are its overflow (<see cref="Overflow"/>), still counted in it.
/// Residents are housed automatically (Q-HOUSE-4). Then R-CITY-009 (Q-JOBS-1): in ascending city id, a city whose job
/// default is on fills its free job slots from its people without a job, at no Attention cost.</summary>
- public static void House(Content c, GameState s, List<Cause> why)
+ public static void House(Content c, GameState s, MvpRules r, List<Cause> why)
{
+ // R-MIN-001, R-MIN-002 (D-H3; Q-MIN-1, Q-MIN-2): the Immigration minister's multiplier scales how many of the
+ // city's refugees are housed this turn; the count is floored (whole groups only) and the rest wait as
+ // refugees. At a neutral multiplier every refugee is housed, as R-CITY-004 says.
+ var m = EffectsSystem.GddSystemMultiplier(c, s, r, EffectsSystem.AbsorptionSystem);
foreach (var x in s.Cities.Values.ToList())
{
- var housed = x.Refugees == 0 ? x : x.WithCounts(x.Civilians + x.Refugees, x.Employed, 0);
- if (x.Refugees != 0)
- why.Add(new Cause("city", x.Id, x.Refugees, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {x.Refugees} groups of immigrants housed")));
+ var absorbed = x.Refugees == 0 ? 0 : Math.Min(x.Refugees, (int)Math.Floor(x.Refugees * m));
+ var housed = absorbed == 0 ? x : x.WithCounts(x.Civilians + absorbed, x.Employed, x.Refugees - absorbed);
+ if (absorbed != 0)
+ why.Add(new Cause("city", x.Id, absorbed, FormattableString.Invariant($"{PlayerText.Settlement(c, x.Id)}: {absorbed} groups of immigrants housed")));
var work = MaxWorkers(housed);
if (housed.JobsDefault && work != housed.Employed)
{
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 04b1d0512..116087d3a 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -518,6 +518,10 @@ namespace Statecraft.Sim
public double? HakhsharaUpkeepPerYear { get; set; }
/// <summary>The day the cities start taking arrivals: the census day their start values count (R-CITY-003, Q-ARRV-3).</summary>
public DateTime CityArrivalsFrom { get; set; }
+ /// <summary>The GDD system to office map (R-MIN-001, D-H3, Q-MIN-1): the office whose
+ /// <see cref="EffectsSystem.Multiplier(Content, GameState, string)"/> scales each named system. A system the map does
+ /// not name is neutral. Read on the turn's date.</summary>
+ public Dictionary<string, string> MinisterSystems { get; set; } = new Dictionary<string, string>();
/// <summary>The day the GDD game ends (R-LOOP-004; D-E5, 15 January 1952 in the real content), or null for the last
/// era's end. Read from rules.yaml through <see cref="Content.End"/>; the same in every era.</summary>
public DateTime? End { get; set; }
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index 82142d3aa..cb28fdc4d 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -1129,6 +1129,9 @@ namespace Statecraft.Sim
}
// R-CITY-003: the cities count arrivals from one day; another day in a later era would lose or double-count units.
if (m.CityArrivalsFrom == default) throw new ContentException(file, "mvp.city_arrivals_from", "required when eras.yaml systems.loop is gdd");
+ foreach (var kv in m.MinisterSystems)
+ if (c.Offices.All(o => o.Id != kv.Value))
+ throw new ContentException(file, $"mvp.minister_systems.{kv.Key}", $"unknown office '{kv.Value}'");
if (m.CityArrivalsFrom != c.Rules.Mvp!.CityArrivalsFrom) throw new ContentException(file, "mvp.city_arrivals_from", "must be the same in every era (the cities count arrivals from one day)");
if (m.BuildYishuvTurns < 1) throw new ContentException(file, "mvp.build_yishuv_turns", "must be >= 1");
if (!(m.BuildYishuvCost >= 0 && IsFinite(m.BuildYishuvCost))) throw new ContentException(file, "mvp.build_yishuv_cost", "must be a finite number >= 0");
diff --git a/sim/Statecraft.Sim/EffectsSystem.cs b/sim/Statecraft.Sim/EffectsSystem.cs
index 4459600a3..5600e20f0 100644
--- a/sim/Statecraft.Sim/EffectsSystem.cs
+++ b/sim/Statecraft.Sim/EffectsSystem.cs
@@ -14,6 +14,38 @@ namespace Statecraft.Sim
foreach (var e in v.Effects) s.EffectContributions[e.Id] = 0;
}
+ /// <summary>The GDD systems a minister's office scales (R-MIN-001; D-H3, Q-MIN-1): the keys of
+ /// mvp.minister_systems in rules.yaml.</summary>
+ public const string HousingConstructionSystem = "housing_construction";
+ public const string IndustryConstructionSystem = "industry_construction";
+ public const string FieldWorkSystem = "field_work";
+ public const string YishuvWorkSystem = "yishuv_work";
+ public const string AbsorptionSystem = "absorption";
+
+ /// <summary>R-MIN-001 and R-MIN-003 (D-H3; Q-MIN-1, Q-MIN-3): the multiplier a GDD system reads on the state's date.
+ /// A system the map does not name is neutral (1.0). An office that does not exist on the date (ended or not yet
+ /// created) reads its named successor office's multiplier, or is neutral with none (Q-MIN-3) - never the
+ /// absent-holder 0.5 of <see cref="Multiplier(Content, GameState, string)"/>, which stays the rule for an office that
+ /// exists but is vacant. A multiplier within 1e-9 of 1.0 reads as exactly 1.0, so float noise in the competence and
+ /// budget factors never stalls a system whose true multiplier is neutral.</summary>
+ public static double GddSystemMultiplier(Content c, GameState s, MvpRules r, string system)
+ {
+ if (!r.MinisterSystems.TryGetValue(system, out var office) || office == "") return 1.0;
+ var seen = new HashSet<string>(StringComparer.Ordinal);
+ while (seen.Add(office))
+ {
+ var o = c.Offices.FirstOrDefault(x => x.Id == office);
+ if (o != null && o.ExistsOn(s.Date))
+ {
+ var m = Multiplier(c, s, office);
+ return Math.Abs(m - 1.0) < 1e-9 ? 1.0 : m;
+ }
+ if (o == null || o.Successor == "") return 1.0;
+ office = o.Successor;
+ }
+ return 1.0; // a successor cycle: neutral rather than a loop (the loader refuses unknown successors)
+ }
+
/// <summary>Competence (0.5 + competence/20) of the office holder (player appointments included) times budget
/// factor. No office: 1.0.</summary>
public static double Multiplier(Content c, GameState s, string office)
diff --git a/sim/Statecraft.Sim/GddState.cs b/sim/Statecraft.Sim/GddState.cs
index 0fd6e748a..24dbff274 100644
--- a/sim/Statecraft.Sim/GddState.cs
+++ b/sim/Statecraft.Sim/GddState.cs
@@ -174,24 +174,34 @@ namespace Statecraft.Sim
public int TurnsLeft { get; }
/// <summary>The end date of the turn the site was built on; null while it is being built.</summary>
public DateTime? BuiltOn { get; }
+ /// <summary>The turn-equivalents of work accumulated toward the next whole turn (R-MIN-002: the office multiplier's
+ /// scaled gain accumulates here, and only whole turns leave it, so no fraction of a turn is ever a turn to go). In
+ /// [0, 1) while being built; 0 once built and on a site no minister system scales.</summary>
+ public double Progress { get; }
/// <summary>A site being built (<paramref name="builtOn"/> null) needs its unit; a built site has none.</summary>
- public SiteWork(string site, int? unit, int turnsLeft, DateTime? builtOn)
+ public SiteWork(string site, int? unit, int turnsLeft, DateTime? builtOn, double progress = 0)
{
if ((builtOn == null) != (unit != null)) throw new ArgumentException("a site being built has a unit, and a built site has none", nameof(unit));
- Site = site; Unit = unit; TurnsLeft = turnsLeft; BuiltOn = builtOn;
+ Site = site; Unit = unit; TurnsLeft = turnsLeft; BuiltOn = builtOn; Progress = progress;
}
/// <summary>The site built on <paramref name="on"/>, with no unit on it.</summary>
public static SiteWork Built(string site, DateTime on) => new SiteWork(site, null, 0, on);
/// <summary>The same work with <paramref name="turnsLeft"/> turns to go.</summary>
- public SiteWork WithTurnsLeft(int turnsLeft) => new SiteWork(Site, Unit, turnsLeft, BuiltOn);
+ public SiteWork WithTurnsLeft(int turnsLeft) => new SiteWork(Site, Unit, turnsLeft, BuiltOn, Progress);
- /// <summary>The record as the state hash writes it: "id=b,UNIT,TURNSLEFT" while building, "id=done,yyyy-MM-dd" once built.</summary>
+ /// <summary>The same work with <paramref name="turnsLeft"/> turns to go and <paramref name="progress"/> accumulated
+ /// (R-MIN-002's floor with carry).</summary>
+ public SiteWork WithProgress(int turnsLeft, double progress) => new SiteWork(Site, Unit, turnsLeft, BuiltOn, progress);
+
+ /// <summary>The record as the state hash writes it: "id=b,UNIT,TURNSLEFT" while building, ",PROGRESS" appended when
+ /// it is not 0, as IEEE bits like the other hashed doubles (R-MIN-002), "id=done,yyyy-MM-dd" once built.</summary>
public string Canonical() => BuiltOn is DateTime on
? Site + "=done," + on.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
- : string.Format(CultureInfo.InvariantCulture, "{0}=b,{1},{2}", Site, Unit, TurnsLeft);
+ : string.Format(CultureInfo.InvariantCulture, "{0}=b,{1},{2}", Site, Unit, TurnsLeft)
+ + (Progress == 0 ? "" : "," + BitConverter.DoubleToInt64Bits(Progress).ToString("X16", CultureInfo.InvariantCulture));
}
/// <summary>A city project (projects.yaml; R-PROJ-001 to R-PROJ-003): <see cref="Kind"/> built for <see cref="City"/> on hex
@@ -209,20 +219,29 @@ namespace Statecraft.Sim
public int TurnsLeft { get; }
/// <summary>The end date of the turn the project was built on; null while it is being built.</summary>
public DateTime? BuiltOn { get; }
+ /// <summary>The turn-equivalents of work accumulated toward the next whole turn (R-MIN-002), as
+ /// <see cref="SiteWork.Progress"/>. In [0, 1) while being built; 0 once built and on a kind no minister system scales.</summary>
+ public double Progress { get; }
- public CityProject(int id, string kind, string city, int q, int r, int turnsLeft, DateTime? builtOn = null)
+ public CityProject(int id, string kind, string city, int q, int r, int turnsLeft, DateTime? builtOn = null, double progress = 0)
{
- Id = id; Kind = kind; City = city; Q = q; R = r; TurnsLeft = turnsLeft; BuiltOn = builtOn;
+ Id = id; Kind = kind; City = city; Q = q; R = r; TurnsLeft = turnsLeft; BuiltOn = builtOn; Progress = progress;
}
/// <summary>The same project with <paramref name="turnsLeft"/> turns to go.</summary>
- public CityProject WithTurnsLeft(int turnsLeft) => new CityProject(Id, Kind, City, Q, R, turnsLeft);
+ public CityProject WithTurnsLeft(int turnsLeft) => new CityProject(Id, Kind, City, Q, R, turnsLeft, BuiltOn, Progress);
+
+ /// <summary>The same project with <paramref name="turnsLeft"/> turns to go and <paramref name="progress"/>
+ /// accumulated (R-MIN-002's floor with carry).</summary>
+ public CityProject WithProgress(int turnsLeft, double progress) => new CityProject(Id, Kind, City, Q, R, turnsLeft, BuiltOn, progress);
/// <summary>The same project, built on <paramref name="on"/>.</summary>
public CityProject Built(DateTime on) => new CityProject(Id, Kind, City, Q, R, 0, on);
- /// <summary>The record as the state hash writes it: "id:KIND@CITY,Q,R/TURNSLEFT" while building, "/done,yyyy-MM-dd" once built.</summary>
+ /// <summary>The record as the state hash writes it: "id:KIND@CITY,Q,R/TURNSLEFT" while building, ",PROGRESS"
+ /// appended as IEEE bits when it is not 0 (R-MIN-002), "/done,yyyy-MM-dd" once built.</summary>
public string Canonical() => string.Format(CultureInfo.InvariantCulture, "{0}:{1}@{2},{3},{4}/", Id, Kind, City, Q, R)
- + (BuiltOn is DateTime on ? "done," + on.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) : TurnsLeft.ToString(CultureInfo.InvariantCulture));
+ + (BuiltOn is DateTime on ? "done," + on.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)
+ : TurnsLeft.ToString(CultureInfo.InvariantCulture) + (Progress == 0 ? "" : "," + BitConverter.DoubleToInt64Bits(Progress).ToString("X16", CultureInfo.InvariantCulture)));
}
}
diff --git a/sim/Statecraft.Sim/GoldenRun.cs b/sim/Statecraft.Sim/GoldenRun.cs
index c0465d835..2e2394991 100644
--- a/sim/Statecraft.Sim/GoldenRun.cs
+++ b/sim/Statecraft.Sim/GoldenRun.cs
@@ -16,13 +16,13 @@ namespace Statecraft.Sim
/// <summary>Final hash of Play(content, Until1950). Changing it is a deliberate rules or content change: the value
/// is pinned in sim/Statecraft.Sim.Tests/golden/manifest.txt, and STATECRAFT_UPDATE_GOLDEN=1 dotnet test rewrites
/// both (docs/determinism.md). Say why in the commit message.</summary>
- public const string Hash1950 = "4f1202cfa20e1f3cc7521c7b3baac386330b77fdbacc25928d781b1659747340";
+ public const string Hash1950 = "e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a";
public static readonly DateTime Until1950 = new DateTime(1950, 1, 1);
/// <summary>Final hash of Play(content, Until1952): the M3 content range (to 31 December 1951). The GDD game ends on
/// 15 January 1952 (R-LOOP-004), the first turn on or after Until1952, so this is also the mvp-end run.</summary>
- public const string Hash1952 = "283349502eb580123fcea6bf64ca174f913627132a1325f3dbf00743435623e2";
+ public const string Hash1952 = "37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde";
public static readonly DateTime Until1952 = new DateTime(1952, 1, 1);
diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.cs
index 6adf14c46..cbb80a5be 100644
--- a/sim/Statecraft.Sim/Projects.cs
+++ b/sim/Statecraft.Sim/Projects.cs
@@ -46,19 +46,40 @@ namespace Statecraft.Sim
/// else 1 (R-SITE-003, R-VET-002).</summary>
public static int Progress(MvpRules r, Unit unit) => unit.Type == VeteranType ? r.VeteranProgress!.Value : 1;
- /// <summary>The turns, this one included, in which <paramref name="unit"/> builds a site with <paramref name="left"/>
- /// turns of progress to go: Advance's count, a halutz promoted on the way (R-VET-001) building faster from the next turn
- /// (R-SITE-003, R-VET-002). With build_yishuv_turns it is how long a Build ordered now takes. Read with the rules of
- /// the current date, as Advance reads them; it changes no state.</summary>
- public static int TurnsToBuild(Content c, GameState s, int unit, int left)
+ /// <summary>The GDD minister system a site's pioneer work belongs to (R-MIN-001; Q-MIN-1): plowing a field and
+ /// building a new yishuv are Agriculture's; camps and swamp draining are no mapped system's ("" = neutral;
+ /// military training joins with #742).</summary>
+ public static string SystemOf(Site place) =>
+ place.Kinds.Contains(FieldKind) ? EffectsSystem.FieldWorkSystem
+ : place.Kinds.Contains(YishuvKind) ? EffectsSystem.YishuvWorkSystem
+ : "";
+
+ /// <summary>The GDD minister system a city project's kind belongs to (R-MIN-001; Q-MIN-1): housing, a transit
+ /// camp included (Q-HOUSE-3's low-condition housing type), and industry construction are Labour's; a kind the map
+ /// does not name is "" (neutral).</summary>
+ public static string SystemOfKind(string kind) =>
+ kind == "industry" ? EffectsSystem.IndustryConstructionSystem
+ : kind == "housing" || kind == "transit_camp" ? EffectsSystem.HousingConstructionSystem
+ : "";
+
+ /// <summary>The turns, this one included, in which the unit completes the site's remaining whole work and
+ /// fractional carry at its current minister multiplier. Reads the current date's rules, accounts for a halutz
+ /// promoted during the work, and changes no state. Initial work passes its base duration and zero carry.</summary>
+ public static int TurnsToBuild(Content c, GameState s, int unit, Site site, int left, double carry)
{
- var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop
+ if (site == null) throw new ArgumentNullException(nameof(site));
+ if (left < 1) throw new ArgumentOutOfRangeException(nameof(left));
+ if (!(carry >= 0 && carry < 1)) throw new ArgumentOutOfRangeException(nameof(carry));
+ var r = c.RulesAt(s.Date).Mvp!;
+ var m = EffectsSystem.GddSystemMultiplier(c, s, r, SystemOf(site));
+ if (!(m > 0) || double.IsInfinity(m)) throw new InvalidOperationException("Site progress multiplier must be finite and positive");
var u = s.Units[unit];
- for (int turns = 1; ; turns++)
+ for (int turns = 1; ; turns = checked(turns + 1))
{
- var progress = Progress(r, u);
- if (left <= progress) return turns;
- left -= progress;
+ carry += Progress(r, u) * m;
+ if (carry >= left) return turns; // before the int cast: completion can exceed the remaining work
+ var whole = (int)Math.Floor(carry);
+ left -= whole; carry -= whole;
if (u.Type == "halutz")
{
var service = u.Service + 1;
@@ -149,12 +170,17 @@ namespace Statecraft.Sim
foreach (var w in s.Sites.Values.Where(x => x.BuiltOn == null).ToList())
{
var u = s.Units[w.Unit!.Value]; // a site being built always names its unit (SiteWork)
- var progress = Progress(r, u);
- if (w.TurnsLeft > progress) s.Sites[w.Site] = w.WithTurnsLeft(w.TurnsLeft - progress);
+ var place = c.Sites.First(x => x.Id == w.Site); // a site being built is always in sites.yaml (Start)
+ // R-MIN-001, R-MIN-002 (D-H3; Q-MIN-1, Q-MIN-2): the office of the site's system scales the turns of
+ // progress the work gains this turn. The gain accumulates in Progress and only whole turns leave it
+ // (floor with carry): no fraction of a turn is ever a turn to go.
+ var acc = w.Progress + Progress(r, u) * EffectsSystem.GddSystemMultiplier(c, s, r, SystemOf(place));
+ var whole = (int)Math.Floor(acc);
+ acc -= whole;
+ if (w.TurnsLeft > whole) s.Sites[w.Site] = w.WithProgress(w.TurnsLeft - whole, acc);
else
{
s.Sites[w.Site] = SiteWork.Built(w.Site, next);
- var place = c.Sites.First(x => x.Id == w.Site); // a site being built is always in sites.yaml (Start)
why.Add(new Cause("map", w.Site, 1, $"{place.Name} {(IsCamp(place) ? "built" : place.Kinds.Contains(FieldKind) ? "plowed" : place.Kinds.Contains(SwampKind) ? "drained" : "founded")}"));
}
// R-VET-001: the project progressed this turn, so a halutz serves a turn; a veteran counts no further.
@@ -240,9 +266,15 @@ namespace Statecraft.Sim
/// advanced again.</summary>
public static void AdvanceCity(Content c, GameState s, DateTime next, List<Cause> why)
{
+ var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop, the only loop TurnResolver runs this in
foreach (var p in s.CityProjects.Values.Where(x => x.BuiltOn == null).ToList())
{
- if (p.TurnsLeft > 1) { s.CityProjects[p.Id] = p.WithTurnsLeft(p.TurnsLeft - 1); continue; }
+ // R-MIN-001, R-MIN-002 (D-H3; Q-MIN-1, Q-MIN-2): the office of the kind's system scales the turn of
+ // progress the project gains this turn, with R-MIN-002's floor and carry as at the sites (Advance).
+ var acc = p.Progress + EffectsSystem.GddSystemMultiplier(c, s, r, SystemOfKind(p.Kind));
+ var whole = (int)Math.Floor(acc);
+ acc -= whole;
+ if (p.TurnsLeft > whole) { s.CityProjects[p.Id] = p.WithProgress(p.TurnsLeft - whole, acc); continue; }
s.CityProjects[p.Id] = p.Built(next);
var k = c.ProjectKinds.First(x => x.Id == p.Kind);
var x = s.Cities[p.City];
diff --git a/sim/Statecraft.Sim/TurnResolver.cs b/sim/Statecraft.Sim/TurnResolver.cs
index 7d6aefdd6..6a71fbf92 100644
--- a/sim/Statecraft.Sim/TurnResolver.cs
+++ b/sim/Statecraft.Sim/TurnResolver.cs
@@ -22,7 +22,7 @@ namespace Statecraft.Sim
Pools.Harvest(c, s, r, why); // and the plowed fields' Food (R-FIELD-002)
Pools.Consume(c, s, r, why); // 7. consumption: the nation eats, then imports (R-FOOD-002)
EconomySystem.PayCivilianUpkeep(c, s, r, yearFraction, why); // and pays Money upkeep (R-MONEY-002)
- Cities.House(c, s, why); // 8. housing, then the housing condition; Social cohesion is morale, which the effects web moves after the resolution
+ Cities.House(c, s, r, why); // 8. housing, then the housing condition; Social cohesion is morale, which the effects web moves after the resolution
Cities.UpdateCondition(c, s, r, why);
Cities.Arrive(c, s, r, next, why); // 9. arrivals
// 10. Occupation timers: Phase 6.
diff --git a/tools/web_check.py b/tools/web_check.py
index 7428605fb..89be59aa3 100644
--- a/tools/web_check.py
+++ b/tools/web_check.py
@@ -8,7 +8,7 @@ fail on a failure line or a timeout. Uses Chrome for Testing from the Playwright
--enable-logging=stderr --v=1 as INFO:CONSOLE... "text", source: ...
Usage (from the repo root):
- uv run tools/web_check.py unity/Builds/Web-disabled --query "golden" --expect "GOLDEN OK hash1950 4f1202cfa20e1f3cc7521c7b3baac386330b77fdbacc25928d781b1659747340" --expect "GOLDEN OK hash1952 283349502eb580123fcea6bf64ca174f913627132a1325f3dbf00743435623e2"
+ uv run tools/web_check.py unity/Builds/Web-disabled --query "golden" --expect "GOLDEN OK hash1950 e3c76f5f6fc45e4941a4499afd2e5c226a4677a651f39c6cef789447d123267a" --expect "GOLDEN OK hash1952 37866907babc55e9477320db32467d1314aa59c8fe86d4d4ad82d8db61731fde"
Options: --query Q (page URL query, without '?'), --expect TEXT (repeatable), --fail REGEX (default: GOLDEN FAIL|SMOKE FAIL|BOOT FAIL),
--timeout SECONDS (default 300), --stall SECONDS (fail when no console message arrives for that long; 0 = off),
--swiftshader (software WebGL when there is no GPU), --dpr N (default 1), --shots DIR (reassemble the player's
diff --git a/unity/Assets/Scripts/UI/GddHexPanel.cs b/unity/Assets/Scripts/UI/GddHexPanel.cs
index e8209c1f4..60b8258cd 100644
--- a/unity/Assets/Scripts/UI/GddHexPanel.cs
+++ b/unity/Assets/Scripts/UI/GddHexPanel.cs
@@ -117,14 +117,14 @@ namespace Statecraft.Game.UI
var ordered = bridge.QueuedLike(new PioneerWork(u.Id, Projects.BuildYishuv, site.Id)) is PioneerWork p && p.Site == site.Id;
Button(host, $"site-build-{u.Id}", ordered ? text["site.ordered"]
: text.Format("site.build", Group(text, s, u.Id), PlayerText.Money(c, "treasury", rules.BuildYishuvCost),
- Turns(text, Projects.TurnsToBuild(c, s, u.Id, rules.BuildYishuvTurns))),
+ Turns(text, Projects.TurnsToBuild(c, s, u.Id, site, rules.BuildYishuvTurns, 0))),
() => bridge.Queue(new PioneerWork(u.Id, Projects.BuildYishuv, site.Id))).SetEnabled(!ordered && !taken);
}
}
else if (work.BuiltOn == null)
{
var unit = work.Unit!.Value; // a site being built names its unit (SiteWork)
- Line(host, "site-state", text.Format("site.building", Group(text, s, unit), Turns(text, Projects.TurnsToBuild(c, s, unit, work.TurnsLeft))));
+ Line(host, "site-state", text.Format("site.building", Group(text, s, unit), Turns(text, Projects.TurnsToBuild(c, s, unit, site, work.TurnsLeft, work.Progress))));
var stopping = bridge.QueuedLike(new StopWork(unit)) is StopWork;
Button(host, "site-stop", text[stopping ? "site.ordered" : "site.stop"], () => bridge.Queue(new StopWork(unit))).SetEnabled(!stopping);
}
diff --git a/unity/Assets/Tests/EditMode/CityPanelTests.cs b/unity/Assets/Tests/EditMode/CityPanelTests.cs
index 480a53a54..d17900511 100644
--- a/unity/Assets/Tests/EditMode/CityPanelTests.cs
+++ b/unity/Assets/Tests/EditMode/CityPanelTests.cs
@@ -301,8 +301,21 @@ public class CityPanelTests
Assert.AreEqual(SiteDef.Name, ui.Q<Label>("info-title").text, "the site's name is the title");
Assert.AreEqual(En["site.available"], ui.Q<Label>("site-state").text);
var r = C.RulesAt(bridge.State.Date).Mvp!;
+ Assert.AreEqual(0.624, EffectsSystem.GddSystemMultiplier(C, bridge.State, r, EffectsSystem.YishuvWorkSystem), 1e-9, "precondition: real Agriculture multiplier");
+ Assert.AreEqual(6, r.BuildYishuvTurns, "the owner's base work is unchanged");
+ Assert.AreEqual(0, bridge.State.Units[a].Service, "the idle group is not already partway to veteran");
+ var played = bridge.State.Clone();
+ int elapsed = 0;
+ do
+ {
+ var result = Simulation.Step(C, played, elapsed == 0 ? new Command[] { new PioneerWork(a, Projects.BuildYishuv, Site) } : new Command[0]);
+ Assert.IsEmpty(result.Rejected);
+ played = result.State; elapsed++;
+ } while (played.Sites[Site].BuiltOn == null && elapsed < 12);
+ Assert.IsNotNull(played.Sites[Site].BuiltOn, "real resolver finishes the fixture");
+ Assert.AreEqual(8, elapsed, "six work units at the real multiplier, including veteran promotion");
var first = ui.Q<Button>($"site-build-{a}");
- Assert.AreEqual(En.Format("site.build", En.Format("site.group", 1), PlayerText.Money(C, "treasury", r.BuildYishuvCost), En.Format("city.turns", r.BuildYishuvTurns)), first.text);
+ Assert.AreEqual(En.Format("site.build", En.Format("site.group", 1), PlayerText.Money(C, "treasury", r.BuildYishuvCost), En.Format("city.turns", 8)), first.text);
StringAssert.Contains(En.Format("site.group", 2), ui.Q<Button>($"site-build-{b}").text, "every idle group has its button, numbered from 1");
UiTestKit.Press(first);
var order = bridge.QueuedLike(new PioneerWork(a, Projects.BuildYishuv, Site)) as PioneerWork;
@@ -349,7 +362,7 @@ public class CityPanelTests
using var panel = Panel(ui, bridge, En);
panel.Show(SiteDef.Q, SiteDef.R);
var r = C.RulesAt(bridge.State.Date).Mvp!;
- var turns = Projects.TurnsToBuild(C, bridge.State, vet, r.BuildYishuvTurns);
+ var turns = Projects.TurnsToBuild(C, bridge.State, vet, SiteDef, r.BuildYishuvTurns, 0);
Assert.Less(turns, r.BuildYishuvTurns, "precondition: a veteran builds faster in the real content");
var button = ui.Q<Button>($"site-build-{vet}");
Assert.IsNotNull(button, "a veteran group has a Build button");
@@ -358,16 +371,18 @@ public class CityPanelTests
Assert.IsNotNull(bridge.QueuedLike(new PioneerWork(vet, Projects.BuildYishuv, Site)));
}
- [Test]
- public void AVeteransSiteShowsTheTurnsItReallyHasLeft()
+ [TestCase(0d, 4)]
+ [TestCase(0.75d, 3)]
+ public void AVeteransSiteShowsTheTurnsItReallyHasLeft(double carry, int expected)
{
using var ui = new UiTestKit();
int vet = -1;
- var bridge = Bridge(En, s => { vet = AddHalutz(s, Projects.VeteranType); s.Sites[Site] = new SiteWork(Site, vet, 4, null); });
+ var bridge = Bridge(En, s => { vet = AddHalutz(s, Projects.VeteranType); s.Sites[Site] = new SiteWork(Site, vet, 4, null, carry); });
using var panel = Panel(ui, bridge, En);
panel.Show(SiteDef.Q, SiteDef.R);
- var turns = Projects.TurnsToBuild(C, bridge.State, vet, 4);
- Assert.AreEqual(2, turns, "precondition: 4 turns of progress at the real content's 2 a turn");
+ var turns = Projects.TurnsToBuild(C, bridge.State, vet, SiteDef, 4, carry);
+ Assert.AreEqual(0.624, EffectsSystem.GddSystemMultiplier(C, bridge.State, C.RulesAt(bridge.State.Date).Mvp!, EffectsSystem.YishuvWorkSystem), 1e-9, "precondition: current real Agriculture rate");
+ Assert.AreEqual(expected, turns, "four work units at 2 x 0.624 per turn, including saved carry");
Assert.AreEqual(En.Format("site.building", En.Format("site.group", 1), En.Format("city.turns", turns)), ui.Q<Label>("site-state").text);
}
@@ -428,7 +443,19 @@ public class CityPanelTests
var bridge = Bridge(En, s => { a = AddHalutz(s); s.Sites[Site] = new SiteWork(Site, a, 4, null); });
using var panel = Panel(ui, bridge, En);
panel.Show(SiteDef.Q, SiteDef.R);
- Assert.AreEqual(En.Format("site.building", En.Format("site.group", 1), En.Format("city.turns", 4)), ui.Q<Label>("site-state").text);
+ Assert.AreEqual(0.624, EffectsSystem.GddSystemMultiplier(C, bridge.State, C.RulesAt(bridge.State.Date).Mvp!, EffectsSystem.YishuvWorkSystem), 1e-9, "precondition: real Agriculture multiplier");
+ Assert.AreEqual((0, 4, 0d), (bridge.State.Units[a].Service, bridge.State.Sites[Site].TurnsLeft, bridge.State.Sites[Site].Progress), "precondition: a fresh halutz with four whole work units and no carry");
+ var played = bridge.State.Clone();
+ int elapsed = 0;
+ do
+ {
+ var result = Simulation.Step(C, played, new Command[0]);
+ Assert.IsEmpty(result.Rejected);
+ played = result.State; elapsed++;
+ } while (played.Sites[Site].BuiltOn == null && elapsed < 12);
+ Assert.IsNotNull(played.Sites[Site].BuiltOn, "real resolver finishes the fixture");
+ Assert.AreEqual(7, elapsed, "remaining work at the real multiplier, including veteran promotion");
+ Assert.AreEqual(En.Format("site.building", En.Format("site.group", 1), En.Format("city.turns", 7)), ui.Q<Label>("site-state").text);
UiTestKit.Press(ui.Q<Button>("site-stop"));
Assert.IsNotNull(bridge.QueuedLike(new StopWork(a)), "Stop queues StopWork");
}