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.

GDD 0.3: builders on city projects (#1700 slice A) (#2341)

Eyal Golan52fe3d60aa26
diff --git a/changelog.d/1700-builders-live.md b/changelog.d/1700-builders-live.md
new file mode 100644
index 000000000..992d39ce5
--- /dev/null
+++ b/changelog.d/1700-builders-live.md
@@ -0,0 +1,9 @@
+### Added
+
+- GDD 0.3 builders on city projects in the sim (Refs #1700, slice A): under the gdd-0.3 ruleset only, a city project
+ being built needs one builder, a person of its city without a job, to make progress, at the kind's existing turns.
+ Starting a project takes a free person as its builder automatically when the city has one; otherwise the project waits
+ until the player assigns one with the new `build` role. A builder holds no job, cannot be trained or put to work in a
+ job or an arms workshop, and is freed when the project is built or cancelled. Extra Money never speeds a project. The Why
+ screen says when a builder starts and why a project waits; its Hebrew lines are agent drafts awaiting a native read.
+ The current game (gdd-0.1) is unchanged. The per-city start limit and the hex panel come later.
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index dd0b83758..1e47d0ffa 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -90,7 +90,7 @@ R-SAVE-004: A schema 2 save of the GDD game with a player attack (`order <unit>
Each GDD turn resolves in the order of the approved plan's section 2.3 (decision D-A6): production, then housing and Social cohesion, then arrivals.
-R-CITY-001: Under legacy/gdd-0.1, `AssignWorkers(city, role, n)` sets how many of the city's people work in `role` (only `job` exists: a craftsman fills an ordinary job slot, R-CRAFT-002). It is refused, with the state unchanged and the Attention refunded, when the city or role is unknown, `n` is negative, or `n` is above the city's jobs or its civilians and craftsmen. An accepted order turns the city's job default off (R-CITY-009). The legacy loop refuses it before charging Attention. The gdd-0.3 population foundation uses one typed assignment per ledger id (R-POP-002); initialized ledger fixtures refuse this aggregate command path, pending producer integration. Under gdd-0.3 the role `workshop` staffs the city's arms workshops instead (R-ARMS-005), and a `job` count is refused above the city's civilians and craftsmen less its staffed workshops, whose workers hold no job; the job default (R-CITY-009) fills to the same number.
+R-CITY-001: Under legacy/gdd-0.1, `AssignWorkers(city, role, n)` sets how many of the city's people work in `role` (only `job` exists: a craftsman fills an ordinary job slot, R-CRAFT-002). It is refused, with the state unchanged and the Attention refunded, when the city or role is unknown, `n` is negative, or `n` is above the city's jobs or its civilians and craftsmen. An accepted order turns the city's job default off (R-CITY-009). The legacy loop refuses it before charging Attention. The gdd-0.3 population foundation uses one typed assignment per ledger id (R-POP-002); initialized ledger fixtures refuse this aggregate command path, pending producer integration. Under gdd-0.3 the role `workshop` staffs the city's arms workshops instead (R-ARMS-005), and a `job` count is refused above the city's civilians and craftsmen less its staffed workshops and its builders (R-CITY-011), whose workers hold no job; the job default (R-CITY-009) fills to the same number. Under gdd-0.3 the role `build` puts builders on the city's projects being built (R-CITY-011).
R-CITY-002: Each turn every city's employed units add `employed * income_per_job_per_year * the turn's share of a year` to the Treasury (an employed craftsman earns more, R-CRAFT-002). The gdd-0.3 catalogue's `industry.income` tiers (ordinary or novice / apprentice / expert: 1 / 2 / 3) are multiples of this per-unit rate (owner, 1 November 2026: "Main's base x 0.3's tiers (Recommended)"; #2112). The inactive synthetic fixtures (`Gdd03AssignmentFixture.IndustryRate`, `Gdd03CraftArithmetic`) quote the catalogue multiple itself, not Money; `Gdd03IndustryRates.MoneyPerTurn` converts it, and no live system reads either. A staffed arms workshop's worker is not employed and earns nothing here (R-ARMS-005).
@@ -146,23 +146,25 @@ R-HOUSE-005: Under `gdd-0.3` only (#1703, the MVP's per-city housing condition),
A city project is built in a city (GDD "Cities and construction"; Phase 3 PR 4, #735). The kinds are in `content/projects.yaml`, every number a design value (Q-PROJ-1, Q-PROJ-5, owner, 15 October 2026, #375: "Take all recommendations", with agent-proposed values the owner may override): permanent housing (`housing`), the transit camp (`transit_camp`, D-D3, Q-HOUSE-3) and `industry`, and, under gdd-0.3 only, the arms workshop (`arms_workshop`, R-ARMS-004). They replace the legacy map actions, which the GDD loop refuses (R-PROJ-004).
-R-PROJ-001: `StartProject(kind, city, q, r)` starts a city project of a `projects.yaml` kind for a city on hex (q, r). The Treasury pays the kind's cost at once and borrows what it lacks (Q-PROJ-1, Q-MONEY-3, "Allow borrowing"); the project takes the next id and the kind's turns, the turn of the order the first (D-A3). It needs no workers (Q-PROJ-3). It is refused, state and Attention unchanged, for an unknown kind or city; a locked kind that no event has unlocked (R-EFX-008); a transit camp without the `maabarot` policy at 0.5 or more (Q-HOUSE-3: the policy carries the camp's sourced date, and the map actions' 1 January 1950 window does not apply); a hex that is not land, is more than `map_action_max_distance` from the city's settlement hex, or holds a map-action placement or another city project, built or not (Q-PROJ-2); and once `map_actions_per_turn` projects were started this turn, counted nationally (Q-PROJ-4; the GDD loop builds no map action, R-PROJ-004). The legacy loop refuses it before charging Attention. Its Attention cost is `attention_cost.start_project` (1, Q-PROJ-5).
+R-PROJ-001: `StartProject(kind, city, q, r)` starts a city project of a `projects.yaml` kind for a city on hex (q, r). The Treasury pays the kind's cost at once and borrows what it lacks (Q-PROJ-1, Q-MONEY-3, "Allow borrowing"); the project takes the next id and the kind's turns, the turn of the order the first (D-A3). It needs no workers (Q-PROJ-3); under gdd-0.3 the start takes a free person as its builder when there is one (R-CITY-011). It is refused, state and Attention unchanged, for an unknown kind or city; a locked kind that no event has unlocked (R-EFX-008); a transit camp without the `maabarot` policy at 0.5 or more (Q-HOUSE-3: the policy carries the camp's sourced date, and the map actions' 1 January 1950 window does not apply); a hex that is not land, is more than `map_action_max_distance` from the city's settlement hex, or holds a map-action placement or another city project, built or not (Q-PROJ-2); and once `map_actions_per_turn` projects were started this turn, counted nationally (Q-PROJ-4; the GDD loop builds no map action, R-PROJ-004). The legacy loop refuses it before charging Attention. Its Attention cost is `attention_cost.start_project` (1, Q-PROJ-5).
-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-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); under gdd-0.3 its builder, if any, is free again at once (R-CITY-011). 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 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-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). Under gdd-0.3, at step 5 a project gains the turn's progress only when it has a builder and its city still has that person without a job (each project with a builder takes one, in ascending id). A project with no builder waits: its record, turns left and carried fraction stay as they were, as in R-CITY-010, and the Why screen says why ("Town: a housing project waits: no builder", or "... no person without a job is left for its builder"). Money is never an input to progress. A project's builder is written into its hashed record (`;builder`) only when it has one, so no gdd-0.1 hash changes.
R-PROJ-004: In the GDD loop a map action (`map_action`, the legacy transit camp or housing placement) is refused with the reason "Map actions are not part of this game: start a city project instead" and its Attention refunded, whatever its action or hex (plan PR 4, spec §1.4: "Placements become completed projects"). So no placement is built and none counts against R-PROJ-001's turn limit. The info panel shows no legacy Build button in the GDD loop. The legacy loop keeps the map actions until that code is deleted (D-E1). The pioneer orders from the map (`pioneer_work`, R-SITE-001) are not map actions.
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 Rishon LeZion with its vineyards flagged `to_verify` (owner, 20 October 2026, on #737, as GDD v0.2 says; this replaces the 18 October default of Zikhron Ya'akov, which has no winery).
+R-CITY-011: Under gdd-0.3 only (owner, 3 November 2026: "Builders in the MVP (Recommended)", "One builder, today's times (Recommended)", "Yes, if someone is free"; #1700 slice A), a city project being built has at most one builder. A builder is one of the city's civilians and craftsmen who hold no job and are not a staffed arms workshop's worker or another project's builder (a free person). The builder stays one of them, with no job, profession or qualification change, is not employed (R-CITY-001) and earns no job income (R-CITY-002). `Train`, `ReassignPioneers`, a `job` count, the job default (R-CITY-009) and a workshop's worker cannot take a builder. `StartProject` takes the city's free person as the new project's builder when it has one, at the moment the start runs, in queue order: a `Train` or `AssignWorkers` queued before the start has already changed the count, and one queued after it sees the builder as taken. Otherwise the project starts with no builder; it never takes anyone out of a job, the job default's included, and a project that waits does not pick up a person who becomes free later. On the aggregate cities the builder is one unit of the city's count, counted at the ordinary tier (no cost in the MVP). `AssignWorkers(city, "build", n)` sets the number of the city's projects being built that have a builder: a rise puts builders on the projects that have none, in ascending project id; a fall takes them off the projects that have one, in descending project id. It is refused, with the state unchanged, for an unknown city; a negative count; more than the city's projects being built ("Town A has 1 city project being built"); or more new builders than the city's free people ("... civilians and craftsmen without a job"), with R-ARMS-005's job-default rule (while the default is on, an order may take a builder from the default's jobs, and is refused only past the city's civilians and craftsmen less its staffed workshops and builders). Under every other ruleset the role is refused as "There is no such role". A project's builder is freed when it is built or cancelled. A freed builder does not move to another project by itself. The limits a panel reads with this turn's queue (`Training.Available`, `Workshops.Check`, `Cities.MaxWorkers`) also count the builder each queued `StartProject` in the city may take, so a count up to them is accepted whichever order runs first. On step 6 the staffed arms workshops share the city's people without a job with the builders, who took theirs at step 5 (R-ARMS-006). The Why screen says when a builder starts on a project ("Town: a builder started on a housing project").
+
For R-PROJ-001 and R-PROJ-003, the preceding rules and the IL 0m upkeep of R-MONEY-002 remain unchanged in the game. The inactive gdd-0.3 addition is `Gdd03ProjectBuildFixture`, synthetic builder rules over the #1963 project catalogue (#1700; no command, save, loader, resolver or UI caller). A start pays the kind's full catalogue cost up front; when Money is short the start goes ahead and the shortfall is borrowed as R-MONEY-003 says, Money stopping at 0 and the rest moving to the fixture's debt (owner, 1 November 2026, D1: "Approve all six (Recommended)"). The record holds work done, not turns left. Each turn only assigned builders add work, at the catalogue's ordinary-or-novice, apprentice or expert rate (1, 1.5, 3), at most `builder.slots_per_project` (3) on one project; a project with no builders makes no progress. Money is not an input to progress, so extra Money never changes the completion turn (Amir, 28 October 2026, recorded on #1668: "Extra Money cannot replace work or speed completion. Housing and improvements also require Money for upkeep."). Work past the kind's `work` is discarded and the project completes that turn; builders are then released, and an order to a completed project is refused. From the completion turn on, every turn, a completed project is charged R-MONEY-002's MVP rate, IL 0m, vacant or not, so Money does not change; the catalogue's non-zero `upkeep` is post-MVP and unused (owner's 30 October 2026 "Keep ruling" on UPKEEP, kept on #1700 on 1 November 2026). Only `construction.starts_per_turn` (1) city starts are allowed a turn, counted nationwide: a second start in the same turn is refused before anything is paid, with Money, debt and every project unchanged, and the count resets when the turn ends; projects already running keep progressing. The fixture has no pioneer start, so pioneer work (#1713) never uses the allowance. Cancel, housing repair, completion effects and the live integration are other #1700 slices.
## Training
Training is step 4 of the turn in the approved order (§2.3, D-A6): it runs before production. One military camp and one Hakhshara exist in Tel Aviv at the start, a labelled design assumption (D-D5); pioneers build more at camp sites (R-CAMP-001). Scope note: this is the live `gdd-0.1` start. Under `gdd-0.3`, 27M-25 says: "Schneller and Tel HaShomer operate from the start, the other military camps are build sites, every camp uses `military.camp_capacity` 5, and the reception site is Kiryat Shmuel, Haifa".
-R-TRAIN-001: `Train(city, track, n)` takes `n` of the city's civilians without a job (not a staffed arms workshop's worker, R-ARMS-005) into a cohort that trains as `track` (a unit type with a `facility`: `recruit`, `artillery` and `armoured_car` in a military camp (R-UNIT-008), `halutz` in a Hakhshara, `craftsman` at industry, R-CRAFT-001) for the type's `training_turns`, counting the turn it was ordered in. The Treasury pays `n * training_cost` at once. When the Treasury holds less, the shortfall is borrowed, as for map actions: it is added to the debt and the Treasury stops at 0 (owner decision "Allow borrowing", 15 October 2026). The trainees leave the civilians at once; the cohort takes the next id, which units share. It is refused, with the state unchanged and the Attention refunded, when the city or track is unknown, `n` is below 1, the city lacks the facility, or it has fewer civilians without a job. A city has a facility when `cities.yaml` gives it one at the start or a camp site of that kind built for it is in the state (R-CAMP-001). The legacy loop refuses it before charging Attention. `Reinforce` (R-TRAIN-004) starts a cohort by the same rules, aimed at a unit. A queued `ReassignCraftsmen` or `ReassignPioneers` (R-QUAL-004, R-QUAL-005) takes its civilians without a job as a queued `Train` does (counted in full, so the orders are accepted in any order), in `Training.Ordered` and `Training.Available` (#1548; owner, 24 October 2026: "Yes, count them", https://github.com/eyalgolan/statecraft-israel/issues/1511#issuecomment-6378360813).
+R-TRAIN-001: `Train(city, track, n)` takes `n` of the city's civilians without a job (not a staffed arms workshop's worker, R-ARMS-005, or a builder, R-CITY-011) into a cohort that trains as `track` (a unit type with a `facility`: `recruit`, `artillery` and `armoured_car` in a military camp (R-UNIT-008), `halutz` in a Hakhshara, `craftsman` at industry, R-CRAFT-001) for the type's `training_turns`, counting the turn it was ordered in. The Treasury pays `n * training_cost` at once. When the Treasury holds less, the shortfall is borrowed, as for map actions: it is added to the debt and the Treasury stops at 0 (owner decision "Allow borrowing", 15 October 2026). The trainees leave the civilians at once; the cohort takes the next id, which units share. It is refused, with the state unchanged and the Attention refunded, when the city or track is unknown, `n` is below 1, the city lacks the facility, or it has fewer civilians without a job. A city has a facility when `cities.yaml` gives it one at the start or a camp site of that kind built for it is in the state (R-CAMP-001). The legacy loop refuses it before charging Attention. `Reinforce` (R-TRAIN-004) starts a cohort by the same rules, aimed at a unit. A queued `ReassignCraftsmen` or `ReassignPioneers` (R-QUAL-004, R-QUAL-005) takes its civilians without a job as a queued `Train` does (counted in full, so the orders are accepted in any order), in `Training.Ordered` and `Training.Available` (#1548; owner, 24 October 2026: "Yes, count them", https://github.com/eyalgolan/statecraft-israel/issues/1511#issuecomment-6378360813).
R-TRAIN-002: `CancelTraining(cohort)` returns the cohort's people to its city as civilians without a job and refunds none of the Money paid (D-A3); a recruit cohort's Arms go back to the pool (R-ARMS-003). A cohort that does not exist, or has finished, is refused with the state unchanged. Replacements (R-TRAIN-004) cancel the same way.
@@ -432,9 +434,9 @@ R-ARMS-003: Recruit training (R-TRAIN-001) takes `arms_per_recruit_group` (1) Ar
R-ARMS-004: Under gdd-0.3 only, the arms workshop (`projects.yaml` `arms_workshop`, #1701) is a city project kind: `StartProject` builds it as R-PROJ-001 to R-PROJ-003 build any kind, for IL 15m and 3 turns (owner, 2 November 2026, #1701 OQ2: "IL 15m, 3 turns (Recommended)"; the gdd-0.3 catalogue's `arms_workshop` cost 15 and work 3). Built, it gives one workshop worker slot (`worker_slots: 1`, the catalogue's `arms_workshop.parts.worker_slots`) and adds no housing, condition or job slots: a workshop gives no Industry job (`docs/gdd/cities.md`, "Arms workshops"). Its row carries `rulesets: [gdd-0.3]`, and the loader leaves it out of every other ruleset's kinds, so a gdd-0.1 game neither lists nor starts it (`StartProject` refuses it as an unknown kind) and its state does not change; the row still moves the content hash. The loader refuses an unknown ruleset id in `rulesets`, `worker_slots` other than 0 or 1, a kind with a worker slot that has capacity, condition or job slots or is not limited to exactly gdd-0.3, and, under gdd-0.3, an `arms_workshop` whose worker slots differ from the catalogue's. It pays no upkeep: R-MONEY-002 has no rate for it (the catalogue's 0.50 is a Default). Its Hebrew name סדנת נשק is a draft awaiting a native speaker's review (`name_he_review: agent-checked`, #564; owner, 2 November 2026, #1701 OQ8).
-R-ARMS-005: Under gdd-0.3, `AssignWorkers(city, "workshop", n)` is a standing order that staffs the city's first `n` built arms workshops, in ascending project id, and leaves the rest unstaffed (27M-13, owner-approved 1 November 2026: "Any free civilian. The cost tier follows the worker (novice or ordinary / apprentice / expert)."). A newly staffed workshop takes one of the city's civilians and craftsmen who hold no job; the worker stays one of them, with no job, profession or qualification change, is not employed (R-CITY-001) and earns no job income (R-CITY-002). On the aggregate cities every worker is priced at the ordinary or novice tier until the population ledger's tiers are live (owner, 2 November 2026, #1701 OQ6: "Accept all four (Recommended)"; R-POP-004). It is refused, state unchanged, for an unknown city, a negative count, more than the city's built workshops ("Town A has 1 arms workshop"), or more newly staffed workshops than the city's people without a job ("... civilians and craftsmen without a job"); under every other ruleset the `workshop` role is refused as "There is no such role". While the city's job default is on (R-CITY-009), a newly staffed workshop may take its worker from the default's jobs instead: the order is refused only past the city's civilians and craftsmen less its staffed workshops ("... civilians and craftsmen"), the city's employed falls to at most its civilians and craftsmen less the staffed workshops (a `city` cause, "Town: N groups in work"), and the default stays on, filling one job fewer (R-CITY-001; #2270 review fix, 2 November 2026). A number of jobs the player set (default off) is never lowered: there the order needs people without a job. A staffed workshop's worker is not idle: `Train` (R-TRAIN-001) and `ReassignPioneers` (R-QUAL-005) cannot take them, and the Train panel's limit (`Training.Available`) counts a pending `workshop` order's newly staffed workers, never as jobs. An unstaffed workshop keeps its record, paid cost and progress (a pause, R-ARMS-007). There is no limit on workshops per city beyond one project a hex and the starts a turn (R-PROJ-001; #1701 OQ7). `GameState.Workshops` holds every workshop ever staffed, by project id, and is hashed as `wshop[...]` only when it has one (R-LOOP-002). The hex panel of a built workshop (#1722, #1701 slice E) queues it: `Workshops.Check(city, n, pending)` gives the order's own refusal and, with this turn's queue, also counts the city's pending `job` order and its Train and reassignment orders, so a count it accepts is accepted whichever runs first; the jobs stepper's limit (`Cities.MaxWorkers` with the queue) counts a pending `workshop` order's newly staffed workers, as `Training.Available` does. The panel's next-cycle price is `Workshops.NextCyclePrice`, what the production step would charge (R-ARMS-006), shown for a workshop never staffed too, at the ordinary or novice tier, and its cycle length is `Workshops.CycleMonths`. A jobs order past the city's civilians and craftsmen less its staffed workshops is refused with the staffing order's people format, "Town A has N civilians and craftsmen" (#1722 review).
+R-ARMS-005: Under gdd-0.3, `AssignWorkers(city, "workshop", n)` is a standing order that staffs the city's first `n` built arms workshops, in ascending project id, and leaves the rest unstaffed (27M-13, owner-approved 1 November 2026: "Any free civilian. The cost tier follows the worker (novice or ordinary / apprentice / expert)."). A newly staffed workshop takes one of the city's civilians and craftsmen who hold no job; the worker stays one of them, with no job, profession or qualification change, is not employed (R-CITY-001) and earns no job income (R-CITY-002). On the aggregate cities every worker is priced at the ordinary or novice tier until the population ledger's tiers are live (owner, 2 November 2026, #1701 OQ6: "Accept all four (Recommended)"; R-POP-004). It is refused, state unchanged, for an unknown city, a negative count, more than the city's built workshops ("Town A has 1 arms workshop"), or more newly staffed workshops than the city's people without a job ("... civilians and craftsmen without a job"); under every other ruleset the `workshop` role is refused as "There is no such role". While the city's job default is on (R-CITY-009), a newly staffed workshop may take its worker from the default's jobs instead: the order is refused only past the city's civilians and craftsmen less its staffed workshops and builders (R-CITY-011) ("... civilians and craftsmen"), the city's employed falls to at most its civilians and craftsmen less the staffed workshops and builders (a `city` cause, "Town: N groups in work"), and the default stays on, filling one job fewer (R-CITY-001; #2270 review fix, 2 November 2026). A number of jobs the player set (default off) is never lowered: there the order needs people without a job. A builder (R-CITY-011) is not one of the city's people without a job for this order. A staffed workshop's worker is not idle: `Train` (R-TRAIN-001) and `ReassignPioneers` (R-QUAL-005) cannot take them, and the Train panel's limit (`Training.Available`) counts a pending `workshop` order's newly staffed workers, never as jobs. An unstaffed workshop keeps its record, paid cost and progress (a pause, R-ARMS-007). There is no limit on workshops per city beyond one project a hex and the starts a turn (R-PROJ-001; #1701 OQ7). `GameState.Workshops` holds every workshop ever staffed, by project id, and is hashed as `wshop[...]` only when it has one (R-LOOP-002). The hex panel of a built workshop (#1722, #1701 slice E) queues it: `Workshops.Check(city, n, pending)` gives the order's own refusal and, with this turn's queue, also counts the city's pending `job` order and its Train and reassignment orders, so a count it accepts is accepted whichever runs first; the jobs stepper's limit (`Cities.MaxWorkers` with the queue) counts a pending `workshop` order's newly staffed workers, as `Training.Available` does. The panel's next-cycle price is `Workshops.NextCyclePrice`, what the production step would charge (R-ARMS-006), shown for a workshop never staffed too, at the ordinary or novice tier, and its cycle length is `Workshops.CycleMonths`. A jobs order past the city's civilians and craftsmen less its staffed workshops is refused with the staffing order's people format, "Town A has N civilians and craftsmen" (#1722 review).
-R-ARMS-006: On step 6 of the turn, after the cities' job income, in ascending project id, each staffed arms workshop under gdd-0.3 works this month when its city is not held (R-CITY-010) and one of the city's people without a job is left for it (each workshop of the city takes one, in ascending project id; when none is left for it, it waits, and the Why screen says so). A workshop with no cycle under way first pays for one there (27M-11: "At the monthly production step."), at its worker's tier from the gdd-0.3 catalogue: `workshop.cost` IL 5m / 4m / 3m (ordinary or novice / apprentice / expert; `docs/GDD.md`'s balance ruling: "`workshop.cost` is Money per Arms and stays."), beside the IL 1m an Arms of R-ARMS-002 (owner, 2 November 2026, #1701 OQ1: "Keep as ruled"). A short Treasury borrows the rest (R-MONEY-003; 27M-12: "Automatic each month while the workshop is staffed, paid like any GDD cost."), but a cycle whose borrowing would take the debt past `debt_ceiling` is not paid: the workshop waits that month, the turn report says why (below), and nothing is borrowed (owner, 2 November 2026, #1701 OQ4: "Refuse past the ceiling (Recommended)"; exactly at the ceiling is allowed, and a Treasury that pays in full is never refused, as in R-ARMS-002). The month a cycle is paid is its first staffed month (#1701 OQ3: "Accept all four (Recommended)"). After `workshop.staffed_turns` (3) staffed months the cycle adds 1 Arms to the stock (R-ARMS-001) and ends, and the next month starts the next one by itself, with no order. When the Arms stock is `int.MaxValue`, a finished cycle waits silently at its completed, paid progress, keeps its worker, and adds no Arms or Why line. A worker change keeps the cycle's paid cost and progress; only the next cycle is priced at the new worker's tier (27M-13). An unstaffed workshop, or one in a held city, keeps its cycle as it is and is not charged. The turn-report panel lists, in a row of its own after the stocks, each Arms a workshop made ("Workshop in Town: +1 Arms") and each ceiling pause ("Workshop in Town paused: debt ceiling") (owner, 2 November 2026, #1701 A1: "Yes, in the panel (Recommended)", the option "The turn-report panel shows 'Workshop in <city>: +1 Arms' and 'Workshop in <city> paused: debt ceiling'."); a no-worker pause is on the Why screen only. A city's Arms are one line and its ceiling pauses another, each with its count when there are two or more ("Workshops in Town (2): +2 Arms", "Workshops in Town (2) paused: debt ceiling"), in the order each first appears among the turn's causes (owner, 2 November 2026: "Combine per city (Recommended)", the option "'Workshops in Tel Aviv (6): +6 Arms'; pauses likewise combined with a count."). The option gives no wording for one workshop, so a city with one keeps A1's line. The count is the number of the sim's causes; the UI computes nothing else.
+R-ARMS-006: On step 6 of the turn, after the cities' job income, in ascending project id, each staffed arms workshop under gdd-0.3 works this month when its city is not held (R-CITY-010) and one of the city's people without a job is left for it once step 5's builders have taken theirs (R-CITY-011; each workshop of the city takes one, in ascending project id; when none is left for it, it waits, and the Why screen says so). A workshop with no cycle under way first pays for one there (27M-11: "At the monthly production step."), at its worker's tier from the gdd-0.3 catalogue: `workshop.cost` IL 5m / 4m / 3m (ordinary or novice / apprentice / expert; `docs/GDD.md`'s balance ruling: "`workshop.cost` is Money per Arms and stays."), beside the IL 1m an Arms of R-ARMS-002 (owner, 2 November 2026, #1701 OQ1: "Keep as ruled"). A short Treasury borrows the rest (R-MONEY-003; 27M-12: "Automatic each month while the workshop is staffed, paid like any GDD cost."), but a cycle whose borrowing would take the debt past `debt_ceiling` is not paid: the workshop waits that month, the turn report says why (below), and nothing is borrowed (owner, 2 November 2026, #1701 OQ4: "Refuse past the ceiling (Recommended)"; exactly at the ceiling is allowed, and a Treasury that pays in full is never refused, as in R-ARMS-002). The month a cycle is paid is its first staffed month (#1701 OQ3: "Accept all four (Recommended)"). After `workshop.staffed_turns` (3) staffed months the cycle adds 1 Arms to the stock (R-ARMS-001) and ends, and the next month starts the next one by itself, with no order. When the Arms stock is `int.MaxValue`, a finished cycle waits silently at its completed, paid progress, keeps its worker, and adds no Arms or Why line. A worker change keeps the cycle's paid cost and progress; only the next cycle is priced at the new worker's tier (27M-13). An unstaffed workshop, or one in a held city, keeps its cycle as it is and is not charged. The turn-report panel lists, in a row of its own after the stocks, each Arms a workshop made ("Workshop in Town: +1 Arms") and each ceiling pause ("Workshop in Town paused: debt ceiling") (owner, 2 November 2026, #1701 A1: "Yes, in the panel (Recommended)", the option "The turn-report panel shows 'Workshop in <city>: +1 Arms' and 'Workshop in <city> paused: debt ceiling'."); a no-worker pause is on the Why screen only. A city's Arms are one line and its ceiling pauses another, each with its count when there are two or more ("Workshops in Town (2): +2 Arms", "Workshops in Town (2) paused: debt ceiling"), in the order each first appears among the turn's causes (owner, 2 November 2026: "Combine per city (Recommended)", the option "'Workshops in Tel Aviv (6): +6 Arms'; pauses likewise combined with a count."). The option gives no wording for one workshop, so a city with one keeps A1's line. The count is the number of the sim's causes; the UI computes nothing else.
R-ARMS-007: A workshop's cycle progress is lost and its Money is not refunded on a destructive cancellation, destruction or transfer of the workshop (27M-14, owner-approved 1 November 2026: "Cycle progress is lost and the Money paid is not refunded."). The MVP has none (owner, 2 November 2026, #1701 OQ5: "Accept all four (Recommended)"): a built project cannot be cancelled (R-PROJ-002), a held city pauses (R-CITY-010) and unstaffing pauses (R-ARMS-005), and each keeps the cycle; a later mechanism that destroys or transfers a workshop applies this rule. Workshop work changes no qualification, profession or craftsman count (Q55, owner-approved 1 November 2026: "No. Only the stated apprentice-to-expert progression counts").
diff --git a/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs b/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs
index 5e879a6b4..de6562fa6 100644
--- a/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs
+++ b/sim/Statecraft.Sim.Tests/ArmsWorkshopTests.cs
@@ -83,6 +83,7 @@ public class ArmsWorkshopTests
Assert.Equal(5, one.Why.Single(w => w.Key == CauseKeys.Borrowed && w.Args[0] == CauseKeys.Purpose.Project).Delta, 9); // IL 15m against IL 10m
var p = one.State.CityProjects.Values.Single();
Assert.Equal(("arms_workshop", 2, (DateTime?)null), (p.Kind, p.TurnsLeft, p.BuiltOn));
+ Assert.True(p.Builder); // R-CITY-011 (#1700): town_a has people without a job, so the start takes one as its builder
var built = Step(c, Step(c, one.State).State).State;
Assert.NotNull(built.CityProjects[p.Id].BuiltOn);
var before = s.Cities["town_a"]; var after = built.Cities["town_a"];
diff --git a/sim/Statecraft.Sim.Tests/CityBuildersTests.cs b/sim/Statecraft.Sim.Tests/CityBuildersTests.cs
new file mode 100644
index 000000000..864a7f587
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/CityBuildersTests.cs
@@ -0,0 +1,479 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>#1700 slice A (GDD 0.3 builders on the aggregate cities), under gdd-0.3 only: R-CITY-011 with R-PROJ-001 to
+/// R-PROJ-003 (owner, 3 November 2026: "Builders in the MVP (Recommended)", "One builder, today's times (Recommended)",
+/// "Yes, if someone is free"). The fixture's town_a is on (1, 0), with (1, 1) and (2, 0) land next to it; its housing takes
+/// 2 turns, its transit camp 1 and its industry 2 (Fixture.GddProjects).</summary>
+public class CityBuildersTests
+{
+ static StepResult Step(Content c, GameState s, params Command[] commands) => Simulation.Step(c, s, commands);
+
+ /// <summary>A game whose town_a has <paramref name="jobs"/> job slots and <paramref name="civilians"/> civilians,
+ /// <paramref name="employed"/> of them in jobs.</summary>
+ static (Content C, GameState S) Game(int civilians = 10, int employed = 8, int jobs = 8, bool jobsDefault = false, bool gdd03 = true,
+ string projects = Fixture.GddProjects + ArmsWorkshopTests.Row)
+ {
+ var c = ArmsWorkshopTests.Load(gdd03, projects);
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ var x = s.Cities["town_a"];
+ s.Cities["town_a"] = new City(x.Id, x.HousingCapacity, jobs, civilians, employed, 0, 0, x.Condition, jobsDefault: jobsDefault);
+ return (c, s);
+ }
+
+ /// <summary>Adds a town_a project of <paramref name="kind"/> being built on hex (q, r), and returns its id.</summary>
+ static int Add(GameState s, string kind, int q, int r, int turnsLeft, bool builder)
+ {
+ var id = s.NextId++;
+ s.CityProjects.Add(id, new CityProject(id, kind, "town_a", q, r, turnsLeft, builder: builder));
+ return id;
+ }
+
+ static AssignWorkers Build(int count, string city = "town_a") => new AssignWorkers(city, Projects.BuildRole, count);
+
+ static StartProject Housing() => new StartProject("housing", "town_a", 1, 1);
+
+ // R-CITY-011: a start takes one of the city's people without a job as its builder. The builder holds no job, so the
+ // employed count is unchanged, but nobody else can take them: the idle civilians and the job limit are 1 lower.
+ [Fact]
+ public void Gdd03StartTakesAFreePersonAsBuilder()
+ {
+ var (c, s) = Game(); // 10 civilians, 8 in jobs: 2 without a job
+ var r = Step(c, s, Housing());
+ Assert.Empty(r.Rejected);
+ var p = r.State.CityProjects.Values.Single();
+ Assert.True(p.Builder);
+ Assert.Equal(1, Projects.Builders(r.State, "town_a"));
+ var line = Assert.Single(r.Why, w => w.Key == CauseKeys.ProjectBuilder);
+ Assert.Equal(("town_a", "housing", "Town A: a builder started on a housing project"), (line.Target, string.Join("|", line.Args), line.Message));
+ var before = Step(c, s).State;
+ var x = r.State.Cities["town_a"]; var was = before.Cities["town_a"];
+ Assert.Equal(was.Employed, x.Employed);
+ Assert.Equal(Training.Idle(before, was) - 1, Training.Idle(r.State, x));
+ Assert.Equal(Training.Available(before, "town_a", Array.Empty<Command>()) - 1, Training.Available(r.State, "town_a", Array.Empty<Command>()));
+ // The job limit counts down from the city's people, so give it room to show the builder.
+ var roomy = new City(x.Id, x.HousingCapacity, 20, x.Civilians, x.Employed, x.Refugees, x.Recruits, x.Condition, x.Craftsmen, x.JobsDefault, x.Qualified);
+ var roomyWas = new City(was.Id, was.HousingCapacity, 20, was.Civilians, was.Employed, was.Refugees, was.Recruits, was.Condition, was.Craftsmen, was.JobsDefault, was.Qualified);
+ Assert.Equal(Cities.MaxWorkers(before, roomyWas) - 1, Cities.MaxWorkers(r.State, roomy));
+ }
+
+ // R-CITY-011, R-PROJ-003: with nobody free at the start, the project has no builder and waits: no progress, nothing
+ // added, while the Money was still paid at the start (R-PROJ-001). The check runs once, at the start.
+ [Fact]
+ public void Gdd03StartWithNobodyFreeWaits()
+ {
+ var (c, s) = Game(civilians: 10, employed: 10, jobs: 10);
+ var r = Step(c, s, Housing());
+ Assert.Empty(r.Rejected);
+ Assert.Contains(r.Why, w => w.Key == CauseKeys.Paid && w.Args[0] == CauseKeys.Purpose.Project);
+ var id = r.State.CityProjects.Keys.Single();
+ var wait = Assert.Single(r.Why, w => w.Key == CauseKeys.ProjectWaiting);
+ Assert.Equal(("housing|" + Projects.NoBuilder, "Town A: a housing project waits: no builder"), (string.Join("|", wait.Args), wait.Message));
+ var state = r.State;
+ for (int i = 1; i < 12; i++) state = Step(c, state).State;
+ var p = state.CityProjects[id];
+ Assert.False(p.Builder);
+ Assert.Equal((2, (DateTime?)null), (p.TurnsLeft, p.BuiltOn));
+ var x = state.Cities["town_a"]; var was = s.Cities["town_a"];
+ Assert.Equal((was.HousingCapacity, was.JobSlots), (x.HousingCapacity, x.JobSlots));
+ }
+
+ // R-CITY-011 with R-CITY-009: the automatic builder never takes anyone out of a job, the default's jobs included.
+ [Fact]
+ public void Gdd03AutoBuilderNeverTakesADefaultJob()
+ {
+ var (c, s) = Game(civilians: 8, employed: 8, jobs: 8, jobsDefault: true);
+ var r = Step(c, s, Housing());
+ Assert.Empty(r.Rejected);
+ Assert.False(r.State.CityProjects.Values.Single().Builder);
+ Assert.Equal(8, r.State.Cities["town_a"].Employed);
+ }
+
+ // R-CITY-011: the start takes its builder when it runs, in queue order: a Train queued first takes the one free person;
+ // queued after the start, the Train finds nobody idle.
+ [Fact]
+ public void Gdd03AutoBuilderFollowsQueueOrder()
+ {
+ var (c, s) = Game(civilians: 10, employed: 9, jobs: 9);
+ var first = Step(c, s, new Train("town_a", "halutz", 1), Housing());
+ Assert.Empty(first.Rejected);
+ Assert.False(first.State.CityProjects.Values.Single().Builder);
+ var after = Step(c, s, Housing(), new Train("town_a", "halutz", 1));
+ Assert.True(after.State.CityProjects.Values.Single().Builder);
+ var refused = Assert.Single(after.Rejected);
+ Assert.IsType<Train>(refused.Command);
+ Assert.Equal("Town A has 0 civilians without work", refused.Reason);
+ }
+
+ // R-PROJ-003 ("One builder, today's times"): with a builder from its start, a project is built after exactly its
+ // kind's turns, and adds its capacity, condition and job slots once.
+ [Theory]
+ [InlineData("transit_camp", 1)]
+ [InlineData("industry", 2)]
+ public void Gdd03BuiltInTodaysTurns(string kind, int turns)
+ {
+ var (c, s) = Game();
+ s.Policies[MapActions.MaabarotPolicy] = 1;
+ var k = c.ProjectKinds.Single(x => x.Id == kind);
+ var state = Step(c, s, new StartProject(kind, "town_a", 1, 1)).State;
+ var id = state.CityProjects.Keys.Single();
+ Assert.True(state.CityProjects[id].Builder || state.CityProjects[id].BuiltOn != null);
+ for (int i = 1; i < turns; i++)
+ {
+ Assert.Null(state.CityProjects[id].BuiltOn);
+ state = Step(c, state).State;
+ }
+ Assert.NotNull(state.CityProjects[id].BuiltOn);
+ var was = s.Cities["town_a"];
+ var built = state.Cities["town_a"];
+ Assert.Equal((was.HousingCapacity + k.Capacity, was.JobSlots + k.JobSlots), (built.HousingCapacity, built.JobSlots));
+ var later = Step(c, state).State.Cities["town_a"];
+ Assert.Equal((built.HousingCapacity, built.JobSlots), (later.HousingCapacity, later.JobSlots));
+ }
+
+ // R-PROJ-003: Money is never an input to progress.
+ [Fact]
+ public void Gdd03ExtraMoneyDoesNotChangeTheCompletionTurn()
+ {
+ DateTime? BuiltOn(double treasury)
+ {
+ var (c, s) = Game();
+ s.Treasury = treasury; s.Debt = 0;
+ var state = Step(c, s, Housing()).State;
+ Assert.True(state.CityProjects.Values.Single().Builder);
+ for (int i = 0; i < 4; i++) state = Step(c, state).State;
+ return state.CityProjects.Values.Single().BuiltOn;
+ }
+ var poor = BuiltOn(1);
+ Assert.NotNull(poor);
+ Assert.Equal(poor, BuiltOn(1000));
+ }
+
+ // R-CITY-011, R-PROJ-003: taking the builder off pauses the project with its progress kept; putting one back resumes it,
+ // so it is built exactly as many turns later as it waited.
+ [Fact]
+ public void Gdd03UnstaffingPausesAndKeepsProgress()
+ {
+ // Housing at the real game's 6 turns, so a pause fits before it is built.
+ var (c, s) = Game(projects: Fixture.GddProjects.Replace("cost: 3, turns: 2", "cost: 3, turns: 6") + ArmsWorkshopTests.Row);
+ int BuiltAt(bool pause)
+ {
+ var state = Step(c, s, Housing()).State; // turn 1
+ var id = state.CityProjects.Keys.Single();
+ Assert.True(state.CityProjects[id].Builder);
+ for (int turn = 2; turn <= 20; turn++)
+ {
+ var orders = !pause ? Array.Empty<Command>() : turn == 3 ? new Command[] { Build(0) } : turn == 6 ? new Command[] { Build(1) } : Array.Empty<Command>();
+ var left = state.CityProjects[id].TurnsLeft;
+ var r = Step(c, state, orders);
+ Assert.Empty(r.Rejected);
+ if (pause && turn >= 3 && turn <= 5) Assert.Equal(left, r.State.CityProjects[id].TurnsLeft);
+ state = r.State;
+ if (state.CityProjects[id].BuiltOn != null) return turn;
+ }
+ throw new InvalidOperationException("never built");
+ }
+ Assert.Equal(6, BuiltAt(false));
+ Assert.Equal(9, BuiltAt(true));
+ }
+
+ // R-CITY-011: a rise puts builders on the projects that have none, in ascending id; a fall takes them off, in descending id.
+ [Fact]
+ public void Gdd03AssignBuildFillsAscendingAndRemovesDescending()
+ {
+ var (c, s) = Game(civilians: 10, employed: 6);
+ // 5 turns left, so none is built (and its builder freed) during the two turns.
+ var one = Add(s, "housing", 1, 1, 5, false);
+ var two = Add(s, "industry", 2, 0, 5, true);
+ var three = Add(s, "housing", 0, 1, 5, false);
+ var up = Step(c, s, Build(2));
+ Assert.Empty(up.Rejected);
+ Assert.Equal((true, true, false), (up.State.CityProjects[one].Builder, up.State.CityProjects[two].Builder, up.State.CityProjects[three].Builder));
+ var down = Step(c, up.State, Build(1));
+ Assert.Empty(down.Rejected);
+ Assert.Equal((true, false, false), (down.State.CityProjects[one].Builder, down.State.CityProjects[two].Builder, down.State.CityProjects[three].Builder));
+ }
+
+ // R-CITY-011: the order's refusals leave the state as it was; under gdd-0.1 the role does not exist.
+ [Theory]
+ [InlineData("town_a", 4, true, "Town A has 3 city projects being built")]
+ [InlineData("town_a", 3, true, "Town A has 1 civilians and craftsmen without a job")]
+ [InlineData("town_a", -1, true, "The number of workers cannot be negative")]
+ [InlineData("nowhere", 1, true, "There is no such city")]
+ [InlineData("town_a", 1, false, "There is no such role")]
+ public void Gdd03BuildRefusals(string city, int count, bool gdd03, string reason)
+ {
+ var (c, s) = Game(civilians: 10, employed: 8, gdd03: gdd03); // 2 without a job
+ Add(s, "housing", 1, 1, 2, gdd03); // under gdd-0.3 its builder is one of the 2
+ Add(s, "industry", 2, 0, 2, false);
+ Add(s, "housing", 0, 1, 2, false);
+ var r = Step(c, s, Build(count, city));
+ Assert.Equal(reason, Assert.Single(r.Rejected).Reason);
+ Assert.Equal(Step(c, s).State.Hash(), r.State.Hash());
+ }
+
+ [Fact]
+ public void Gdd03BuildRefusesOneProjectInTheSingular()
+ {
+ var (c, s) = Game();
+ Add(s, "housing", 1, 1, 2, false);
+ Assert.Equal("Town A has 1 city project being built", Assert.Single(Step(c, s, Build(2)).Rejected).Reason);
+ }
+
+ // R-CITY-011, R-PROJ-002: a builder is freed when the project is built or cancelled, and does not move to another
+ // project by itself; a cancel returns no Money.
+ [Fact]
+ public void Gdd03BuilderFreedOnCompletionAndCancel()
+ {
+ var (c, s) = Game();
+ var done = Add(s, "housing", 1, 1, 1, true);
+ var waiting = Add(s, "industry", 2, 0, 2, false);
+ var r = Step(c, s).State;
+ Assert.NotNull(r.CityProjects[done].BuiltOn);
+ Assert.False(r.CityProjects[done].Builder);
+ Assert.False(r.CityProjects[waiting].Builder);
+ Assert.Equal(2, r.CityProjects[waiting].TurnsLeft);
+ Assert.Equal(0, Projects.Builders(r, "town_a"));
+
+ var (c2, s2) = Game();
+ var id = Add(s2, "housing", 1, 1, 2, true);
+ var cancel = Step(c2, s2, new CancelProject(id));
+ Assert.Empty(cancel.Rejected);
+ Assert.Equal(0, Projects.Builders(cancel.State, "town_a"));
+ var none = Step(c2, s2).State;
+ Assert.Equal(Training.Idle(none, none.Cities["town_a"]) + 1, Training.Idle(cancel.State, cancel.State.Cities["town_a"]));
+ Assert.Equal(none.Treasury, cancel.State.Treasury, 9);
+ }
+
+ // R-CITY-011 with R-ARMS-006: builders and workshop workers share the city's people without a job; step 5 (the
+ // projects) comes before step 6 (the workshops), so with one such person the project advances and the workshop pauses.
+ [Fact]
+ public void Gdd03BuilderAndWorkshopShareTheFreePeople()
+ {
+ var (c, s, workshop) = ArmsWorkshopTests.Built(civilians: 10, employed: 9, jobs: 9, jobsDefault: false);
+ s.Workshops.Add(workshop, new Workshop(workshop, true, SyntheticWorkshopTier.Ordinary));
+ var id = Add(s, "housing", 2, 0, 2, true);
+ var r = Step(c, s);
+ Assert.Equal(1, r.State.CityProjects[id].TurnsLeft);
+ var paused = Assert.Single(r.Why, w => w.Key == CauseKeys.WorkshopPaused);
+ Assert.Equal(Workshops.NoWorker, paused.Args[0]);
+ }
+
+ // R-CITY-011 with R-CITY-010: a held city's project keeps its builder and its turns.
+ [Fact]
+ public void Gdd03HeldCityKeepsItsBuilder()
+ {
+ var (c, s) = Game();
+ var id = Add(s, "housing", 1, 1, 2, true);
+ s.Units.Add(s.NextId, new Unit(s.NextId++, "enemy", 1, 0, side: "egypt", strength: 3));
+ var p = Step(c, s).State.CityProjects[id];
+ Assert.True(p.Builder);
+ Assert.Equal(2, p.TurnsLeft);
+ }
+
+ // R-CITY-011 with R-CITY-009: the job default fills jobs from the people without a job who are not builders.
+ [Fact]
+ public void Gdd03JobDefaultLeavesBuildersOut()
+ {
+ var (c, s) = Game(civilians: 10, employed: 6, jobs: 10, jobsDefault: true);
+ Add(s, "housing", 1, 1, 2, true);
+ var x = Step(c, s).State.Cities["town_a"];
+ Assert.Equal(9, x.Employed);
+ Assert.True(x.Employed <= x.Civilians + x.Craftsmen - 1);
+ }
+
+ // R-PROJ-001, R-PROJ-003: gdd-0.1 is unchanged: its projects need no workers, take no builder and write no new field.
+ [Fact]
+ public void Gdd01ProjectsStillNeedNoWorkers()
+ {
+ var (c, s) = Game(civilians: 10, employed: 10, jobs: 10, gdd03: false); // nobody free
+ var one = Step(c, s, Housing());
+ Assert.Empty(one.Rejected);
+ Assert.DoesNotContain(one.Why, w => w.Key == CauseKeys.ProjectBuilder || w.Key == CauseKeys.ProjectWaiting);
+ var id = one.State.CityProjects.Keys.Single();
+ Assert.False(one.State.CityProjects[id].Builder);
+ Assert.Equal(FormattableString.Invariant($"{id}:housing@town_a,1,1/1"), one.State.CityProjects[id].Canonical());
+ var two = Step(c, one.State).State;
+ Assert.NotNull(two.CityProjects[id].BuiltOn);
+ Assert.Equal(10, two.Cities["town_a"].Employed);
+ }
+
+ // R-CITY-011: the builder is written into the state hash only when set.
+ [Fact]
+ public void TheBuilderIsHashedOnlyWhenSet()
+ {
+ var p = new CityProject(5, "housing", "town_a", 1, 1, 2);
+ Assert.Equal("5:housing@town_a,1,1/2", p.Canonical());
+ Assert.Equal("5:housing@town_a,1,1/2;builder", p.WithBuilder(true).Canonical());
+ Assert.Equal("5:housing@town_a,1,1/done,1948-05-15", p.WithBuilder(true).Built(new DateTime(1948, 5, 15)).Canonical());
+ }
+ // R-SAVE with R-CITY-011 (review MUST-1): a save is the command log, so a game with builders, saved and loaded, replays to
+ // the same state, the builders included, and goes on identically.
+ [Fact]
+ public void Gdd03BuildersSurviveASaveAndLoad()
+ {
+ // Housing and industry at 6 turns, so both are still being built when the game is saved.
+ var c = ArmsWorkshopTests.Load(true, Fixture.GddProjects.Replace("turns: 2,", "turns: 6,") + ArmsWorkshopTests.Row);
+ var orders = new Dictionary<int, Command[]>
+ {
+ [0] = new Command[] { Housing(), new StartProject("industry", "town_a", 2, 0) },
+ [1] = new Command[] { Build(1) },
+ };
+ var game = GameSession.New(c, 7, Mode.Historical);
+ for (int t = 0; t < 2; t++) game.Step(orders[t]);
+ Assert.Contains(";builder", game.State.Describe());
+ var loaded = GameSession.Load(c, game.Save.Write(), out _);
+ Assert.Equal(game.State.Hash(), loaded.State.Hash());
+ game.Step(Array.Empty<Command>());
+ loaded.Step(Array.Empty<Command>());
+ Assert.Equal(game.State.Hash(), loaded.State.Hash());
+ }
+
+ // R-TRAIN-001, R-ARMS-005, R-CITY-001 with R-CITY-011 (review SHOULD-1): the limits a panel reads with this turn's queue
+ // count the builder a queued gdd-0.3 start takes, so a count up to them is accepted whichever order runs first.
+ [Fact]
+ public void Gdd03QueuedStartCountsInThePanelLimits()
+ {
+ var (c, s) = Game(civilians: 10, employed: 9, jobs: 20); // one free person
+ var queued = new Command[] { Housing() };
+ Assert.Equal(0, Training.Available(s, "town_a", queued));
+ var train = Step(c, s, Housing(), new Train("town_a", "halutz", 1));
+ Assert.Single(train.Rejected); // the limit of 0 is what makes this refusal expected
+ Assert.Equal(9, Cities.MaxWorkers(s, "town_a", queued));
+ Assert.Empty(Step(c, s, Housing(), new AssignWorkers("town_a", "job", 9)).Rejected);
+ Assert.Single(Step(c, s, Housing(), new AssignWorkers("town_a", "job", 10)).Rejected);
+ var (wc, ws, _) = ArmsWorkshopTests.Built(civilians: 10, employed: 9, jobs: 9, jobsDefault: false);
+ Assert.Null(Workshops.Check(wc, ws, "town_a", 1, Array.Empty<Command>()));
+ Assert.NotNull(Workshops.Check(wc, ws, "town_a", 1, new Command[] { new StartProject("housing", "town_a", 2, 0) }));
+ // Under gdd-0.1 a start takes nobody, so nothing changes.
+ var (oc, os) = Game(civilians: 10, employed: 9, jobs: 20, gdd03: false);
+ Assert.Equal(1, Training.Available(os, "town_a", queued));
+ }
+
+ // R-PROJ-003, R-ARMS-006 (review SHOULD-3): with two builders and one person without a job, the lower id advances, the
+ // higher waits with no_worker, and the city's staffed workshop pauses at step 6.
+ [Fact]
+ public void Gdd03MoreBuildersThanPeopleWaitInAscendingId()
+ {
+ var (c, s, workshop) = ArmsWorkshopTests.Built(civilians: 10, employed: 9, jobs: 9, jobsDefault: false);
+ s.Workshops.Add(workshop, new Workshop(workshop, true, SyntheticWorkshopTier.Ordinary));
+ var low = Add(s, "housing", 2, 0, 2, true);
+ var high = Add(s, "industry", 0, 1, 2, true);
+ var r = Step(c, s);
+ Assert.Equal((1, 2), (r.State.CityProjects[low].TurnsLeft, r.State.CityProjects[high].TurnsLeft));
+ var wait = Assert.Single(r.Why, w => w.Key == CauseKeys.ProjectWaiting);
+ Assert.Equal(("industry", Projects.NoWorker), (wait.Args[0], wait.Args[1]));
+ Assert.Equal("Town A: an industry project waits: no person without a job is left for its builder", wait.Message);
+ Assert.Equal(Workshops.NoWorker, Assert.Single(r.Why, w => w.Key == CauseKeys.WorkshopPaused).Args[0]);
+ Assert.True(r.State.CityProjects[high].Builder); // a wait keeps the builder
+ }
+
+ // R-CITY-011 (review SHOULD-3): a city with nobody starts its project without a builder, and the build order is refused.
+ [Fact]
+ public void Gdd03ACityWithNobodyTakesNoBuilder()
+ {
+ var (c, s) = Game(civilians: 0, employed: 0, jobs: 0);
+ var r = Step(c, s, Housing());
+ Assert.Empty(r.Rejected);
+ Assert.False(r.State.CityProjects.Values.Single().Builder);
+ Assert.Equal("Town A has 0 civilians and craftsmen without a job", Assert.Single(Step(c, r.State, Build(1)).Rejected).Reason);
+ }
+
+ // R-CITY-011 with R-CITY-009 (review NIT-2): a person the job default has not yet put in an open job holds no job, so a
+ // start takes them; the default then fills one job fewer.
+ [Fact]
+ public void Gdd03AutoBuilderTakesAPersonTheDefaultHadNotPlaced()
+ {
+ var (c, s) = Game(civilians: 10, employed: 8, jobs: 10, jobsDefault: true);
+ var r = Step(c, s, Housing());
+ Assert.True(r.State.CityProjects.Values.Single().Builder);
+ Assert.Equal(9, r.State.Cities["town_a"].Employed);
+ Assert.Equal(10, Step(c, s).State.Cities["town_a"].Employed);
+ }
+ // R-CITY-011 (second review): a start's free person excludes an existing builder and a staffed workshop's worker.
+ [Fact]
+ public void Gdd03StartSeesAnExistingBuilder()
+ {
+ var (c, s) = Game(civilians: 10, employed: 9, jobs: 9); // one person without a job, already a builder
+ Add(s, "industry", 2, 0, 5, true);
+ var r = Step(c, s, Housing());
+ Assert.Empty(r.Rejected);
+ Assert.False(r.State.CityProjects.Values.Single(p => p.Kind == "housing").Builder);
+ }
+
+ [Fact]
+ public void Gdd03StartSeesAStaffedWorkshop()
+ {
+ var (c, s, workshop) = ArmsWorkshopTests.Built(civilians: 10, employed: 9, jobs: 9, jobsDefault: false);
+ s.Workshops.Add(workshop, new Workshop(workshop, true, SyntheticWorkshopTier.Ordinary)); // its worker is the one
+ var r = Step(c, s, new StartProject("housing", "town_a", 2, 0));
+ Assert.Empty(r.Rejected);
+ Assert.False(r.State.CityProjects.Values.Single(p => p.Kind == "housing").Builder);
+ }
+
+ // R-CITY-011 (second review): the start runs in queue order against AssignWorkers too: a job order queued first takes
+ // the free person; queued after the start, it is refused past the people less the builder.
+ [Fact]
+ public void Gdd03AutoBuilderFollowsQueueOrderWithAJobOrder()
+ {
+ var (c, s) = Game(civilians: 10, employed: 9, jobs: 10);
+ var jobFirst = Step(c, s, new AssignWorkers("town_a", "job", 10), Housing());
+ Assert.Empty(jobFirst.Rejected);
+ Assert.False(jobFirst.State.CityProjects.Values.Single().Builder);
+ var startFirst = Step(c, s, Housing(), new AssignWorkers("town_a", "job", 10));
+ Assert.True(startFirst.State.CityProjects.Values.Single().Builder);
+ Assert.Equal("Town A has 9 civilians and craftsmen", Assert.Single(startFirst.Rejected).Reason);
+ }
+
+ // R-CITY-011 with R-ARMS-005's job-default rule (second review): while the default is on, a build order may take its
+ // builder from the default's jobs (the employed fall, with the city's line) and is refused only past the people.
+ [Fact]
+ public void Gdd03BuildOrderMayTakeFromTheJobDefault()
+ {
+ var (c, s) = Game(civilians: 10, employed: 10, jobs: 10, jobsDefault: true);
+ var id = Add(s, "housing", 1, 1, 2, false);
+ var r = Simulation.Preview(c, s, new Command[] { Build(1) }); // the orders only, before the turn's housing step
+ Assert.Empty(r.Rejected);
+ Assert.True(r.State.CityProjects[id].Builder);
+ var x = r.State.Cities["town_a"];
+ Assert.Equal((9, true), (x.Employed, x.JobsDefault));
+ var line = Assert.Single(r.Why, w => w.Key == CauseKeys.WorkersAssigned);
+ Assert.Equal("Town A: 9 groups in work", line.Message);
+
+ var (c2, s2) = Game(civilians: 1, employed: 1, jobs: 1, jobsDefault: true);
+ Add(s2, "housing", 1, 1, 2, false);
+ Add(s2, "industry", 2, 0, 2, false);
+ Assert.Equal("Town A has 1 civilians and craftsmen", Assert.Single(Step(c2, s2, Build(2)).Rejected).Reason);
+ }
+
+ // R-ARMS-005 with R-CITY-011 (second review): staffing a workshop from the job default leaves the builders out of the jobs.
+ [Fact]
+ public void Gdd03WorkshopStaffingFromTheDefaultLeavesBuildersOut()
+ {
+ var (c, s, _) = ArmsWorkshopTests.Built(civilians: 10, employed: 9, jobs: 10, jobsDefault: true);
+ Add(s, "housing", 2, 0, 2, true);
+ var r = Simulation.Preview(c, s, new Command[] { ArmsWorkshopTests.Staff(1) });
+ Assert.Empty(r.Rejected);
+ Assert.Equal(8, r.State.Cities["town_a"].Employed); // 10 people less the worker and the builder
+ }
+
+ // R-PROJ-001, R-PROJ-003 (plan test 14, second review): under gdd-0.1 a start in a city with people without a job takes
+ // no builder, writes no new field or Why line, and changes no count; byte identity with main is the golden manifest's.
+ [Fact]
+ public void Gdd01StartWithFreePeopleTakesNoBuilder()
+ {
+ var (c, s) = Game(civilians: 10, employed: 8, jobs: 8, gdd03: false);
+ var one = Step(c, s, Housing());
+ var none = Step(c, s);
+ Assert.Empty(one.Rejected);
+ Assert.DoesNotContain(";builder", one.State.Describe());
+ Assert.DoesNotContain(one.Why, w => w.Key == CauseKeys.ProjectBuilder || w.Key == CauseKeys.ProjectWaiting);
+ var x = one.State.Cities["town_a"]; var was = none.State.Cities["town_a"];
+ Assert.Equal((Training.Idle(none.State, was), Cities.MaxWorkers(none.State, was), was.Employed),
+ (Training.Idle(one.State, x), Cities.MaxWorkers(one.State, x), x.Employed));
+ var id = one.State.CityProjects.Keys.Single();
+ Assert.NotNull(Step(c, one.State).State.CityProjects[id].BuiltOn);
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/NoAttentionTests.cs b/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
index 78ec6f149..8dd0718c3 100644
--- a/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
+++ b/sim/Statecraft.Sim.Tests/NoAttentionTests.cs
@@ -82,9 +82,11 @@ public class NoAttentionTests
var oldGood=Simulation.Preview(oldContent,oldState,new[]{oldValid});
var oldBad=Simulation.Preview(oldContent,oldState,new[]{oldInvalid});
Assert.Equal(oldBad.Rejected.Single().Reason,bad.Rejected.Single().Reason);
- Assert.Equal(WithoutLegacyAccounting(oldGood.State.Describe()),WithoutLegacyAccounting(good.State.Describe()));
+ // R-CITY-011 (#1700): under gdd-0.3 a start takes a free person as its builder, its one difference from gdd-0.1.
+ string Same(string modern) { if (kind != "start_project") return modern; Assert.Single(Regex.Matches(modern, ";builder")); return modern.Replace(";builder", ""); }
+ Assert.Equal(WithoutLegacyAccounting(oldGood.State.Describe()),WithoutLegacyAccounting(Same(good.State.Describe())));
Assert.Equal(WithoutLegacyAccounting(oldBad.State.Describe()),WithoutLegacyAccounting(bad.State.Describe()));
- Assert.Equal(WithoutLegacyAccounting(Simulation.Step(oldContent,oldState,new[]{oldValid}).State.Describe()),WithoutLegacyAccounting(step.State.Describe()));
+ Assert.Equal(WithoutLegacyAccounting(Simulation.Step(oldContent,oldState,new[]{oldValid}).State.Describe()),WithoutLegacyAccounting(Same(step.State.Describe())));
}
[Fact] public void InitialAndEndTurnRefillAreAbsentAndCanonicalStateIgnoresCompatibilityPool()
{
diff --git a/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.cs b/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.cs
index 063813786..5e5a59120 100644
--- a/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.cs
+++ b/sim/Statecraft.Sim.Tests/NoCityLossDefeatTests.cs
@@ -169,8 +169,9 @@ public class NoCityLossDefeatTests
public void Gdd03HeldCityPausesItsJobsAndProjectsUntilRetaken()
{
var c = Load(); var s = Simulation.NewGame(c, 1, Mode.Historical); Occupy(s);
- s.CityProjects.Add(10, new CityProject(10, "housing", "town_a", 1, 1, 3));
- s.CityProjects.Add(11, new CityProject(11, "housing", "town_b", 3, 2, 3));
+ // Each with a builder (R-CITY-011, #1700), so only the hold pauses it.
+ s.CityProjects.Add(10, new CityProject(10, "housing", "town_a", 1, 1, 3, builder: true));
+ s.CityProjects.Add(11, new CityProject(11, "housing", "town_b", 3, 2, 3, builder: true));
s.Objectives["already_awarded"] = s.Date;
var cities = s.Cities.Keys.ToArray();
var held = Simulation.Step(c, s, Array.Empty<Command>());
@@ -199,7 +200,8 @@ public class NoCityLossDefeatTests
{
var c = Load(ruleset); var s = Simulation.NewGame(c, 1, Mode.Historical);
if (halutz) s.Units.Add(1, new Unit(1, "halutz", 1, 0)); else Occupy(s);
- s.CityProjects.Add(10, new CityProject(10, "housing", "town_a", 1, 1, 3));
+ // With a builder under gdd-0.3 (R-CITY-011, #1700), so only a hold could pause it; gdd-0.1 has no builders.
+ s.CityProjects.Add(10, new CityProject(10, "housing", "town_a", 1, 1, 3, builder: ruleset == SaveGame.Gdd03Ruleset));
var result = Simulation.Step(c, s, Array.Empty<Command>());
Assert.True(Paid(result, "town_a"));
Assert.Equal(2, result.State.CityProjects[10].TurnsLeft);
diff --git a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
index 252f2f0d1..8a292bb53 100644
--- a/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
+++ b/sim/Statecraft.Sim.Tests/RemainingCauseKeysTests.cs
@@ -115,7 +115,7 @@ public class RemainingCauseKeysTests
sites++;
}
}
- Assert.Equal(114, sites); // 114 with #1703's gdd-0.3 housing surcharge and housing cohesion lines; 112 with the arms workshops' five (R-ARMS-005 with its job-default line, R-ARMS-006; #1701); 107 with R-MONEY-004's DollarsConverted (#813); 106 since #2212: EconomySystem.OtherMoney's line (105 since #2199: PayOrBorrow's Paid line)
+ Assert.Equal(118, sites); // 118 with #1700's builders (R-CITY-011: two ProjectBuilder lines, ProjectWaiting, the build order's job-default line); 114 with #1703's gdd-0.3 housing surcharge and housing cohesion lines; 112 with the arms workshops' five (R-ARMS-005 with its job-default line, R-ARMS-006; #1701); 107 with R-MONEY-004's DollarsConverted (#813); 106 since #2212: EconomySystem.OtherMoney's line (105 since #2199: PayOrBorrow's Paid line)
}
[Fact]
diff --git a/sim/Statecraft.Sim/Cause.cs b/sim/Statecraft.Sim/Cause.cs
index f5cac29cd..1d4be771b 100644
--- a/sim/Statecraft.Sim/Cause.cs
+++ b/sim/Statecraft.Sim/Cause.cs
@@ -134,6 +134,10 @@ namespace Statecraft.Sim
public const string ProjectCancelled = "project_cancelled";
/// <summary>Args: k.Id.</summary>
public const string ProjectCompleted = "project_completed";
+ /// <summary>R-CITY-011 (#1700): a builder started on a city project. Args: k.Id.</summary>
+ public const string ProjectBuilder = "project_builder";
+ /// <summary>R-PROJ-003 with R-CITY-011: a city project gained no progress this turn. Args: k.Id; Projects.NoBuilder or Projects.NoWorker.</summary>
+ public const string ProjectWaiting = "project_waiting";
/// <summary>Args: CauseKeys.Number(cost).</summary>
public const string ArmsBought = "arms_bought";
/// <summary>R-ARMS-005: a city's staffed arms workshops. Args: CauseKeys.Number(count).</summary>
@@ -265,7 +269,7 @@ namespace Statecraft.Sim
EventNew, EventChosen, EventDelegated, EventDelegatedPartial, EventAmount, EventStock, EventGrant, EventCity,
EventUnlock, EventPolicy, EventSetRung, EventRejoin, MilitaryUpkeep, HousingSurcharge, HousingCohesion,
ObjectiveCompleted, PrisonersReturned, SoldiersReturned,
- WorkersAssigned, WagesPaid, ImmigrantsHoused, HousingShortage, ImmigrantsWaiting, RecruitsVeteran, CorridorStarted, CorridorCancelled, CorridorCompleted, PioneersVeteran, MapBorrowed, MapBuilt, LandWorkStarted, SiteStarted, SiteCancelled, SiteCompleted, ProjectStarted, ProjectCancelled, ProjectCompleted, ArmsBought, WorkshopWorkers, WorkshopArms, WorkshopPaused, DollarsConverted, FoodHarvest, FoodShortage, FoodWithoutImports, PrisonerFood, PrisonerFoodShortage, CraftsmenReturned, CraftsmenReassigned, PioneerReturned, PioneersReassigned, TrainingStarted, TrainingArms, TrainingCancelled, TrainingArmsReturned, ReplacementsStopped, ReplacementsJoined, MilitaryTrained, PioneersTrained, CraftsmenTrained, Appointed, Reshuffle, AppointmentsEnded, ApprovalStability, CoalitionCollapsed, LegislatureConvened, GovernmentTookOffice, CoalitionChanged, EraEnded, AdvisoryPolicyRejected, PolicyRejected, PolicySet, AdvisoryBudgetRejected, BudgetRejected, PlaceCaptured, EnemyRegained, PlaceAnnexed, PlaceWithdrawn, PlaceDeported, DeportEffect, DeportCost, OccupationStarted, PendingBecameRaid, OccupationLostUnit, OccupationCountdown, DepopulationSupport,
+ WorkersAssigned, WagesPaid, ImmigrantsHoused, HousingShortage, ImmigrantsWaiting, RecruitsVeteran, CorridorStarted, CorridorCancelled, CorridorCompleted, PioneersVeteran, MapBorrowed, MapBuilt, LandWorkStarted, SiteStarted, SiteCancelled, SiteCompleted, ProjectStarted, ProjectCancelled, ProjectCompleted, ProjectBuilder, ProjectWaiting, ArmsBought, WorkshopWorkers, WorkshopArms, WorkshopPaused, DollarsConverted, FoodHarvest, FoodShortage, FoodWithoutImports, PrisonerFood, PrisonerFoodShortage, CraftsmenReturned, CraftsmenReassigned, PioneerReturned, PioneersReassigned, TrainingStarted, TrainingArms, TrainingCancelled, TrainingArmsReturned, ReplacementsStopped, ReplacementsJoined, MilitaryTrained, PioneersTrained, CraftsmenTrained, Appointed, Reshuffle, AppointmentsEnded, ApprovalStability, CoalitionCollapsed, LegislatureConvened, GovernmentTookOffice, CoalitionChanged, EraEnded, AdvisoryPolicyRejected, PolicyRejected, PolicySet, AdvisoryBudgetRejected, BudgetRejected, PlaceCaptured, EnemyRegained, PlaceAnnexed, PlaceWithdrawn, PlaceDeported, DeportEffect, DeportCost, OccupationStarted, PendingBecameRaid, OccupationLostUnit, OccupationCountdown, DepopulationSupport,
};
/// <summary>A number as an Arg: invariant and round-trip, so the UI rounds exactly the value Message rounded.</summary>
diff --git a/sim/Statecraft.Sim/Cities.cs b/sim/Statecraft.Sim/Cities.cs
index 7d72347da..8646b790a 100644
--- a/sim/Statecraft.Sim/Cities.cs
+++ b/sim/Statecraft.Sim/Cities.cs
@@ -14,23 +14,24 @@ namespace Statecraft.Sim
/// civilians and craftsmen (a craftsman fills an ordinary job slot, R-CRAFT-002). R-CITY-009's default fills to it.</summary>
public static int MaxWorkers(City city) => Math.Min(city.JobSlots, city.Civilians + city.Craftsmen);
- /// <summary>R-CITY-001 with R-ARMS-005: <see cref="MaxWorkers(City)"/> less the city's staffed arms workshops, whose
- /// workers hold no job. The same number where no workshop is staffed (always, outside gdd-0.3).</summary>
+ /// <summary>R-CITY-001 with R-ARMS-005 and R-CITY-011: <see cref="MaxWorkers(City)"/> less the city's staffed arms
+ /// workshops and builders, who hold no job. The same number where neither is (always, outside gdd-0.3).</summary>
public static int MaxWorkers(GameState s, City city) =>
- Math.Max(0, Math.Min(city.JobSlots, city.Civilians + city.Craftsmen - Workshops.Staffed(s, city.Id)));
+ Math.Max(0, Math.Min(city.JobSlots, city.Civilians + city.Craftsmen - Workshops.Staffed(s, city.Id) - Projects.Builders(s, city.Id)));
/// <summary>R-CITY-001 with R-TRAIN-001: <see cref="MaxWorkers(City)"/> once the city's Train, Reinforce and Reassign
/// orders in <paramref name="pending"/> (this turn's queue) have taken their civilians, so a count up to it keeps every one
/// of them accepted, whatever order they run in. Every queued reassignment counts in full, craftsmen too (#1548): if the
/// job order runs first, the civilians a reassignment needs are already in work. R-ARMS-005: the staffed arms workshops
- /// count as a pending "workshop" order leaves them, when it staffs more (#1722 slice E, as Training.Available does).</summary>
+ /// count as a pending "workshop" order leaves them, when it staffs more (#1722 slice E, as Training.Available does), and
+ /// the city's builders and the builder each queued gdd-0.3 StartProject there may take (R-CITY-011) are taken off too.</summary>
public static int MaxWorkers(GameState s, string city, IEnumerable<Command> pending)
{
var x = s.Cities[city];
var list = pending as IReadOnlyCollection<Command> ?? pending.ToList();
var staffed = Math.Max(Workshops.Staffed(s, city),
list.OfType<AssignWorkers>().Where(w => w.City == city && w.Role == Workshops.Role).Select(w => w.Count).DefaultIfEmpty(0).Max());
- return Math.Max(0, Math.Min(x.JobSlots, x.Civilians + x.Craftsmen - staffed - Training.Ordered(city, list)));
+ return Math.Max(0, Math.Min(x.JobSlots, x.Civilians + x.Craftsmen - staffed - Projects.Builders(s, city) - Projects.Starting(s, city, list) - Training.Ordered(city, list)));
}
/// <summary>R-CITY-007: a city's start people in units: the nearest unit (a half rounds up), and at least 1 for a city
@@ -76,13 +77,15 @@ namespace Statecraft.Sim
if (!s.Cities.TryGetValue(city, out var x)) return "There is no such city";
// R-ARMS-005: under gdd-0.3 the "workshop" role staffs the city's arms workshops.
if (role == Workshops.Role && c.Ruleset == SaveGame.Gdd03Ruleset) return Workshops.Staff(c, s, city, count, why);
+ // R-CITY-011 (#1700): under gdd-0.3 the "build" role puts builders on the city's projects being built.
+ if (role == Projects.BuildRole && c.Ruleset == SaveGame.Gdd03Ruleset) return Projects.AssignBuilders(c, s, city, count, why);
// Craftsmen fill ordinary job slots (Q-CRAFT-2, R-CRAFT-002), so "job" stays the only role.
if (role != "job") return "There is no such role";
if (count < 0) return "The number of workers cannot be negative";
if (count > MaxWorkers(s, x))
return count > x.JobSlots
? FormattableString.Invariant($"{PlayerText.Settlement(c, city)} has {x.JobSlots} jobs")
- : string.Format(System.Globalization.CultureInfo.InvariantCulture, Workshops.RefusedPeople, PlayerText.Settlement(c, city), x.Civilians + x.Craftsmen - Workshops.Staffed(s, city));
+ : string.Format(System.Globalization.CultureInfo.InvariantCulture, Workshops.RefusedPeople, PlayerText.Settlement(c, city), x.Civilians + x.Craftsmen - Workshops.Staffed(s, city) - Projects.Builders(s, city));
s.Cities[city] = x.WithCounts(x.Civilians, count, x.Refugees).WithJobsDefault(false);
why.Add(new Cause("city", city, count - x.Employed, FormattableString.Invariant($"{PlayerText.Settlement(c, city)}: {count} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(count) }));
return null;
diff --git a/sim/Statecraft.Sim/GddState.cs b/sim/Statecraft.Sim/GddState.cs
index 1dd916abb..3a61850e0 100644
--- a/sim/Statecraft.Sim/GddState.cs
+++ b/sim/Statecraft.Sim/GddState.cs
@@ -296,8 +296,8 @@ namespace Statecraft.Sim
/// <summary>A city project (projects.yaml; R-PROJ-001 to R-PROJ-003): <see cref="Kind"/> built for <see cref="City"/> on hex
/// (<see cref="Q"/>, <see cref="R"/>) with <see cref="TurnsLeft"/> more turns to go, or, once <see cref="BuiltOn"/> is set,
/// built on that date (its capacity, condition and slots added then, once). A built project keeps its record, so its hex
- /// stays taken (Q-PROJ-2) and the map can draw it (Phase 3 PR 8). No workers (Q-PROJ-3). Immutable; a change replaces the
- /// record.</summary>
+ /// stays taken (Q-PROJ-2) and the map can draw it (Phase 3 PR 8). No workers (Q-PROJ-3); under gdd-0.3 at most one
+ /// builder (<see cref="Builder"/>, R-CITY-011). Immutable; a change replaces the record.</summary>
public sealed class CityProject
{
public int Id { get; }
@@ -311,27 +311,35 @@ namespace Statecraft.Sim
/// <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; }
+ /// <summary>R-CITY-011 (#1700, gdd-0.3 only): whether one of the city's people without a job builds it. Always false
+ /// once built (the builder is freed) and under every other ruleset.</summary>
+ public bool Builder { get; }
- public CityProject(int id, string kind, string city, int q, int r, int turnsLeft, DateTime? builtOn = null, double progress = 0)
+ public CityProject(int id, string kind, string city, int q, int r, int turnsLeft, DateTime? builtOn = null, double progress = 0, bool builder = false)
{
- Id = id; Kind = kind; City = city; Q = q; R = r; TurnsLeft = turnsLeft; BuiltOn = builtOn; Progress = progress;
+ Id = id; Kind = kind; City = city; Q = q; R = r; TurnsLeft = turnsLeft; BuiltOn = builtOn; Progress = progress; Builder = builder;
}
+ /// <summary>The same project with or without its builder (R-CITY-011).</summary>
+ public CityProject WithBuilder(bool builder) => new CityProject(Id, Kind, City, Q, R, TurnsLeft, BuiltOn, Progress, builder);
+
/// <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, BuiltOn, Progress);
+ public CityProject WithTurnsLeft(int turnsLeft) => new CityProject(Id, Kind, City, Q, R, turnsLeft, BuiltOn, Progress, Builder);
/// <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);
+ public CityProject WithProgress(int turnsLeft, double progress) => new CityProject(Id, Kind, City, Q, R, turnsLeft, BuiltOn, progress, Builder);
- /// <summary>The same project, built on <paramref name="on"/>.</summary>
+ /// <summary>The same project, built on <paramref name="on"/>; its builder, if any, is freed (R-CITY-011).</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, ",PROGRESS"
- /// appended as IEEE bits when it is not 0 (R-MIN-002), "/done,yyyy-MM-dd" once built.</summary>
+ /// appended as IEEE bits when it is not 0 (R-MIN-002) and ";builder" when it has one (R-CITY-011, so no record without
+ /// a builder, and no gdd-0.1 hash, changes), "/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) + (Progress == 0 ? "" : "," + BitConverter.DoubleToInt64Bits(Progress).ToString("X16", CultureInfo.InvariantCulture)));
+ : TurnsLeft.ToString(CultureInfo.InvariantCulture) + (Progress == 0 ? "" : "," + BitConverter.DoubleToInt64Bits(Progress).ToString("X16", CultureInfo.InvariantCulture))
+ + (Builder ? ";builder" : ""));
}
/// <summary>R-ARMS-005, R-ARMS-006 (gdd-0.3 only): the cycle of the built arms workshop that is city project
diff --git a/sim/Statecraft.Sim/Projects.cs b/sim/Statecraft.Sim/Projects.cs
index 4c755fd53..d8cd9d45f 100644
--- a/sim/Statecraft.Sim/Projects.cs
+++ b/sim/Statecraft.Sim/Projects.cs
@@ -241,6 +241,33 @@ namespace Statecraft.Sim
Corridors.Advance(c, s, next, why); // R-COR-002: after the sites (Phase 4 PR 2)
}
+ /// <summary>R-CITY-011 (#1700): the AssignWorkers role that puts builders on a city's projects being built (gdd-0.3 only).</summary>
+ public const string BuildRole = "build";
+
+ /// <summary>R-PROJ-003 with R-CITY-011: why a city project gained no progress this turn (CauseKeys.ProjectWaiting's
+ /// second argument): it has no builder, or no person of its city without a job was left for its builder.</summary>
+ public const string NoBuilder = "no_builder", NoWorker = "no_worker";
+
+ /// <summary>R-CITY-011: the build order's refusal past the city's projects being built, formats with the settlement's
+ /// name ({0}) and a count ({1}, invariant).</summary>
+ public const string RefusedBeingBuiltOne = "{0} has 1 city project being built", RefusedBeingBuilt = "{0} has {1} city projects being built";
+
+ /// <summary>R-CITY-011: the city's builders, each one of its people who hold no job. 0 outside gdd-0.3, where no project
+ /// has one.</summary>
+ public static int Builders(GameState s, string city) => s.CityProjects.Values.Count(p => p.Builder && p.City == city);
+
+ /// <summary>R-CITY-011: the builders this turn's queued gdd-0.3 StartProject orders for <paramref name="city"/> may take,
+ /// one each at most (#1700 review: the panel limits count them, so a count up to a limit is accepted whichever order
+ /// runs first). 0 under every other ruleset.</summary>
+ internal static int Starting(GameState s, string city, IEnumerable<Command> pending) =>
+ s.Ruleset == SaveGame.Gdd03Ruleset ? pending.OfType<StartProject>().Count(p => p.City == city) : 0;
+
+ /// <summary>R-CITY-011: the city's free people: its civilians and craftsmen who hold no job and are not a staffed arms
+ /// workshop's worker (R-ARMS-005) or a builder.</summary>
+ static int Free(GameState s, City x) => x.Civilians + x.Craftsmen - x.Employed - Workshops.Staffed(s, x.Id) - Builders(s, x.Id);
+
+ static string Refused(string format, params object[] values) => string.Format(System.Globalization.CultureInfo.InvariantCulture, format, values);
+
/// <summary>The city project at hex (q, r), being built or built, or null (Q-PROJ-2: one project or placement a hex).</summary>
public static CityProject? CityProjectAt(GameState s, int q, int r) => s.CityProjects.Values.FirstOrDefault(p => p.Q == q && p.R == r);
@@ -310,7 +337,9 @@ namespace Statecraft.Sim
/// <summary>R-PROJ-001: starts city project <paramref name="kind"/> for <paramref name="city"/> on hex (q, r), or returns
/// the reason (<see cref="CheckCity"/>; state untouched). The Treasury pays the kind's cost now and borrows what it lacks
/// (Q-PROJ-1, Q-MONEY-3); the project takes the next id and the kind's turns, the turn of the order the first (D-A3). It
- /// needs no workers (Q-PROJ-3). Step has already refused it in the legacy loop.</summary>
+ /// needs no workers (Q-PROJ-3); under gdd-0.3 it takes one of the city's free people as its builder when it has one, as
+ /// the order runs (R-CITY-011, owner, 3 November 2026: "Yes, if someone is free"), and never anyone in a job. Step has
+ /// already refused it in the legacy loop.</summary>
public static string? StartCity(Content c, GameState s, string kind, string city, int q, int r, List<Cause> why)
{
var reason = CheckCity(c, s, kind, city, q, r);
@@ -321,13 +350,16 @@ namespace Statecraft.Sim
var name = PlayerText.Settlement(c, city);
EconomySystem.PayOrBorrow(c, s, k.Cost, "to build " + k.Name, why, CauseKeys.Purpose.Project, k.Id);
var id = s.NextId++;
- s.CityProjects.Add(id, new CityProject(id, kind, city, q, r, k.Turns));
+ var builder = c.Ruleset == SaveGame.Gdd03Ruleset && Free(s, s.Cities[city]) >= 1;
+ s.CityProjects.Add(id, new CityProject(id, kind, city, q, r, k.Turns, builder: builder));
why.Add(new Cause("city", city, 1, $"{name}: {k.Name} began, cost {PlayerText.Money(c, "treasury", k.Cost)}", key: CauseKeys.ProjectStarted, args: new[] { kind, CauseKeys.Number(k.Cost) }));
+ if (builder) why.Add(new Cause("city", city, 1, $"{name}: a builder started on {k.Name}", key: CauseKeys.ProjectBuilder, args: new[] { kind }));
return null;
}
/// <summary>R-PROJ-002 (D-A3): city project <paramref name="project"/> leaves the state; the Money spent is not returned,
- /// and with no workers (Q-PROJ-3) there are no people to return. Refused, state untouched, for a project that does not
+ /// and with no workers (Q-PROJ-3) there are no people to return; under gdd-0.3 its builder, if any, is free again at once
+ /// (R-CITY-011). Refused, state untouched, for a project that does not
/// exist or is built. Step has already refused it in the legacy loop.</summary>
public static string? CancelCity(Content c, GameState s, int project, List<Cause> why)
{
@@ -339,16 +371,74 @@ namespace Statecraft.Sim
return null;
}
+ /// <summary>R-CITY-011 (#1700; owner, 3 November 2026: "Builders in the MVP (Recommended)", "One builder, today's times
+ /// (Recommended)"): AssignWorkers(city, "build", count), gdd-0.3 only, sets how many of the city's projects being built
+ /// have a builder. A rise puts builders on the projects that have none, in ascending id; a fall takes them off the
+ /// projects that have one, in descending id. A new builder is one of the city's free people; while its job default is
+ /// on (R-CITY-009) the order may take one from the default's jobs, as R-ARMS-005's workshop order does. Refused, state
+ /// untouched, for a negative count, more than the city's projects being built, or more new builders than its free
+ /// people. Cities.Assign has already refused an unknown city.</summary>
+ internal static string? AssignBuilders(Content c, GameState s, string city, int count, List<Cause> why)
+ {
+ if (count < 0) return "The number of workers cannot be negative";
+ var x = s.Cities[city];
+ var name = PlayerText.Settlement(c, city);
+ var building = s.CityProjects.Values.Where(p => p.City == city && p.BuiltOn == null).OrderBy(p => p.Id).ToList();
+ if (count > building.Count) return building.Count == 1 ? Refused(RefusedBeingBuiltOne, name) : Refused(RefusedBeingBuilt, name, building.Count);
+ var builders = Builders(s, city);
+ var staffed = Workshops.Staffed(s, city);
+ // R-CITY-009 with R-ARMS-005: while the job default is on, a new builder may come from the default's jobs (the
+ // default then fills one job fewer, R-CITY-001); a number the player set is not lowered.
+ var free = x.Civilians + x.Craftsmen - (x.JobsDefault ? 0 : x.Employed) - staffed - builders;
+ if (count - builders > free)
+ return Refused(x.JobsDefault ? Workshops.RefusedPeople : Workshops.RefusedPeopleNoJob, name, Math.Max(0, free));
+ var employed = Math.Min(x.Employed, x.Civilians + x.Craftsmen - staffed - count);
+ if (employed != x.Employed)
+ {
+ s.Cities[city] = x.WithCounts(x.Civilians, employed, x.Refugees);
+ why.Add(new Cause("city", city, employed - x.Employed, FormattableString.Invariant($"{name}: {employed} groups in work"), key: CauseKeys.WorkersAssigned, args: new[] { CauseKeys.Number(employed) }));
+ }
+ if (count > builders)
+ foreach (var p in building.Where(p => !p.Builder).Take(count - builders))
+ {
+ s.CityProjects[p.Id] = p.WithBuilder(true);
+ var k = c.ProjectKinds.First(y => y.Id == p.Kind);
+ why.Add(new Cause("city", city, 1, $"{name}: a builder started on {k.Name}", key: CauseKeys.ProjectBuilder, args: new[] { k.Id }));
+ }
+ else
+ foreach (var p in building.Where(p => p.Builder).Reverse().Take(builders - count)) s.CityProjects[p.Id] = p.WithBuilder(false);
+ return null;
+ }
+
/// <summary>R-PROJ-003, step 5 of the turn (D-A6), after the pioneer work: in ascending id, each city project being built
/// has one turn less to go. One that reaches 0 is built on <paramref name="next"/>, the turn's end date, and adds its
/// kind's housing capacity, condition (kept from 0 to 1) and job slots to its city, once: a built project is never
- /// advanced again. R-CITY-010: a project in a city the enemy holds keeps its record as it is.</summary>
+ /// advanced again. R-CITY-010: a project in a city the enemy holds keeps its record as it is. R-CITY-011 (gdd-0.3 only):
+ /// a project gains the turn's progress only when it has a builder and its city still has that person without a job
+ /// (each project with a builder takes one, in ascending id); otherwise it waits with its record as it is, and the turn
+ /// report says why. Money is never an input to progress.</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
var held = Cities.Held(c, s);
- foreach (var p in s.CityProjects.Values.Where(x => x.BuiltOn == null && !held.Contains(x.City)).ToList())
+ var builders = c.Ruleset == SaveGame.Gdd03Ruleset;
+ var working = new Dictionary<string, int>(StringComparer.Ordinal);
+ foreach (var p in s.CityProjects.Values.Where(x => x.BuiltOn == null && !held.Contains(x.City)).OrderBy(x => x.Id).ToList())
{
+ if (builders)
+ {
+ var x = s.Cities[p.City];
+ working.TryGetValue(p.City, out var taken);
+ var waits = !p.Builder ? NoBuilder : taken >= x.Civilians + x.Craftsmen - x.Employed ? NoWorker : null;
+ if (waits != null)
+ {
+ var kind = c.ProjectKinds.First(y => y.Id == p.Kind);
+ var because = waits == NoBuilder ? "no builder" : "no person without a job is left for its builder";
+ why.Add(new Cause("city", p.City, 0, $"{PlayerText.Settlement(c, p.City)}: {kind.Name} waits: {because}", key: CauseKeys.ProjectWaiting, args: new[] { kind.Id, waits }));
+ continue;
+ }
+ working[p.City] = taken + 1;
+ }
// 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));
@@ -357,9 +447,9 @@ namespace Statecraft.Sim
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];
- var condition = x.Condition is double now ? Math.Min(1.0, Math.Max(0.0, now + k.Condition)) : (double?)null;
- s.Cities[p.City] = new City(x.Id, x.HousingCapacity + k.Capacity, x.JobSlots + k.JobSlots, x.Civilians, x.Employed, x.Refugees, x.Recruits, condition, x.Craftsmen, x.JobsDefault, x.Qualified);
+ var city = s.Cities[p.City];
+ var condition = city.Condition is double now ? Math.Min(1.0, Math.Max(0.0, now + k.Condition)) : (double?)null;
+ s.Cities[p.City] = new City(city.Id, city.HousingCapacity + k.Capacity, city.JobSlots + k.JobSlots, city.Civilians, city.Employed, city.Refugees, city.Recruits, condition, city.Craftsmen, city.JobsDefault, city.Qualified);
why.Add(new Cause("city", p.City, 1, $"{PlayerText.Settlement(c, p.City)}: {k.Name} was finished", key: CauseKeys.ProjectCompleted, args: new[] { k.Id }));
}
}
diff --git a/sim/Statecraft.Sim/Training.cs b/sim/Statecraft.Sim/Training.cs
index 952a9c376..4c1bb99ef 100644
--- a/sim/Statecraft.Sim/Training.cs
+++ b/sim/Statecraft.Sim/Training.cs
@@ -74,11 +74,11 @@ namespace Statecraft.Sim
/// city's jobs first (R-CRAFT-002), so only the employed beyond its craftsmen are civilians in work.</summary>
public static int Idle(City city) => city.Civilians - Math.Max(0, city.Employed - city.Craftsmen);
- /// <summary>R-TRAIN-001 with R-ARMS-005: <see cref="Idle(City)"/>, less the city's staffed arms workshops' workers, who
- /// hold no job but are not idle (each one is a craftsman without a job first, then a civilian), as
- /// <see cref="Cities.MaxWorkers(GameState, City)"/> takes them off the jobs. The same number where no workshop is
- /// staffed (always, outside gdd-0.3).</summary>
- public static int Idle(GameState s, City city) => Idle(city, city.Employed, Workshops.Staffed(s, city.Id));
+ /// <summary>R-TRAIN-001 with R-ARMS-005 and R-CITY-011: <see cref="Idle(City)"/>, less the city's staffed arms
+ /// workshops' workers and its builders, who hold no job but are not idle (each one is a craftsman without a job first,
+ /// then a civilian), as <see cref="Cities.MaxWorkers(GameState, City)"/> takes them off the jobs. The same number where
+ /// no workshop is staffed and no project has a builder (always, outside gdd-0.3).</summary>
+ public static int Idle(GameState s, City city) => Idle(city, city.Employed, Workshops.Staffed(s, city.Id) + Projects.Builders(s, city.Id));
static int Idle(City city, int employed, int staffed) =>
Math.Max(0, Math.Min(city.Civilians - Math.Max(0, employed - city.Craftsmen), city.Civilians + city.Craftsmen - employed - staffed));
@@ -93,7 +93,8 @@ namespace Statecraft.Sim
/// <summary>R-TRAIN-001 with R-CITY-001: the groups still free to train in <paramref name="city"/> once the orders in
/// <paramref name="pending"/> (this turn's queue) have run: <see cref="Idle"/>, less every track's Train order there
/// and every queued reassignment (R-QUAL-004, R-QUAL-005), less a pending "job" AssignWorkers' rise in jobs, and less
- /// a pending "workshop" AssignWorkers' rise in staffed arms workshops (R-ARMS-005). A count up to
+ /// a pending "workshop" AssignWorkers' rise in staffed arms workshops (R-ARMS-005), and less the city's builders and
+ /// the builder each queued gdd-0.3 StartProject there may take (R-CITY-011). A count up to
/// it keeps every one of those orders accepted, whatever order they run in. A pending CancelTraining is not counted, since it may run after the Train.</summary>
public static int Available(GameState s, string city, IEnumerable<Command> pending)
{
@@ -101,7 +102,7 @@ namespace Statecraft.Sim
var list = pending as IReadOnlyCollection<Command> ?? pending.ToList();
int Pending(string role, int now) =>
Math.Max(now, list.OfType<AssignWorkers>().Where(w => w.City == city && w.Role == role).Select(w => w.Count).DefaultIfEmpty(0).Max());
- return Math.Max(0, Idle(x, Pending("job", x.Employed), Pending(Workshops.Role, Workshops.Staffed(s, city))) - Ordered(city, list));
+ return Math.Max(0, Idle(x, Pending("job", x.Employed), Pending(Workshops.Role, Workshops.Staffed(s, city)) + Projects.Builders(s, city) + Projects.Starting(s, city, list)) - Ordered(city, list));
}
/// <summary>R-TRAIN-001: <paramref name="count"/> of the city's civilians without work start training as
diff --git a/sim/Statecraft.Sim/Workshops.cs b/sim/Statecraft.Sim/Workshops.cs
index e460338b4..b23a621ae 100644
--- a/sim/Statecraft.Sim/Workshops.cs
+++ b/sim/Statecraft.Sim/Workshops.cs
@@ -60,7 +60,8 @@ namespace Statecraft.Sim
/// refused, or null; nothing changes. With an empty <paramref name="pending"/> it is the order's own check. With this
/// turn's queue (#1722 slice E, the hex panel) it also counts the city's pending "job" order (whose jobs then hold
/// no workshop worker, and which turns R-CITY-009's default off) and its Train and reassignment orders
- /// (Training.Ordered), so a count it accepts is still accepted whichever of them runs first.</summary>
+ /// (Training.Ordered) and the builder each queued gdd-0.3 StartProject there may take (R-CITY-011), so a count it
+ /// accepts is still accepted whichever of them runs first.</summary>
public static string? Check(Content c, GameState s, string city, int count, IEnumerable<Command> pending)
{
if (!s.Cities.TryGetValue(city, out var x)) return "There is no such city";
@@ -74,8 +75,9 @@ namespace Statecraft.Sim
var byDefault = x.JobsDefault && job == null;
var staffed = Staffed(s, city);
// R-CITY-009: while the city's job default is on, a newly staffed workshop may take its worker from the default's
- // jobs (the default then fills one job fewer, R-CITY-001); a number the player set is not lowered.
- var free = x.Civilians + x.Craftsmen - Math.Max(x.JobsDefault ? 0 : x.Employed, job ?? 0) - staffed - Training.Ordered(city, list);
+ // jobs (the default then fills one job fewer, R-CITY-001); a number the player set is not lowered. R-CITY-011: a
+ // builder is not free, nor the one a queued start there may take.
+ var free = x.Civilians + x.Craftsmen - Math.Max(x.JobsDefault ? 0 : x.Employed, job ?? 0) - staffed - Projects.Builders(s, city) - Projects.Starting(s, city, list) - Training.Ordered(city, list);
if (count - staffed > free) return Refused(byDefault ? RefusedPeople : RefusedPeopleNoJob, name, Math.Max(0, free));
return null;
}
@@ -106,7 +108,7 @@ namespace Statecraft.Sim
var built = BuiltIn(c, s, city);
var x = s.Cities[city];
var staffed = Staffed(s, city);
- var employed = Math.Min(x.Employed, x.Civilians + x.Craftsmen - count);
+ var employed = Math.Min(x.Employed, x.Civilians + x.Craftsmen - count - Projects.Builders(s, city)); // R-CITY-011: nor a builder's
if (employed != x.Employed)
{
s.Cities[city] = x.WithCounts(x.Civilians, employed, x.Refugees);
@@ -125,7 +127,7 @@ namespace Statecraft.Sim
/// <summary>R-ARMS-006, step 6 of the turn after the cities' wages, gdd-0.3 only. In ascending project id, a staffed
/// workshop whose city the enemy does not hold (R-CITY-010) works this month when one of its city's people without a
- /// job is left for it (each workshop of the city takes one). With no cycle under way it first pays for one at its
+ /// job is left for it (each workshop of the city takes one, after the city's builders, R-CITY-011). With no cycle under way it first pays for one at its
/// worker's tier (gdd03-balance.yaml workshop.cost: 27M-11, "At the monthly production step."), borrowing a short
/// Treasury's rest (R-MONEY-003; 27M-12, "paid like any GDD cost"), unless that would take the debt past
/// mvp.debt_ceiling (#1701 OQ4, owner 2 November 2026: "Refuse past the ceiling (Recommended)"): then the workshop
@@ -148,7 +150,8 @@ namespace Statecraft.Sim
if (held.Contains(city)) continue;
var name = PlayerText.Settlement(c, city);
var x = s.Cities[city];
- working.TryGetValue(city, out var taken);
+ // R-CITY-011: step 5's builders took their people first.
+ if (!working.TryGetValue(city, out var taken)) taken = Projects.Builders(s, city);
if (taken >= x.Civilians + x.Craftsmen - x.Employed)
{
why.Add(new Cause("city", city, 0, $"{name}: an arms workshop has no worker without a job this month", key: CauseKeys.WorkshopPaused, args: new[] { NoWorker }));
diff --git a/unity/Assets/Scripts/UI/CauseText.cs b/unity/Assets/Scripts/UI/CauseText.cs
index 160b58249..1e9d8810c 100644
--- a/unity/Assets/Scripts/UI/CauseText.cs
+++ b/unity/Assets/Scripts/UI/CauseText.cs
@@ -89,7 +89,7 @@ namespace Statecraft.Game.UI
// #1682: these branches use captured ids, values and resident flags, never the live GameState.
static readonly HashSet<string> RemainingKeys = new HashSet<string>
{
- CauseKeys.WorkersAssigned, CauseKeys.WagesPaid, CauseKeys.ImmigrantsHoused, CauseKeys.HousingShortage, CauseKeys.ImmigrantsWaiting, CauseKeys.RecruitsVeteran, CauseKeys.CorridorStarted, CauseKeys.CorridorCancelled, CauseKeys.CorridorCompleted, CauseKeys.PioneersVeteran, CauseKeys.MapBorrowed, CauseKeys.MapBuilt, CauseKeys.LandWorkStarted, CauseKeys.SiteStarted, CauseKeys.SiteCancelled, CauseKeys.SiteCompleted, CauseKeys.ProjectStarted, CauseKeys.ProjectCancelled, CauseKeys.ProjectCompleted, CauseKeys.ArmsBought, CauseKeys.WorkshopWorkers, CauseKeys.WorkshopArms, CauseKeys.WorkshopPaused, CauseKeys.DollarsConverted, CauseKeys.FoodHarvest, CauseKeys.FoodShortage, CauseKeys.FoodWithoutImports, CauseKeys.PrisonerFood, CauseKeys.PrisonerFoodShortage, CauseKeys.CraftsmenReturned, CauseKeys.CraftsmenReassigned, CauseKeys.PioneerReturned, CauseKeys.PioneersReassigned, CauseKeys.TrainingStarted, CauseKeys.TrainingArms, CauseKeys.TrainingCancelled, CauseKeys.TrainingArmsReturned, CauseKeys.ReplacementsStopped, CauseKeys.ReplacementsJoined, CauseKeys.MilitaryTrained, CauseKeys.PioneersTrained, CauseKeys.CraftsmenTrained, CauseKeys.Appointed, CauseKeys.Reshuffle, CauseKeys.AppointmentsEnded, CauseKeys.ApprovalStability, CauseKeys.CoalitionCollapsed, CauseKeys.LegislatureConvened, CauseKeys.GovernmentTookOffice, CauseKeys.CoalitionChanged, CauseKeys.EraEnded, CauseKeys.AdvisoryPolicyRejected, CauseKeys.PolicyRejected, CauseKeys.PolicySet, CauseKeys.AdvisoryBudgetRejected, CauseKeys.BudgetRejected, CauseKeys.PlaceCaptured, CauseKeys.EnemyRegained, CauseKeys.PlaceAnnexed, CauseKeys.PlaceWithdrawn, CauseKeys.PlaceDeported, CauseKeys.DeportEffect, CauseKeys.DeportCost, CauseKeys.OccupationStarted, CauseKeys.PendingBecameRaid, CauseKeys.OccupationLostUnit, CauseKeys.OccupationCountdown, CauseKeys.DepopulationSupport
+ CauseKeys.WorkersAssigned, CauseKeys.WagesPaid, CauseKeys.ImmigrantsHoused, CauseKeys.HousingShortage, CauseKeys.ImmigrantsWaiting, CauseKeys.RecruitsVeteran, CauseKeys.CorridorStarted, CauseKeys.CorridorCancelled, CauseKeys.CorridorCompleted, CauseKeys.PioneersVeteran, CauseKeys.MapBorrowed, CauseKeys.MapBuilt, CauseKeys.LandWorkStarted, CauseKeys.SiteStarted, CauseKeys.SiteCancelled, CauseKeys.SiteCompleted, CauseKeys.ProjectStarted, CauseKeys.ProjectCancelled, CauseKeys.ProjectCompleted, CauseKeys.ProjectBuilder, CauseKeys.ProjectWaiting, CauseKeys.ArmsBought, CauseKeys.WorkshopWorkers, CauseKeys.WorkshopArms, CauseKeys.WorkshopPaused, CauseKeys.DollarsConverted, CauseKeys.FoodHarvest, CauseKeys.FoodShortage, CauseKeys.FoodWithoutImports, CauseKeys.PrisonerFood, CauseKeys.PrisonerFoodShortage, CauseKeys.CraftsmenReturned, CauseKeys.CraftsmenReassigned, CauseKeys.PioneerReturned, CauseKeys.PioneersReassigned, CauseKeys.TrainingStarted, CauseKeys.TrainingArms, CauseKeys.TrainingCancelled, CauseKeys.TrainingArmsReturned, CauseKeys.ReplacementsStopped, CauseKeys.ReplacementsJoined, CauseKeys.MilitaryTrained, CauseKeys.PioneersTrained, CauseKeys.CraftsmenTrained, CauseKeys.Appointed, CauseKeys.Reshuffle, CauseKeys.AppointmentsEnded, CauseKeys.ApprovalStability, CauseKeys.CoalitionCollapsed, CauseKeys.LegislatureConvened, CauseKeys.GovernmentTookOffice, CauseKeys.CoalitionChanged, CauseKeys.EraEnded, CauseKeys.AdvisoryPolicyRejected, CauseKeys.PolicyRejected, CauseKeys.PolicySet, CauseKeys.AdvisoryBudgetRejected, CauseKeys.BudgetRejected, CauseKeys.PlaceCaptured, CauseKeys.EnemyRegained, CauseKeys.PlaceAnnexed, CauseKeys.PlaceWithdrawn, CauseKeys.PlaceDeported, CauseKeys.DeportEffect, CauseKeys.DeportCost, CauseKeys.OccupationStarted, CauseKeys.PendingBecameRaid, CauseKeys.OccupationLostUnit, CauseKeys.OccupationCountdown, CauseKeys.DepopulationSupport
};
static string Remaining(Cause cause, Content c, UiText text, IReadOnlyDictionary<string, string>? namesHe)
@@ -152,6 +152,10 @@ namespace Statecraft.Game.UI
return text.Format(key, Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))));
case CauseKeys.ProjectCompleted:
return text.Format(key, Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))));
+ case CauseKeys.ProjectBuilder: // R-CITY-011 (#1700)
+ return text.Format(key, Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))));
+ case CauseKeys.ProjectWaiting: // R-PROJ-003: why.cause.project_waiting.<Projects.NoBuilder or .NoWorker>
+ return text.Format(key + "." + A(1), Settlement(cause.Target), ContentNames.Of(text, c.ProjectKinds.First(x => x.Id == A(0))));
case CauseKeys.ArmsBought:
return text.Format(key, cause.Delta, Money(c, "treasury", A(0)));
case CauseKeys.WorkshopWorkers: // R-ARMS-005 (#1701)
diff --git a/unity/Assets/Tests/EditMode/CauseTextTests.cs b/unity/Assets/Tests/EditMode/CauseTextTests.cs
index 6a9646614..24e1594b4 100644
--- a/unity/Assets/Tests/EditMode/CauseTextTests.cs
+++ b/unity/Assets/Tests/EditMode/CauseTextTests.cs
@@ -437,6 +437,8 @@ public class CauseTextTests
new Cause("draft", "town", 1, "Town: Housing began, cost IL\u00A01.3m", key: CauseKeys.ProjectStarted, args: new[] { "housing", "1.25" }),
new Cause("draft", "town", -1, "Town: Housing was cancelled; the Money spent is not returned", key: CauseKeys.ProjectCancelled, args: new[] { "housing" }),
new Cause("draft", "town", 1, "Town: Housing was finished", key: CauseKeys.ProjectCompleted, args: new[] { "housing" }),
+ new Cause("draft", "town", 1, "Town: a builder started on Housing", key: CauseKeys.ProjectBuilder, args: new[] { "housing" }), // #1700
+ new Cause("draft", "town", 0, "Town: Housing waits: no builder", key: CauseKeys.ProjectWaiting, args: new[] { "housing", Projects.NoBuilder }),
new Cause("draft", "arms", 2000000000, "Bought 2000000000 Arms, cost IL\u00A01.3m", key: CauseKeys.ArmsBought, args: new[] { "1.25" }),
new Cause("draft", "town", 2, "Town: arms workshops staffed: 2", key: CauseKeys.WorkshopWorkers, args: new[] { "2" }),
new Cause("draft", "town", 1, "Town: an arms workshop made 1 Arms", key: CauseKeys.WorkshopArms),
@@ -551,6 +553,7 @@ public class CauseTextTests
new Cause("draft", "site", 1, "Site: a group of halutzim began draining the swamp, cost IL\u00A01.3m", key: CauseKeys.LandWorkStarted, args: new[] { "drain", "1.25" }),
new Cause("draft", "site", 1, "Site: a group of halutzim began building a training camp, cost IL\u00A01.3m", key: CauseKeys.SiteStarted, args: new[] { "camp", "1.25" }),
new Cause("draft", "town", 0, "Town: an arms workshop's next cycle waits: paying for it would take the debt past its ceiling", key: CauseKeys.WorkshopPaused, args: new[] { Workshops.DebtCeiling }), // #1701 OQ4
+ new Cause("draft", "town", 0, "Town: Housing waits: no person without a job is left for its builder", key: CauseKeys.ProjectWaiting, args: new[] { "housing", Projects.NoWorker }), // #1700
};
// A renderer receives no live state: both resident variants must survive the settlement record's removal.
foreach (var row in rows)
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 88b5eb112..487f4cd91 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -1088,6 +1088,10 @@ why.cause.site_completed: "{0} {1}"
why.cause.project_started: "{0}: {1} began, cost {2}"
why.cause.project_cancelled: "{0}: {1} was cancelled; the Money spent is not returned"
why.cause.project_completed: "{0}: {1} was finished"
+# The gdd-0.3 builders (#1700; R-CITY-011, R-PROJ-003).
+why.cause.project_builder: "{0}: a builder started on {1}"
+why.cause.project_waiting.no_builder: "{0}: {1} waits: no builder"
+why.cause.project_waiting.no_worker: "{0}: {1} waits: no person without a job is left for its builder"
why.cause.arms_bought: "Bought {0} Arms, cost {1}"
# The gdd-0.3 arms workshops (#1701; R-ARMS-005, R-ARMS-006).
why.cause.workshop_workers: "{0}: arms workshops staffed: {1}"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index d5d4653fe..06c979d2c 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -1228,6 +1228,13 @@ why.cause.site_completed: "{0}: מצב האתר: {1}"
why.cause.project_started: "{0}: תחילת {1}, עלות {2}"
why.cause.project_cancelled: "{0}: ביטול {1}; הכסף שהוצא לא יוחזר"
why.cause.project_completed: "{0}: סיום {1}"
+# The gdd-0.3 builders (#1700; R-CITY-011, R-PROJ-003). Agent-drafted Hebrew: native-review-pending (#564).
+# native-review-pending
+why.cause.project_builder: "{0}: בונה החל לעבוד על {1}"
+# native-review-pending
+why.cause.project_waiting.no_builder: "{0}: העבודה על {1} ממתינה: אין בונה"
+# native-review-pending
+why.cause.project_waiting.no_worker: "{0}: העבודה על {1} ממתינה: לא נותר אדם ללא משרה שיבנה"
why.cause.arms_bought: "נשק שנרכש: {0}, עלות {1}"
# The gdd-0.3 arms workshops (#1701; R-ARMS-005, R-ARMS-006). Agent-drafted Hebrew; native review pending (#564).
why.cause.workshop_workers: "{0}: סדנאות נשק מאוישות: {1}"