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: infantry and armour movement, permanent forts, and a named block on artillery movement (#1780)
Eyal Golanc7851de3525a
diff --git a/changelog.d/1708.md b/changelog.d/1708.mdnew file mode 100644index 000000000..2bd3d4414--- /dev/null+++ b/changelog.d/1708.md@@ -0,0 +1,3 @@+### Changed++- Under the separate gdd-0.3 identity, use catalogue infantry/armour movement allowances and terrain costs, and additive permanent-fort defence from existing fort locations. Keep legacy/gdd-0.1 rules and content unchanged. Artillery movement remains blocked pending approved values; existing fire rules remain unchanged. Refs #1708 (bounded slice; full cutover and release gates remain).diff --git a/docs/gdd03-catalogue.md b/docs/gdd03-catalogue.mdindex 3ef82cdb2..50dba4b65 100644--- a/docs/gdd03-catalogue.md+++ b/docs/gdd03-catalogue.md@@ -1,6 +1,8 @@# GDD 0.3 catalogue mapping-`content/gdd03-balance.yaml` records the design data for the separate `gdd-0.3` ruleset (#1687). It does not select that ruleset or change the live legacy/gdd-0.1 simulation. Existing content sets without this file still load; an authored file is validated and included in the content hash. No existing system consumes its numbers yet.+`content/gdd03-balance.yaml` records the design data for the separate `gdd-0.3` ruleset (#1687). It does not select that ruleset or change the live legacy/gdd-0.1 simulation. Existing content sets without this file still load; an authored file is validated and included in the content hash. #1708 consumes only the existing movement/defence subset under exact identity `gdd-0.3`: `military.move_infantry`, `military.move_armoured`, `military.move_road`, `military.move_rail`, `military.stack_limit`, `military.fort_bonus`, `military.fortify_turns`, `military.fortify_bonus`, the six land biomes' `movement` and `defence_percent` parts, and the `lake`/`sea` impassability expressions. Consumed values must have the specified integral shape and Agreed/Default basis; absent, Deferred or malformed values are rejected. This does not promote Default data to Agreed or adopt the remainder of the catalogue.++Artillery allowance and terrain costs remain Deferred, with no number introduced. Its movement consumer is blocked; its existing firing contract and shot accounting remain unchanged. Adding symbolic artillery catalogue entries requires a separately approved 0.3-only overlay/load design so older identities' raw content hashes remain unchanged; no shared catalogue edit is made here. Permanent forts derive from existing `kind: fort` location records after overrides (currently Latrun and Iraq Suwaydan; roster subject to Amir), without new state/save data. Legacy/gdd-0.1 use their original runtime paths and hash inputs.The pinned source is [#1668's balance.md at 605277df](https://github.com/eyalgolan/statecraft-israel/blob/605277df/docs/gdd/balance.md). Every backticked key in its Key tables has a literal catalogue key. Project keys (`maabara` through `rail_segment`) and existing biome ids also keep their names. This gives 142 keys; a test fixes that inventory independently of the loader. Tables that share one row across several keys are split into individual entries. Multi-tier values remain ordered as in the source, with the order and units in the note.diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex a1689eec1..ec37324dc 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -236,23 +236,23 @@ R-COR-003: A corridor is complete when every one of its segments is built, in anPhase 5 PR 5 (#744). The numbers are design values this PR proposed (Q-MOVE-1, Q-MOVE-3; owner, 15 October 2026, #375: "Take all recommendations") and the owner accepted them on 19 October 2026 (https://github.com/eyalgolan/statecraft-israel/pull/1073#issuecomment-6259021508).-R-MOVE-001: Each unit type that moves has an integer `movement_points` a turn (`unit_types.yaml`; required, at least 1, on a military type; refused on a population type), and each land biome of `map/hexes.json` an integer cost to enter (`rules.yaml` `mvp.move_cost`, at least 1; the loader refuses a land biome with no cost and a cost for a water biome, so lake and sea are impassable). A path's cost is the sum of the costs of the hexes it enters. A unit's Moves in one turn share its points: a second Move has what the first left, and the next turn has them all again. The points left are the type's points less those the unit spent this turn (`Movement.PointsLeft`). A unit needs the full cost of the next hex, with one exception: a unit that has not moved this turn may enter one neighbouring land hex whatever it costs, and that move spends all its points (the owner, 23 October 2026, OQ-3: "No, strict like Civ VI", "with full points it can always move one hex"). A type with no movement points (the halutz types) cannot move. Real values: recruit 3 (owner, 19 October 2026, https://github.com/eyalgolan/statecraft-israel/pull/1130#issuecomment-6269103829), veteran soldier 3, artillery 2, armoured car 5; coastal plain, valley and lowland 1, hills and desert 2, mountains 3.+R-MOVE-001: Each unit type that moves has an integer `movement_points` a turn (`unit_types.yaml`; required, at least 1, on a military type; refused on a population type), and each land biome of `map/hexes.json` an integer cost to enter (`rules.yaml` `mvp.move_cost`, at least 1; the loader refuses a land biome with no cost and a cost for a water biome, so lake and sea are impassable). A path's cost is the sum of the costs of the hexes it enters. A unit's Moves in one turn share its points: a second Move has what the first left, and the next turn has them all again. The points left are the type's points less those the unit spent this turn (`Movement.PointsLeft`). A unit needs the full cost of the next hex, with one exception: a unit that has not moved this turn may enter one neighbouring land hex whatever it costs, and that move spends all its points (the owner, 23 October 2026, OQ-3: "No, strict like Civ VI", "with full points it can always move one hex"). A type with no movement points (the halutz types) cannot move. Real values: recruit 3 (owner, 19 October 2026, https://github.com/eyalgolan/statecraft-israel/pull/1130#issuecomment-6269103829), veteran soldier 3, artillery 2, armoured car 5; coastal plain, valley and lowland 1, hills and desert 2, mountains 3. Under exact identity `gdd-0.3` (#1708), `Movement.Allowance` reads `gdd03-balance.yaml` `military.move_infantry` (2) or `military.move_armoured` (3), by type class for either army. The six land rows' `movement` pairs are infantry/armour: coastal plain, lowland and valley 1/1; hills and desert 2/2; mountains 2/3. These are existing Default catalogue values sourced to #1668 balance.md at 605277df. Reachability, path, route ETA, immediate execution, enemy movement, points-left, needs-orders and the UI denominator share this contract, including the full-points exception. Artillery movement parameters remain Deferred: movement and go-to are blocked, without guessing a number or borrowing a terrain column; existing artillery fire accounting remains unchanged (R-COMBAT-007). No shared content bytes or older identity allowances change.-R-MOVE-002: `Move(unit, q, r)` takes the cheapest path, at command time (spec §2.3). Hexes leave the search in (cost, q, r) ordinal order, neighbours are tried in `tools/hexgrid.py`'s `NEIGHBOURS` order, and a hex reached again at the same cost keeps the hex it was first entered from, so of two equal paths the one through the hex first in that order wins, and the path is the same every run. `Movement.Reachable(c, s, unit, spent)` and `Movement.Path(c, s, unit, q, r, spent)` search with the points left; without `spent`, with all of them. `Movement.Reachable` lists the hexes a Move can end on this turn with their costs, and `Movement.Path` the hexes a path enters; both come from the same search Move uses (spec §2.6). `Movement.Route(c, s, unit, q, r, spent)` is the cheapest path with no points limit, each hex numbered with the turn it is reached on: turn 1 spends the points left, later turns all of them, a step that does not fit what is left of a turn starts the next, and a step costing more than the full points is a turn of its own (R-MOVE-001).+R-MOVE-002: `Move(unit, q, r)` takes the cheapest path, at command time (spec §2.3). Hexes leave the search in (cost, q, r) ordinal order, neighbours are tried in `tools/hexgrid.py`'s `NEIGHBOURS` order, and a hex reached again at the same cost keeps the hex it was first entered from, so of two equal paths the one through the hex first in that order wins, and the path is the same every run. `Movement.Reachable(c, s, unit, spent)` and `Movement.Path(c, s, unit, q, r, spent)` search with the points left; without `spent`, with all of them. `Movement.Reachable` lists the hexes a Move can end on this turn with their costs, and `Movement.Path` the hexes a path enters; both come from the same search Move uses (spec §2.6). `Movement.Route(c, s, unit, q, r, spent)` is the cheapest path with no points limit, each hex numbered with the turn it is reached on: turn 1 spends the points left, later turns all of them, a step that does not fit what is left of a turn starts the next, and a step costing more than the full points is a turn of its own (R-MOVE-001). Under `gdd-0.3`, the same ordering and search consume R-MOVE-001's role costs and effective allowance; player actions still take effect at command time (owner ruling on #1708, 26 October 2026).-R-MOVE-003: A hex holds at most `mvp.stack_limit` units of one side (Q-MOVE-3; real value 3). The limit counts the moving unit's side only and applies where a move ends; a path may pass through a full hex. A hex never holds both sides' units: entering an enemy unit's hex is an attack (Phase 5 PR 8), so Move refuses it.+R-MOVE-003: A hex holds at most `mvp.stack_limit` units of one side (Q-MOVE-3; real value 3). The limit counts the moving unit's side only and applies where a move ends; a path may pass through a full hex. A hex never holds both sides' units: entering an enemy unit's hex is an attack (Phase 5 PR 8), so Move refuses it. Under `gdd-0.3`, the limit is the existing Default catalogue key `military.stack_limit` (3), including combat retreats.-R-MOVE-004: There is no zone of control (Q-MOVE-4): a unit passes next to an enemy unit at the terrain's cost, but no path enters or passes through an enemy unit's hex. Units may enter any land hex on the board; the 1948 control layer stays display-only. There is no transport (Q-MOVE-5).+R-MOVE-004: There is no zone of control (Q-MOVE-4): a unit passes next to an enemy unit at the terrain's cost, but no path enters or passes through an enemy unit's hex. Units may enter any land hex on the board; the 1948 control layer stays display-only. There is no transport (Q-MOVE-5). The same water, enemy-hex and no-zone-of-control restrictions apply under `gdd-0.3`; water catalogue rows must remain `impassable`.-R-MOVE-005: A player unit cannot enter the hex of an enemy-held locality that is not a curated target (`settlement_targets.yaml`, R-CTRL-001), and no path passes through one: in Phase 6 only Gaza stays closed (Q-CIV-1, owner, 15 October 2026: "No entry until Phase 6"; Q-TGT-1 (a)). The hex of an enemy-held target is open, so a player unit may move onto it, or through it, and capture it in play (R-CTRL-004; the owner's ruling on #793, 21 October 2026, that the targets "can be captured in play", https://github.com/eyalgolan/statecraft-israel/issues/793#issuecomment-6322289565; #1304). Raid's withdrawal (R-CTRL-010) and combat retreat (R-COMBAT-003) still never end on any enemy-held locality, target or not, and the enemy's mirror (R-ENEMY-001) is unchanged. The localities are the settlements listed in `rules.yaml` `mvp.enemy_held_localities` (`settlements_1948.yaml` ids; the loader refuses an unknown one). The real list is the owner-accepted DRAFT (19 October 2026, https://github.com/eyalgolan/statecraft-israel/pull/1073#issuecomment-6259083180): acre, nazareth, lod, ramla, gaza, beersheba. It is unchecked: no person has yet checked each place's control on 15 May 1948; research task #1096 will check it. An annexed target (R-CTRL-016) is no enemy-held locality: the player's withdrawal and retreat may end on it, and enemy units may not enter it, as any Israeli town (#799).+R-MOVE-005: A player unit cannot enter the hex of an enemy-held locality that is not a curated target (`settlement_targets.yaml`, R-CTRL-001), and no path passes through one: in Phase 6 only Gaza stays closed (Q-CIV-1, owner, 15 October 2026: "No entry until Phase 6"; Q-TGT-1 (a)). The hex of an enemy-held target is open, so a player unit may move onto it, or through it, and capture it in play (R-CTRL-004; the owner's ruling on #793, 21 October 2026, that the targets "can be captured in play", https://github.com/eyalgolan/statecraft-israel/issues/793#issuecomment-6322289565; #1304). Raid's withdrawal (R-CTRL-010) and combat retreat (R-COMBAT-003) still never end on any enemy-held locality, target or not, and the enemy's mirror (R-ENEMY-001) is unchanged. The localities are the settlements listed in `rules.yaml` `mvp.enemy_held_localities` (`settlements_1948.yaml` ids; the loader refuses an unknown one). The real list is the owner-accepted DRAFT (19 October 2026, https://github.com/eyalgolan/statecraft-israel/pull/1073#issuecomment-6259083180): acre, nazareth, lod, ramla, gaza, beersheba. It is unchecked: no person has yet checked each place's control on 15 May 1948; research task #1096 will check it. An annexed target (R-CTRL-016) is no enemy-held locality: the player's withdrawal and retreat may end on it, and enemy units may not enter it, as any Israeli town (#799). Under `gdd-0.3` these guards remain; a `kind: fort` location grants neither locality capture eligibility nor peaceful entry onto hostile combatants (R-COMBAT-010).-R-MOVE-006: `Move` is refused with the state unchanged and a reason when the unit does not exist, is not the player's (a unit of a side other than Israel), cannot move or is already on the hex, when the hex is water or off the board, holds an enemy unit, is an enemy-held locality closed by R-MOVE-005 or is full of the unit's side, or when no path reaches it within the points the unit has left this turn. It costs no Attention (D-A6). A Move that goes through clears a fortify order (`fortify`, or `fortifying` the turn it is given) and the hex it names at once, so a unit that leaves its hex and comes back in the same turn is not fortified (Q-HOLD-1, "lost on move"); hold moves with the unit; a refused Move changes nothing.+R-MOVE-006: `Move` is refused with the state unchanged and a reason when the unit does not exist, is not the player's (a unit of a side other than Israel), cannot move or is already on the hex, when the hex is water or off the board, holds an enemy unit, is an enemy-held locality closed by R-MOVE-005 or is full of the unit's side, or when no path reaches it within the points the unit has left this turn. It costs no Attention (D-A6). A Move that goes through clears a fortify order (`fortify`, or `fortifying` the turn it is given) and the hex it names at once, so a unit that leaves its hex and comes back in the same turn is not fortified (Q-HOLD-1, "lost on move"); hold moves with the unit; a refused Move changes nothing. Under `gdd-0.3` the same immediate/refusal/order-clearing contract uses the effective allowance and role terrain costs in R-MOVE-001. Moving never removes a permanent fort (R-COMBAT-010).-R-MOVE-007: Roads and rail are cheaper (D-G2; Phase 5 PR 6, #745). A step into a hex from a hex of the same built corridor segment (`corridors.yaml`, R-COR-002) costs the kind's `mvp.road_move_cost` or `mvp.rail_move_cost` (at least 1; the loader requires both in the GDD loop) when that is lower than the terrain's cost; otherwise it costs the terrain's. Only the corridors Phase 4 builds count, not the 1948 roads of `map/routes_1948.yaml` (Q-MOVE-2, owner, 15 October 2026, #375: option (a)). A segment not started or still being built costs the terrain, and a step from one segment onto another costs the terrain unless both hexes lie on one built segment. Real values: road 1, rail 1, design values Phase 5 PR 6 proposes; the owner may override them. A cost of 1 saves nothing on the coastal plain, valley or lowland, which already cost 1.+R-MOVE-007: Roads and rail are cheaper (D-G2; Phase 5 PR 6, #745). A step into a hex from a hex of the same built corridor segment (`corridors.yaml`, R-COR-002) costs the kind's `mvp.road_move_cost` or `mvp.rail_move_cost` (at least 1; the loader requires both in the GDD loop) when that is lower than the terrain's cost; otherwise it costs the terrain's. Only the corridors Phase 4 builds count, not the 1948 roads of `map/routes_1948.yaml` (Q-MOVE-2, owner, 15 October 2026, #375: option (a)). A segment not started or still being built costs the terrain, and a step from one segment onto another costs the terrain unless both hexes lie on one built segment. Real values: road 1, rail 1, design values Phase 5 PR 6 proposes; the owner may override them. A cost of 1 saves nothing on the coastal plain, valley or lowland, which already cost 1. Under `gdd-0.3`, the corridor costs come from Default catalogue keys `military.move_road` and `military.move_rail` (1 each); the same built-segment, both-endpoint and minimum-with-biome conditions apply.-R-MOVE-008: `UnitOrder(unit, go_to, q, r)` gives a standing go-to order and moves the unit at once as far as its points left reach along `Movement.Route`. It is refused with the state unchanged and a reason for an unknown or enemy unit, one that cannot move or is already there, water or off the board, a hex holding an enemy unit, a closed locality (R-MOVE-005), or a hex no route reaches. Otherwise it replaces the unit's order, including fortify. On arrival the order is cleared. A route may pass through a full friendly hex; at each turn's stop the unit uses the last hex with room. If the destination is full on arrival, the route stops and the order is cleared.+R-MOVE-008: `UnitOrder(unit, go_to, q, r)` gives a standing go-to order and moves the unit at once as far as its points left reach along `Movement.Route`. It is refused with the state unchanged and a reason for an unknown or enemy unit, one that cannot move or is already there, water or off the board, a hex holding an enemy unit, a closed locality (R-MOVE-005), or a hex no route reaches. Otherwise it replaces the unit's order, including fortify. On arrival the order is cleared. A route may pass through a full friendly hex; at each turn's stop the unit uses the last hex with room. If the destination is full on arrival, the route stops and the order is cleared. Under `gdd-0.3`, R-MOVE-001 supplies allowance and role costs; no second allowance is applied at End turn.-R-MOVE-009: At the start of each player turn, before that turn's committed and waiting orders, every player's unit with a go-to order advances in ascending unit id along a freshly computed route. It spends movement points normally, including the full-points exception (R-MOVE-001). If no route reaches its target, or the target is full on arrival, it stops, clears the order and needs orders. An adjacent enemy does not stop it (Q-MOVE-4: no zone of control). If no hex it can reach this turn has room, it waits where it is and keeps the order.+R-MOVE-009: At the start of each player turn, before that turn's committed and waiting orders, every player's unit with a go-to order advances in ascending unit id along a freshly computed route. It spends movement points normally, including the full-points exception (R-MOVE-001). If no route reaches its target, or the target is full on arrival, it stops, clears the order and needs orders. An adjacent enemy does not stop it (Q-MOVE-4: no zone of control). If no hex it can reach this turn has room, it waits where it is and keeps the order. Under `gdd-0.3`, only an outstanding route continues at the turn boundary; ordinary moves and immediate attacks are not repeated, and the enemy follows the player's actions (owner ruling on #1708). Allowance and ETA follow R-MOVE-001.R-MOVE-010: A unit needs orders when it is one of the player's military units, its type has movement points, it has neither moved nor attacked this turn, and it has no order (`fortify`, `fortifying`, `hold` and `go_to` are orders) (`Movement.NeedsOrders`, ascending id). End turn waits until no unit needs orders, apart from those the player skips this turn (the owner, 23 October 2026: "Block like Civ"; spec 2026-10-23 section 7). Skipping is not an order and changes nothing in the game.@@ -262,9 +262,9 @@ Phase 5 PR 7 (#746). Q-HOLD-1, "(a) 1 turn, free, lost on move", and Q-HOLD-2, "R-ORDER-001: `UnitOrder(unit, order)` gives one of the player's military units the standing order `fortify` or `hold`, replacing the one it had. A new order replaces a go-to too. The unit keeps its order, turn after turn, until the player gives another; moving clears fortify (Q-HOLD-1): in the resolver after combat (step 2), in id order, a unit no longer on the hex its fortify names (`OrderTarget`, "q,r") loses the order. The order is refused with the state unchanged and a reason for an unknown order or unit, a unit with no side (a halutz), a unit of another side, a hold for artillery (R-COMBAT-007), or the order the unit already has (fortify on the hex it fortifies). It costs `attention_cost.unit_order` (0, D-A6) and is refused in the legacy loop.-R-ORDER-002: Fortify takes one turn to set and costs no Arms or Money (Q-HOLD-1). Given, it reads `fortifying` and names the unit's hex; in the same resolver step it becomes `fortify`, so the combat of the turn it is given sees no bonus. A fortified unit on its hex defends at `mvp.fortify_defence_percent` of its strength (`Orders.DefencePercent`; real value 125), and from the moment it leaves the hex at 100.+R-ORDER-002: Fortify takes one turn to set and costs no Arms or Money (Q-HOLD-1). Given, it reads `fortifying` and names the unit's hex; in the same resolver step it becomes `fortify`, so the combat of the turn it is given sees no bonus. A fortified unit on its hex defends at `mvp.fortify_defence_percent` of its strength (`Orders.DefencePercent`; real value 125), and from the moment it leaves the hex at 100. Under `gdd-0.3`, the catalogue's Agreed `military.fortify_turns` must remain 1; settled fortify on its named hex adds the Default `military.fortify_bonus` (25) to the other defence bonuses, once (R-COMBAT-002). `fortifying` adds nothing.-R-ORDER-003: Hold acts on the unit's own hex only and does not intercept or stop any enemy move, past or next to it (Q-HOLD-2). It names no hex and stays when the unit moves. A holding unit defends at `mvp.hold_defence_percent` of its strength (real value 100: hold keeps the position and adds nothing); a unit with no order defends at 100.+R-ORDER-003: Hold acts on the unit's own hex only and does not intercept or stop any enemy move, past or next to it (Q-HOLD-2). It names no hex and stays when the unit moves. A holding unit defends at `mvp.hold_defence_percent` of its strength (real value 100: hold keeps the position and adds nothing); a unit with no order defends at 100. Under `gdd-0.3`, Hold adds no defence bonus; it does not multiply terrain or permanent forts (R-COMBAT-002).## Combat@@ -272,7 +272,7 @@ Phase 5 PR 8 (#747). Q-COMBAT-1 to Q-COMBAT-4 are the plan's recommendations (owR-COMBAT-001: `UnitOrder(unit, attack, q, r)` makes one of the player's military units attack the hex (q, r) at once, alone, when the order runs (the owner, 23 October 2026: "Instant, like Civ" and OQ-1: "One unit per attack, Civ"). It replaces the unit's order (a fortify is lost), spends the rest of its movement points for the turn and leaves no attack order. The hex must be next to the unit (artillery: within its range, R-COMBAT-007) and hold an enemy military unit; enemy units on a hex with a locality and its residents may be attacked, and the residents are never a target (Q-CIV-2). The order is refused with the state unchanged and a reason for an unknown unit, a halutz, a unit of another side, no hex, a hex not next to it (artillery: beyond its range), no enemy unit, no movement points left or a stock below the Arms this attack needs. Fortify and hold name no hex: one that names a hex is refused. The order costs `attention_cost.unit_order` (0, D-A6). A save writes it as `order <unit> attack <q> <r>`; a scenario takes `q` and `r`. Under `gdd-0.3`, attacks and artillery fire use the same instant timing without an Arms affordability check or deduction; all other validity checks remain.-R-COMBAT-002: Resolver step 2 resolves the enemy's attacks in ascending attacker id: the lowest-id unit with an attack not yet in an engagement leads one, with every enemy unit attacking the same hex. A player's attack is fought when its order runs (R-COMBAT-001), as one engagement with that unit alone and one draw. Each unit's strength is first multiplied by its type's `combat_percent` (R-COMBAT-007, R-COMBAT-008). The attackers' strengths are summed; each defender's strength is multiplied by its order's defence percent (`Orders.DefencePercent`: fortify 125, R-ORDER-002) and by `mvp.combat_terrain_percent` for its hex's biome (real values: hills 125, mountains 150, every other land biome 100). The ratio is attack over defence in whole percent, rounded down, in integers only; the row of `mvp.combat_table` is the last whose `min_ratio_percent` it reaches (real rows: below 1:2, 1:2, 1:1, 2:1, 3:1). Each engagement draws exactly one RNG value, a face of the row (six in the real table), whatever its outcome; a step 2 with no engagement draws nothing (docs/determinism.md, "Combat draws"). `Combat.Preview(c, s, unit, q, r)` gives the ratio and row the UI shows (Q-UI-1; spec §2.6), counting that unit alone for a player's attack.+R-COMBAT-002: Resolver step 2 resolves the enemy's attacks in ascending attacker id: the lowest-id unit with an attack not yet in an engagement leads one, with every enemy unit attacking the same hex. A player's attack is fought when its order runs (R-COMBAT-001), as one engagement with that unit alone and one draw. Each unit's strength is first multiplied by its type's `combat_percent` (R-COMBAT-007, R-COMBAT-008). The attackers' strengths are summed; each defender's strength is multiplied by its order's defence percent (`Orders.DefencePercent`: fortify 125, R-ORDER-002) and by `mvp.combat_terrain_percent` for its hex's biome (real values: hills 125, mountains 150, every other land biome 100). The ratio is attack over defence in whole percent, rounded down, in integers only; the row of `mvp.combat_table` is the last whose `min_ratio_percent` it reaches (real rows: below 1:2, 1:2, 1:1, 2:1, 3:1). Each engagement draws exactly one RNG value, a face of the row (six in the real table), whatever its outcome; a step 2 with no engagement draws nothing (docs/determinism.md, "Combat draws"). `Combat.Preview(c, s, unit, q, r)` gives the ratio and row the UI shows (Q-UI-1; spec §2.6), counting that unit alone for a player's attack. Under exact identity `gdd-0.3`, each defender instead counts once at `100 + biome defence_percent + permanent fort bonus + applicable settled Fortify bonus` percent, with bonuses read from the existing catalogue (#1668 military-combat.md:27, additive). Hold and unsettled/mismatched Fortify add nothing. Mountain + fort + settled Fortify is 225% of base defence (50 + 50 + 25); preview and resolution share this integer calculation. The older multiplicative formula remains unchanged.R-COMBAT-003: The face gives the population units each side loses and whether the defenders retreat. Losses fall one unit at a time on the side's strongest unit in the engagement (a tie on the lower id; the attackers' losses spare their artillery, R-COMBAT-007); a unit at 0 is destroyed and leaves the state, and its id is never reused (`NextId` does not move). When the face says retreat, each defender left, in id order, moves one hex to the first neighbour in the fixed order (R-MOVE-002) that is land, holds no unit of the other side, has room for its side under `mvp.stack_limit`, and, for a player's unit, is not an enemy-held locality (R-MOVE-005). A defender with no such hex surrenders and leaves the state: the only way a unit is captured (impact plan §4.3 item 1; its people are counted as prisoners or as the player's soldiers held, R-POW-001, R-POW-005). The attackers never advance into the hex (Q-COMBAT-3). A player's unit's first loss stores the strength it had as its `Full`; only replacements (R-TRAIN-004) restore lost strength.@@ -286,12 +286,14 @@ Phase 5 PR 9, part 1 (#748): artillery's combat role and the armoured car. Q-ARTR-COMBAT-007: Artillery (a type of class `artillery`, which needs a `range` and an `arms_per_fire`; real values 2 and 2) attacks alone from range. Its `UnitOrder(unit, attack, q, r)` names an enemy hex at a hex distance of 1 to its `range`; a farther hex is refused with "That hex is beyond the unit's range". The player's artillery attacks at once like any unit, pays its type's `arms_per_fire` in place of `mvp.arms_per_attack`, and its losses spare it, so it loses nothing. Enemy artillery still joins an engagement in step 2 after the other attackers of its side and only when at least one of them joins; otherwise it holds its fire, with a line, pays nothing and keeps its order. Its strength counts at its `combat_percent` (real value 200). Artillery that is attacked defends and takes losses like any unit. It never holds ground: a hold order for it is refused with "Artillery does not hold ground" (fortify is allowed). As in any attack, residents are never a target (Q-CIV-2, R-COMBAT-005). Under `gdd-0.3`, artillery still fires alone at once from the existing range and keeps the same outcomes, but has no Arms affordability check or deduction; `arms_per_fire` is not required or read in that identity. Range and combat factors retain their existing validation. The remaining combat redesign is held.-R-COMBAT-008: A military type may carry a `combat_percent` (at least 1; none is 100): its units' strength counts at that percent in the ratio, attacking and defending, in integers (R-COMBAT-002). The armoured car's is 150 (real value), with its 5 movement points (R-MOVE-001) and no other rule (Q-ARTY-2).+R-COMBAT-008: A military type may carry a `combat_percent` (at least 1; none is 100): its units' strength counts at that percent in the ratio, attacking and defending, in integers (R-COMBAT-002). The armoured car's is 150 (real value), with its 5 movement points (R-MOVE-001) and no other rule (Q-ARTY-2). Under `gdd-0.3`, armour's movement allowance is the catalogue value 3 (R-MOVE-001); combat factors and other mechanics remain unchanged.Phase 5 PR 11, slice 2 (#750): the truce cards bind the player's attack orders (Q-WAR-3). The windows and the two rulings below are the owner's of 21 and 22 October 2026 (https://github.com/eyalgolan/statecraft-israel/issues/750#issuecomment-6327133246). The card-to-window binding by `ChosenOptions` is an agent default of this PR; the rest of #750's war state replaces R-ENEMY-006's date-alone guard in its own slices.R-COMBAT-009: From accepting a truce card until its window ends, the player's attack orders are refused with "A truce is in force": from `first_truce`'s `accept` on the turns that start before 8 July 1948, and from `second_truce`'s `comply` on the turns that start before 15 October 1948, on the sourced dates of `events/first_truce.yaml`, `events/ten_days.yaml`, `events/second_truce.yaml` and `events/operation_yoav.yaml` (R-ENEMY-006's windows). A refused or defied card binds nothing: only the accepting option starts the binding. A complying player attacks again from the 15 October 1948 turn (owner ruling 1). The rule reads its turn by the turn's first day (the date the HUD shows) and R-ENEMY-006 by the turn's middle day; on monthly turns the two agree: the turns of 15 June to 15 September 1948 are bound, 15 October is free. Movement and every other order stand. The enemy side's own guard is untouched. The truce's refusal takes nothing: the order names its hex before the truce is checked, the state and the Attention are preserved, and no Arms are paid.+R-COMBAT-010: Under exact identity `gdd-0.3` only, an effective map-location hex with at least one existing `kind: fort` record grants either defending army the Default catalogue `military.fort_bonus` (50 percent). Existing records are `latrun_fort` and `iraq_suwaydan_fort`; the roster remains subject to Amir. Use effective placement after map overrides, with a legal land hex required. Duplicate markers grant one bonus. A fort is immutable content, independent of its occupant: vacancy, departure, re-entry, retreat, destruction and a change of defending army do not remove it. Attacking from a fort gives no attack bonus. No managed-city, capture-target, control, defeat, save schema or mutable-state property is created. Bonuses combine as R-COMBAT-002 specifies; older identities ignore permanent forts. Source: #1668 balance.md:141 at 605277df and the existing locations_1948.yaml records, reused without new historical claims.+## The enemyPhase 5 PR 10, part 1 (#749). Q-ENEMY-1 to Q-ENEMY-4 are the plan's recommendations (owner, 15 October 2026, #375: "Take all recommendations"). The march's turns (through the 15 June 1948 turn, until the first truce ends on 8 July) are the owner's (owner, 21 October 2026, #749); so is the truce guard (R-ENEMY-006, same ruling). The scripted anchor's choice, the goal order, `mvp.enemy_attack_ratio_percent` and the truce guard's turn-middle reading are agent defaults proposed on #749 and #1263. The operation cards' orders (Q-ENEMY-5, the plan's R-ENEMY-005) are part 2.diff --git a/sim/Statecraft.Sim.Tests/Gdd03MovementFortTests.cs b/sim/Statecraft.Sim.Tests/Gdd03MovementFortTests.csnew file mode 100644index 000000000..38bfe392d--- /dev/null+++ b/sim/Statecraft.Sim.Tests/Gdd03MovementFortTests.cs@@ -0,0 +1,416 @@+using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using Statecraft.Sim;++/// <summary>#1708 bounded slice. Synthetic units/forts are fixture data, not a production roster.</summary>+public class Gdd03MovementFortTests+{+ const string Types = Fixture.GddUnitTypes+ + " - { id: car, kind: unit, side: israel, class: armour, movement_points: 5 }\n"+ + " - { id: enemy, kind: unit, side: egypt, class: infantry, movement_points: 3 }\n"+ + " - { id: enemy_car, kind: unit, side: egypt, class: armour, movement_points: 5 }\n"+ + " - { id: gun, kind: unit, side: israel, class: artillery, movement_points: 2, range: 2, arms_per_fire: 2 }\n";++ static Dictionary<string, string> Files(string identity = SaveGame.Gdd03Ruleset, string biome = "coastal_plain")+ {+ var f = Fixture.Gdd(new Dictionary<string, string> {+ ["unit_types.yaml"] = Types,+ ["map/hexes.json"] = MovementTests.Board((3, 1, biome)),+ ["corridors.yaml"] = "corridors: []\n"+ });+ f["rules.yaml"] = f["rules.yaml"].Replace("move_cost: { coastal_plain: 1, hills: 2, desert: 3 }",+ "move_cost: { coastal_plain: 1, lowland: 1, valley: 1, hills: 2, mountains: 3, desert: 3 }")+ .Replace("combat_terrain_percent: { coastal_plain: 100, hills: 150, desert: 100 }",+ "combat_terrain_percent: { coastal_plain: 100, lowland: 100, valley: 100, hills: 150, mountains: 150, desert: 100 }");+ f["eras.yaml"] = f["eras.yaml"].Replace("loop: gdd", "loop: gdd, ruleset: " + identity);+ f[Gdd03BalanceCatalogue.FileName] = File.ReadAllText(Path.Combine(RealContentTests.ContentRoot(), Gdd03BalanceCatalogue.FileName));+ return f;+ }++ static Content Load(string identity = SaveGame.Gdd03Ruleset, string biome = "coastal_plain") =>+ ContentLoader.Load(Fixture.Write(Files(identity, biome)));++ static Unit Of(string type, int id = 1, int q = 2, int r = 1, string side = "israel", string order = "", string target = "") =>+ new Unit(id, type, q, r, side: side, strength: 6, order: order, orderTarget: target);++ static GameState With(Content c, params Unit[] units) => CombatTests.With(c, units);++ // R-MOVE-001, R-SAVE-001: exact identity gate, even with a catalogue present.+ [Fact]+ public void LegacyStillReadsItsAuthoredAllowanceAndHasNoFortBonus()+ {+ var c = ContentLoader.Load(Fixture.Write(new() { [Gdd03BalanceCatalogue.FileName] = File.ReadAllText(Path.Combine(RealContentTests.ContentRoot(),Gdd03BalanceCatalogue.FileName)) }));+ c.UnitTypes.Add(new UnitType { Id = "car", Side = "israel", Class = "armour", MovementPoints = 5 });+ c.MapLocations.Add(new MapLocation { Id = "fixture", Kind = "fort", Q = 3, R = 1 });+ Assert.Equal(SaveGame.LegacyRuleset, c.Ruleset);+ Assert.Equal(5, Movement.Allowance(c, Of("car")));+ Assert.False(c.HasPermanentFort(3, 1));+ }++ // R-MOVE-001: class, not id or army, chooses the allowance; older identities keep their authored values.+ [Theory]+ [InlineData("recruit", "israel", 2)]+ [InlineData("enemy", "egypt", 2)]+ [InlineData("car", "israel", 3)]+ [InlineData("enemy_car", "egypt", 3)]+ public void BothArmiesUseCatalogueAllowances(string type, string side, int expected)+ {+ var c = Load();+ Assert.Equal(expected, Movement.Allowance(c, Of(type, side: side)));+ var old = Load(SaveGame.GddRuleset);+ Assert.Equal(type.Contains("car") ? 5 : 3, Movement.Allowance(old, Of(type, side: side)));+ }++ // R-MOVE-001, R-MOVE-004: every land column, with water still impassable.+ [Theory]+ [InlineData("coastal_plain", 1, 1)]+ [InlineData("lowland", 1, 1)]+ [InlineData("valley", 1, 1)]+ [InlineData("hills", 2, 2)]+ [InlineData("mountains", 2, 3)]+ [InlineData("desert", 2, 2)]+ public void RoleTerrainCosts(string biome, int foot, int car)+ {+ var c = Load(biome: biome);+ foreach (var pair in new[] { ("recruit", foot), ("car", car) })+ {+ var s = With(c, Of(pair.Item1));+ Assert.Equal(pair.Item2, Movement.Reachable(c, s, 1)[(3, 1)]);+ }+ }++ [Theory]+ [InlineData("sea")]+ [InlineData("lake")]+ public void WaterIsNeverReachable(string biome)+ {+ var c = Load(biome: biome); var s = With(c, Of("car"));+ Assert.DoesNotContain((3, 1), Movement.Reachable(c, s, 1).Keys); // R-MOVE-004+ }++ // R-MOVE-001, R-MOVE-006: accumulate immediately, reset only on the next turn.+ [Fact]+ public void ImmediateMovesSpendTheNewAllowance()+ {+ var c = Load(); var s = With(c, Of("recruit"));+ var now = Simulation.Preview(c, s, new Command[] { new Move(1, 3, 1), new Move(1, 4, 1), new Move(1, 5, 1) });+ Assert.Equal((4, 1), (now.State.Units[1].Q, now.State.Units[1].R));+ Assert.Single(now.Rejected);+ Assert.Equal(2, now.Spent[1]);+ Assert.Equal(0, Movement.PointsLeft(c, now.State, 1, now.Spent));+ var next = Simulation.Step(c, s, new Command[] { new Move(1, 3, 1), new Move(1, 4, 1) });+ Assert.Equal((4, 1), (next.State.Units[1].Q, next.State.Units[1].R));+ Assert.Equal(2, Movement.PointsLeft(c, next.State, 1, new Dictionary<int, int>()));+ }++ // R-MOVE-001, R-MOVE-008, R-MOVE-009: synthetic expensive terrain tests the full-points exception.+ [Fact]+ public void ExpensiveFirstStepIsOnlyAllowedAtFullPointsAndEtaAgrees()+ {+ var f = Files();+ f["map/hexes.json"] = MovementTests.Board((3, 1, "mountains"), (4, 1, "sea"), (4, 0, "sea"),+ (3, 0, "sea"), (2, 2, "sea"), (3, 2, "sea"));+ var c = ContentLoader.Load(Fixture.Write(f));+ c.Gdd03Balance!.Values["mountains"].Parts["movement"].Values[0] = 9;+ var s = With(c, Of("recruit"));+ Assert.Equal(2, Movement.Reachable(c, s, 1)[(3, 1)]);+ Assert.DoesNotContain((3, 1), Movement.Reachable(c, s, 1, new Dictionary<int, int> { [1] = 1 }).Keys);+ Assert.Equal(1, Movement.Route(c, s, 1, 3, 1, new Dictionary<int, int>()).Last().Turn);+ Assert.Equal(2, Movement.Route(c, s, 1, 3, 1, new Dictionary<int, int> { [1] = 1 }).Last().Turn);+ }++ // R-MOVE-002, R-MOVE-008: deterministic route and initial advancement share the allowance.+ [Fact]+ public void GoToAdvancesAtOnceAndOnlyTheOutstandingRouteContinues()+ {+ var c = Load(); var s = With(c, Of("recruit", q: 0)); var spent = new Dictionary<int, int>(); var why = new List<Cause>();+ var route = Movement.Route(c, s, 1, 5, 1, spent);+ Assert.Equal(new[] { 1, 1, 2, 2, 3 }, route.Select(h => h.Turn));+ Assert.Equal(route, Movement.Route(c, s, 1, 5, 1, spent));+ Assert.Null(Movement.GiveGoTo(c, s, 1, 5, 1, spent, why));+ Assert.Equal(2, s.Units[1].Q);+ Movement.ContinueRoutes(c, s, spent, why); // no second allowance in the same turn+ Assert.Equal(2, s.Units[1].Q);+ spent.Clear(); Movement.ContinueRoutes(c, s, spent, why);+ Assert.Equal(4, s.Units[1].Q);+ spent.Clear(); Movement.ContinueRoutes(c, s, spent, why);+ Assert.Equal(5, s.Units[1].Q); Assert.Equal("", s.Units[1].Order);+ }++ // R-MOVE-003: catalogue selection, not accidental equality with the legacy stack default.+ [Fact]+ public void StackLimitComesFromCatalogue()+ {+ var c = Load(); c.Gdd03Balance!.Values["military.stack_limit"].Values[0] = 1;+ var s = With(c, Of("recruit"), Of("car", 2, 3));+ Assert.NotNull(Movement.Full(c, s, s.Units[1], 3, 1));+ }++ // R-MOVE-001: no artillery movement number or infantry-column fallback is introduced.+ [Fact]+ public void DeferredArtilleryCannotMoveButItsExistingFireContractRemains()+ {+ var c = Load(); var s = With(c, Of("gun"), Of("enemy", 2, 4, side: "egypt"));+ Assert.Contains(1, Movement.NeedsOrders(c,s,new Dictionary<int,int>()));+ Assert.Empty(Movement.Reachable(c, s, 1));+ Assert.Equal(Movement.MissingArtilleryMovement, Movement.GiveGoTo(c, s, 1, 3, 1, new Dictionary<int, int>(), new List<Cause>()));+ s.Arms = 0;+ Assert.Null(Combat.Check(c, s, 1, 4, 1, spent: new Dictionary<int, int>())); // R-COMBAT-007+ var spent = new Dictionary<int,int>(); var why = new List<Cause>();+ var before = s.Hash();+ Assert.Equal(Movement.MissingArtilleryMovement, Movement.Move(c,s,1,3,1,spent,why));+ Assert.Equal(before,s.Hash()); Assert.Empty(why); Assert.Empty(spent);+ Assert.True(Movement.ActionsLeft(c,s,1,spent) > 0);+ Assert.Null(Combat.Strike(c,s,1,4,1,spent,new Dictionary<int,(int Q,int R)>(),why));+ Assert.Equal(0,s.Arms); Assert.DoesNotContain(1,Movement.NeedsOrders(c,s,spent));+ Assert.Equal(0,Movement.ActionsLeft(c,s,1,spent));+ Assert.NotNull(Combat.Check(c,s,1,4,1,spent:spent));++ }++ // R-COMBAT-010, R-COMBAT-002, R-ORDER-002, R-ORDER-003: additive, either army, no Hold or unsettled bonus.+ [Theory]+ [InlineData("israel", "", "", 50)]+ [InlineData("egypt", "", "", 50)]+ [InlineData("egypt", "hold", "", 50)]+ [InlineData("egypt", "fortifying", "3,1", 50)]+ [InlineData("egypt", "fortify", "3,1", 44)]+ [InlineData("egypt", "fortify", "2,1", 50)]+ public void FortDefenceIsAdditiveAndIndependentOfOccupant(string defenderSide, string order, string target, int expected)+ {+ var c = Load(biome: "mountains");+ c.MapLocations.Add(new MapLocation { Id = "fixture_fort", Kind = "fort", Q = 3, R = 1 });+ c.MapLocations.Add(new MapLocation { Id = "duplicate_marker", Kind = "fort", Q = 3, R = 1 });+ string attackSide = defenderSide == "israel" ? "egypt" : "israel";+ var s = With(c, Of("recruit", side: attackSide), Of("enemy", 2, 3, side: defenderSide, order: order, target: target));+ Assert.Equal(expected, Combat.Preview(c, s, 1, 3, 1)!.Value.RatioPercent);+ s.Units.Remove(2); // destruction/vacancy cannot remove a content property+ Assert.True(c.HasPermanentFort(3, 1));+ s.Units.Add(2, Of("enemy", 2, 3, side: defenderSide));+ Assert.Equal(50, Combat.Preview(c, s, 1, 3, 1)!.Value.RatioPercent);+ c.MapLocations.Clear();+ Assert.Equal(66, Combat.Preview(c, s, 1, 3, 1)!.Value.RatioPercent);+ }++ // R-COMBAT-010: the actual existing fort roster, no name/coordinate guessing.+ [Fact]+ public void ExistingFortRecordsSupplyBothHexesOnlyUnderGdd03()+ {+ var c = ContentLoader.Load(RealContentTests.ContentRoot());+ var forts = c.MapLocations.Where(l => l.Kind == "fort").ToArray();+ Assert.Equal(new[] { "iraq_suwaydan_fort", "latrun_fort" }, forts.Select(l => l.Id).OrderBy(x => x));+ Assert.All(forts, l => Assert.False(c.HasPermanentFort(l.Q, l.R)));+ c.Eras[0].Systems.Ruleset = SaveGame.Gdd03Ruleset;+ Assert.All(forts, l => Assert.True(c.HasPermanentFort(l.Q, l.R)));+ foreach (var fort in forts)+ foreach (var defenderSide in new[] { "israel", "egypt" })+ {+ var neighbour = Movement.Neighbours.Select(d => c.HexAt(fort.Q + d.Q, fort.R + d.R)).First(h => h != null && h.Land)!;+ var s = Simulation.NewGame(c, 1, Mode.Historical); s.Units.Clear();+ var attackerSide = defenderSide == "israel" ? "egypt" : "israel";+ s.Units.Add(1, Of("recruit", q: neighbour.Q, r: neighbour.R, side: attackerSide));+ s.Units.Add(2, Of("recruit", 2, fort.Q, fort.R, side: defenderSide));+ var biome = c.HexAt(fort.Q, fort.R)!.Biome;+ var terrain = biome == "mountains" ? 50 : biome == "hills" ? 25 : 0;+ Assert.Equal(10_000 / (150 + terrain), Combat.Preview(c, s, 1, fort.Q, fort.R)!.Value.RatioPercent);+ }+ }++ // R-MOVE-001, R-COMBAT-010: malformed consumed values fail at load, never use old numbers.+ [Theory]+ [InlineData("military.move_infantry", "basis: Deferred, expression: pending, note: fixture")]+ [InlineData("military.move_armoured", "basis: Default, values: [1.5], note: fixture")]+ [InlineData("military.move_road", "basis: Default, values: [0], note: fixture")]+ [InlineData("military.move_rail", "basis: Default, values: [1, 2], note: fixture")]+ [InlineData("military.fort_bonus", "basis: Default, values: [-1], note: fixture")]+ public void LoaderRejectsInvalidConsumedScalar(string key, string row)+ {+ var f = Files();+ f[Gdd03BalanceCatalogue.FileName] = System.Text.RegularExpressions.Regex.Replace(f[Gdd03BalanceCatalogue.FileName],+ "(?m)^ \"" + System.Text.RegularExpressions.Regex.Escape(key) + "\":\\n(?: .*\\n)*", " \"" + key + "\": { " + row + " }\n");+ var error = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(f)));+ Assert.Contains(key, error.Message);+ f["rules.yaml"] = f["rules.yaml"].Replace("move_cost: { coastal_plain: 1, hills: 2, desert: 3 }",+ "move_cost: { coastal_plain: 1, lowland: 1, valley: 1, hills: 2, mountains: 3, desert: 3 }")+ .Replace("combat_terrain_percent: { coastal_plain: 100, hills: 150, desert: 100 }",+ "combat_terrain_percent: { coastal_plain: 100, lowland: 100, valley: 100, hills: 150, mountains: 150, desert: 100 }");+ f["eras.yaml"] = f["eras.yaml"].Replace("gdd-0.3", "gdd-0.1");+ // Catalogue structural validation still applies, but none of these valid catalogue rows is a consumed old-rule requirement.+ Assert.NotNull(ContentLoader.Load(Fixture.Write(f)));+ }+ // R-MOVE-007: both endpoints must belong to the same built segment for either corridor kind.+ [Theory]+ [InlineData("road")]+ [InlineData("rail")]+ public void CorridorCostsUseCatalogueAndRequireBuiltSharedSegment(string kind)+ {+ var f = Files();+ f["corridors.yaml"] = Fixture.GddCorridors;+ f["map/hexes.json"] = MovementTests.Board((3, 0, "mountains"), (3, 1, "mountains"));+ var c = ContentLoader.Load(Fixture.Write(f));+ var r = kind == "road" ? 0 : 1;+ var s = With(c, Of("car", r: r));+ Assert.Equal(3, Movement.Reachable(c, s, 1)[(3, r)]);+ var id = kind == "road" ? "road_a" : "rail_a";+ var built = new DateTime(1948, 5, 15);+ s.Corridors[id] = new CorridorWork(id, kind == "road"+ ? new SegmentWork?[] { new SegmentWork(null, 6, built), null }+ : new SegmentWork?[] { new SegmentWork(null, 6, built) });+ Assert.Equal(1, Movement.Reachable(c, s, 1)[(3, r)]);+ c.Gdd03Balance!.Values["military.move_" + kind].Values[0] = 2;+ Assert.Equal(2, Movement.Reachable(c, s, 1)[(3, r)]);+ // Crossing into the segment from outside it gets no discount.+ s.Units[1] = Of("car", q: 3, r: r + 1);+ Assert.Equal(3, Movement.Reachable(c, s, 1)[(3, r)]);+ s.Corridors[id] = new CorridorWork(id, kind == "road"+ ? new SegmentWork?[] { new SegmentWork(9, 5, null), null }+ : new SegmentWork?[] { new SegmentWork(9, 5, null) });+ s.Units[1] = Of("car", r: r);+ Assert.Equal(3, Movement.Reachable(c, s, 1)[(3, r)]);+ }++ // R-COMBAT-010, R-MOVE-006: moving clears temporary fortify, never the permanent property.+ [Fact]+ public void LeavingAndReturningKeepsOnlyThePermanentFort()+ {+ var c = Load(); c.MapLocations.Add(new MapLocation { Id = "fixture", Kind = "fort", Q = 2, R = 1 });+ var s = With(c, Of("recruit", order: Orders.Fortify, target: "2,1"));+ var why = new List<Cause>(); var spent = new Dictionary<int, int>();+ Assert.Null(Movement.Move(c, s, 1, 3, 1, spent, why));+ Assert.True(c.HasPermanentFort(2, 1));+ Assert.Null(Movement.Move(c, s, 1, 2, 1, spent, why));+ Assert.Equal("", s.Units[1].Order);+ Assert.True(c.HasPermanentFort(2, 1));+ }++ // R-COMBAT-002, R-COMBAT-010: preview and resolution use exactly the same ratio; one engagement draws once.+ [Fact]+ public void FortPreviewMatchesImmediateEngagementWithMultipleDefenders()+ {+ var c = Load(biome: "mountains");+ c.MapLocations.Add(new MapLocation { Id = "fixture", Kind = "fort", Q = 3, R = 1 });+ var s = With(c, Of("recruit"), Of("enemy", 2, 3, side: "egypt"), Of("enemy", 3, 3, side: "egypt"));+ var before = s.RngState; var rng = new Rng(before); rng.NextDouble();+ Assert.Equal(25, Combat.Preview(c, s, 1, 3, 1)!.Value.RatioPercent);+ var why = new List<Cause>();+ Assert.Null(Combat.Strike(c, s, 1, 3, 1, new Dictionary<int, int>(), new Dictionary<int, (int Q, int R)>(), why));+ Assert.Equal(rng.State, s.RngState);+ Assert.Contains(why, line => line.Key == WhyKeys.Engagement && line.Args[1] == "25");+ Assert.True(c.HasPermanentFort(3, 1));+ }++ // R-MOVE-001: every missing consumed scalar must be named, with no old-rule fallback.+ [Theory]+ [InlineData("military.move_infantry")]+ [InlineData("military.move_armoured")]+ [InlineData("military.move_road")]+ [InlineData("military.move_rail")]+ [InlineData("military.stack_limit")]+ [InlineData("military.fort_bonus")]+ [InlineData("military.fortify_bonus")]+ [InlineData("military.fortify_turns")]+ public void LoaderRejectsMissingConsumedKey(string key)+ {+ var f = Files();+ f[Gdd03BalanceCatalogue.FileName] = f[Gdd03BalanceCatalogue.FileName].Replace("\"" + key + "\":", "\"unused.fixture\":");+ Assert.Contains(key, Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(f))).Message);+ }++ // R-MOVE-001: the two role columns have fixed shape, and every biome part is required.+ [Theory]+ [InlineData("movement", "basis: Default, values: [1], note: fixture")]+ [InlineData("movement", "basis: Default, values: [1, 1.5], note: fixture")]+ [InlineData("movement", "basis: Deferred, expression: pending, note: fixture")]+ [InlineData("defence_percent", "basis: Default, values: [-1], note: fixture")]+ public void LoaderRejectsMalformedBiomePart(string part, string row)+ {+ var f = Files();+ var yaml = f[Gdd03BalanceCatalogue.FileName];+ var start = yaml.IndexOf(" \"mountains\":", StringComparison.Ordinal);+ var end = yaml.IndexOf(" \"desert\":", start, StringComparison.Ordinal);+ var section = yaml.Substring(start, end - start);+ section = System.Text.RegularExpressions.Regex.Replace(section,+ "(?m)^ \"" + part + "\":\\n(?: .*\\n)*", " \"" + part + "\": { " + row + " }\n");+ f[Gdd03BalanceCatalogue.FileName] = yaml.Substring(0, start) + section + yaml.Substring(end);+ Assert.Contains(part, Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(f))).Message);+ }++ // R-MOVE-001: absent biome rows/parts never fall through to the old move_cost table.+ [Theory]+ [InlineData("mountains", "missing_mountains")]+ [InlineData("movement", "missing_movement")]+ [InlineData("defence_percent", "missing_defence")]+ public void LoaderRejectsMissingBiomeData(string key, string replacement)+ {+ var f = Files();+ f[Gdd03BalanceCatalogue.FileName] = f[Gdd03BalanceCatalogue.FileName].Replace("\"" + key + "\":", "\"" + replacement + "\":");+ Assert.Contains(key, Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(f))).Message);+ }++ // R-COMBAT-010: fort identity follows the effective authoring placement rather than original coordinates.+ [Fact]+ public void FortQueryUsesMapOverridesAndRejectsWaterPlacement()+ {+ var f = Files();+ var fort = Fixture.Files["map/locations_1948.yaml"].Replace("locations:", "")+ .Replace("town_a","fixture_fort").Replace("kind: city","kind: fort").Replace("q: 1","q: 3").Replace("r: 0","r: 1").Replace("managed_city: true","managed_city: false");+ f["map/locations_1948.yaml"] = Fixture.Files["map/locations_1948.yaml"] + fort;+ f[MapOverrides.FileName] = "terrain: []\ncontrol: []\nlocations: [{ id: fixture_fort, hex: { q: 4, r: 1 } }]\n";+ var c = ContentLoader.Load(Fixture.Write(f));+ Assert.False(c.HasPermanentFort(3,1)); Assert.True(c.HasPermanentFort(4,1));+ var state = With(c,Of("recruit",q:3),Of("enemy",2,4,side:"egypt"));+ Assert.Equal(66,Combat.Preview(c,state,1,4,1)!.Value.RatioPercent);+ state.Units[1]=Of("recruit",q:2); state.Units[2]=Of("enemy",2,3,side:"egypt");+ Assert.Equal(100,Combat.Preview(c,state,1,3,1)!.Value.RatioPercent);+ f["map/hexes.json"] = MovementTests.Board((4,1,"sea"));+ var ex = Assert.Throws<ContentException>(()=>ContentLoader.Load(Fixture.Write(f)));+ Assert.Equal(MapOverrides.FileName,ex.File); Assert.Equal("locations[0].hex",ex.Field);+ Assert.Contains("not a land hex",ex.Message); // Existing generic override rejection, not claimed as new fort-specific red.++ }++ // R-ENEMY-002, R-MOVE-001: enemy path progress uses its class allowance and the same execution cost.+ [Fact]+ public void EnemyProgressUsesTheTwoPointInfantryAllowance()+ {+ var c = Load(); var u = Of("enemy", side: "egypt"); var s = With(c, u);+ var target = Movement.Toward(c, s, u, 5, 1);+ Assert.NotNull(target); Assert.Equal((4, 1), target!.Value);+ var spent = new Dictionary<int, int>();+ Assert.Null(Movement.Move(c, s, 1, target.Value.Q, target.Value.R, spent, new List<Cause>(), enemy: true));+ Assert.Equal(2, spent[1]);+ }++ // R-COMBAT-010, R-COMBAT-005: a fort helps defenders only; invalid combat changes no state.+ [Fact]+ public void AttackingFromAFortAddsNothingAndRefusalMutatesNothing()+ {+ var c = Load(); c.MapLocations.Add(new MapLocation { Id = "fixture", Kind = "fort", Q = 2, R = 1 });+ var state = With(c, Of("recruit"), Of("enemy", 2, 3, side: "egypt"));+ Assert.Equal(100, Combat.Preview(c, state, 1, 3, 1)!.Value.RatioPercent);+ var before = state.Hash();+ Assert.NotNull(Combat.Strike(c, state, 1, 5, 1, new Dictionary<int,int>(),new Dictionary<int,(int Q,int R)>(),new List<Cause>()));+ Assert.Equal(before,state.Hash()); Assert.True(c.HasPermanentFort(2,1));+ }++ // R-SAVE-001/002, R-MOVE-001, R-COMBAT-010: authored synthetic content precedes NewGame, actual committed commands replay.+ [Fact]+ public void Gdd03MoveAndFortCombatReplayWithoutAnUnsupportedGoldenPolicy()+ {+ var c=Load(); c.StartingForces.Clear();+ c.StartingForces.Add(new StartingForce { Row="fixture_own",Type="recruit",Side="israel",Strength=6,Q=1,R=1 });+ c.StartingForces.Add(new StartingForce { Row="fixture_enemy",Type="enemy",Side="egypt",Strength=6,Q=3,R=1 });+ c.MapLocations.Add(new MapLocation { Id="fixture_fort",Kind="fort",Q=3,R=1 });+ var g=GameSession.New(c,1,Mode.Historical);+ Assert.Null(g.Commit(new Move(0,2,1))); Assert.Equal(1,Movement.PointsLeft(c,g.Now.State,0,g.Now.Spent));+ Assert.Equal(66,Combat.Preview(c,g.Now.State,0,3,1)!.Value.RatioPercent);+ Assert.Null(g.Commit(new UnitOrder(0,Combat.Attack,3,1)));+ var save=g.Save.Write(); var loaded=GameSession.Load(c,save,out var warnings);+ Assert.Empty(warnings); Assert.Equal(save,loaded.Save.Write()); Assert.Equal(g.Now.State.Hash(),loaded.Now.State.Hash());+ Assert.Equal(g.Now.Why.Select(x=>x.Message),loaded.Now.Why.Select(x=>x.Message));+ Assert.True(c.HasPermanentFort(3,1));+ }++}diff --git a/sim/Statecraft.Sim.Tests/NoShotArmsTests.cs b/sim/Statecraft.Sim.Tests/NoShotArmsTests.csindex 5b808a0e5..11632fc5e 100644--- a/sim/Statecraft.Sim.Tests/NoShotArmsTests.cs+++ b/sim/Statecraft.Sim.Tests/NoShotArmsTests.cs@@ -252,10 +252,10 @@ public class NoShotArmsTests}var before = s.Hash();var cmds = invalid == "spent"- ? new Command[] { new Move(1, 2, 2), new Move(1, 2, 1), new Move(1, 2, 2), cmd }+ ? new Command[] { new Move(1, 2, 2), new Move(1, 2, 1), cmd }: new Command[] { cmd };var r = Simulation.Preview(c, s, cmds);- Assert.Single(r.Rejected);+ Assert.Same(cmd, Assert.Single(r.Rejected).Command);Assert.Equal(0, r.State.Arms);Assert.Equal(s.RngState, r.State.RngState);if (invalid != "spent") Assert.Equal(before, r.State.Hash());diff --git a/sim/Statecraft.Sim/Combat.cs b/sim/Statecraft.Sim/Combat.csindex c93d51c9f..969d46c39 100644--- a/sim/Statecraft.Sim/Combat.cs+++ b/sim/Statecraft.Sim/Combat.cs@@ -100,7 +100,9 @@ namespace Statecraft.Simif (enemy && u.Order == Attack && u.OrderTarget == target) return "That unit already has that order";if (!InReach(c, u, q.Value, r.Value)) return Guns(c, u) ? "That hex is beyond the unit's range" : "That hex is not next to the unit";if (Defenders(s, u, q.Value, r.Value).Count == 0) return "There is no enemy unit on that hex";- if (!enemy && spent != null && Movement.PointsLeft(c, s, unitId, spent) == 0)+ if (!enemy && spent != null && (Gdd03Military.Applies(c) && Guns(c, u)+ ? Movement.AttackPoints(c, u) <= (spent.TryGetValue(unitId, out var used) ? used : 0)+ : Movement.PointsLeft(c, s, unitId, spent) == 0))return "That unit has no movement points left this turn";if (enemy || !SpendsArms(c)) return null; // before Need, so gdd-0.3 never reads a pricevar mvp = c.RulesAt(s.Date).Mvp!;@@ -137,7 +139,7 @@ namespace Statecraft.Simif (u.Order == Orders.Fortify)why.Add(UnitLines.Line(WhyKeys.FortifyLost,$"Unit {unitId} left hex {u.OrderTarget} and is no longer fortified", new[] { u }, u.OrderTarget));- spent[unitId] = Movement.Points(c, attacker);+ spent[unitId] = Movement.AttackPoints(c, attacker);attacked[unitId] = (q!.Value, r!.Value);Engage(c, s, mvp, new List<Unit> { attacker }, Defenders(s, attacker, q.Value, r.Value), q.Value, r.Value, why);return null;@@ -185,6 +187,15 @@ namespace Statecraft.Simstatic int Ratio(Content c, MvpRules mvp, List<Unit> attackers, List<Unit> defenders, int q, int r){long attack = attackers.Sum(x => x.Strength * Factor(c, x)); // in 1/100 of a strength unit+ if (Gdd03Military.Applies(c))+ {+ var biomeBonus = Gdd03Military.Defence(c, c.HexAt(q, r)!.Biome);+ var fortBonus = c.HasPermanentFort(q, r) ? Gdd03Military.Scalar(c, "military.fort_bonus", false) : 0;+ long total = defenders.Sum(x => (long)x.Strength * Factor(c, x) *+ (100L + biomeBonus + fortBonus + (x.Order == Orders.Fortify && x.OrderTarget == Hex(x.Q, x.R)+ ? Gdd03Military.Scalar(c, "military.fortify_bonus", false) : 0)));+ return total == 0 ? int.MaxValue : (int)Math.Min(int.MaxValue, attack * 10_000 / total);+ }var terrain = mvp.CombatTerrainPercent[c.HexAt(q, r)!.Biome]; // a unit stands on land, and the loader requires every land biomelong defence = defenders.Sum(x => x.Strength * Factor(c, x) * Orders.DefencePercent(mvp, x) * terrain); // in 1/1,000,000 of a strength unitreturn defence == 0 ? int.MaxValue : (int)Math.Min(int.MaxValue, attack * 1_000_000 / defence); // 0: no real unit has no strength@@ -349,7 +360,7 @@ namespace Statecraft.Simint q = u.Q + dq, r = u.R + dr;if (!(c.HexAt(q, r) is MapHex hex) || !hex.Land || noEntry.Contains((q, r))) continue;var here = s.Units.Values.Where(x => x.Q == q && x.R == r).ToList();- if (here.Any(x => Player(x) != Player(u)) || here.Count(x => x.Side == u.Side) >= mvp.StackLimit!.Value) continue;+ if (here.Any(x => Player(x) != Player(u)) || here.Count(x => x.Side == u.Side) >= Movement.StackLimit(c, s)) continue;return (q, r);}return null;diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.csindex 372f3763d..aec51c573 100644--- a/sim/Statecraft.Sim/Content.cs+++ b/sim/Statecraft.Sim/Content.cs@@ -1352,6 +1352,9 @@ namespace Statecraft.Simpublic List<SettlementHex> SettlementHexes = new List<SettlementHex>();/// <summary>Named GDD map locations. Presentation metadata only; gameplay roles remain in their owning systems.</summary>public List<MapLocation> MapLocations = new List<MapLocation>();+ /// <summary>R-COMBAT-010: immutable, effective location placement; duplicate markers grant one bonus.</summary>+ public bool HasPermanentFort(int q, int r) => Ruleset == SaveGame.Gdd03Ruleset+ && MapLocations.Any(l => l.Kind == "fort" && l.Q == q && l.R == r);/// <summary>The curated settlement-control targets, in file order (R-CTRL-001).</summary>public List<SettlementTarget> SettlementTargets = new List<SettlementTarget>();/// <summary>The display name of each settlement id (map/settlements_1948.yaml name), for text the player reads.</summary>diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex 834686d30..21828cc23 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -403,6 +403,7 @@ namespace Statecraft.Simc.ProjectKinds = Read<ProjectsFile>(readFile, "projects.yaml").Projects; // design values (Phase 3 PR 4)c.Corridors = Read<CorridorsFile>(readFile, "corridors.yaml").Corridors; // sourced, hexes derived (Phase 4 PR 2)ValidateGdd(c, settlementIds);+ Gdd03Military.Validate(c); // after effective map overrides and role validation, only exact gdd-0.3// The sourced starting forces (Phase 5 PR 4, R-UNIT-006), once the types and people_per_unit are known valid.c.StartingForces = StartingForces.Read(readFile, c);}diff --git a/sim/Statecraft.Sim/Gdd03Military.cs b/sim/Statecraft.Sim/Gdd03Military.csnew file mode 100644index 000000000..8fe10ed89--- /dev/null+++ b/sim/Statecraft.Sim/Gdd03Military.cs@@ -0,0 +1,77 @@+using System;+using System.Linq;++namespace Statecraft.Sim+{+ /// <summary>Only #1708's approved 0.3 consumers. Reads exact catalogue data; never falls back to old balance values.</summary>+ internal static class Gdd03Military+ {+ internal static bool Applies(Content c) => c.Ruleset == SaveGame.Gdd03Ruleset;+ static ContentException Invalid(string key, string reason) =>+ new ContentException(Gdd03BalanceCatalogue.FileName, "values." + key, reason);++ static Gdd03DesignValue Entry(Content c, string key)+ {+ if (c.Gdd03Balance == null || !c.Gdd03Balance.Values.TryGetValue(key, out var value) || value == null)+ throw Invalid(key, "required by gdd-0.3 military runtime");+ if (value.Basis != "Agreed" && value.Basis != "Default") throw Invalid(key, "runtime consumer is blocked while Deferred");+ return value;+ }++ static int Number(Gdd03DesignValue value, string key, int count, int index, bool positive)+ {+ if (value.Values == null || value.Values.Count != count || value.Parts == null || value.Parts.Count != 0+ || !string.IsNullOrEmpty(value.Expression) || (value.Basis != "Agreed" && value.Basis != "Default"))+ throw Invalid(key, FormattableString.Invariant($"requires an Agreed/Default integer list of length {count}"));+ var n = value.Values[index];+ // Bound percent additions and movement/path arithmetic as well as the decimal-to-int conversion.+ if (n != decimal.Truncate(n) || n < (positive ? 1 : 0) || n > int.MaxValue - 100)+ throw Invalid(key, "requires an exact " + (positive ? "positive" : "nonnegative") + " integer below int.MaxValue - 99");+ return (int)n;+ }++ internal static int Scalar(Content c, string key, bool positive = true) => Number(Entry(c, key), key, 1, 0, positive);++ static Gdd03DesignValue Part(Content c, string biome, string part)+ {+ var row = Entry(c, biome);+ if (row.Values == null || row.Values.Count != 0 || !string.IsNullOrEmpty(row.Expression)+ || row.Parts == null || !row.Parts.TryGetValue(part, out var value) || value == null)+ throw Invalid(biome + ".parts." + part, "required biome part");+ return value;+ }++ internal static int Terrain(Content c, string biome, string role)+ {+ int index = role == "infantry" ? 0 : role == "armour" ? 1 : -1;+ if (index < 0) throw Invalid(biome + ".parts.movement", "no approved movement column for role " + role);+ return Number(Part(c, biome, "movement"), biome + ".parts.movement (" + role + ")", 2, index, true);+ }++ internal static int Defence(Content c, string biome) =>+ Number(Part(c, biome, "defence_percent"), biome + ".parts.defence_percent", 1, 0, false);++ internal static void Validate(Content c)+ {+ if (!Applies(c)) return;+ foreach (var key in new[] { "military.move_infantry", "military.move_armoured", "military.move_road", "military.move_rail", "military.stack_limit" })+ Scalar(c, key);+ Scalar(c, "military.fort_bonus", false);+ Scalar(c, "military.fortify_bonus", false);+ if (Scalar(c, "military.fortify_turns") != 1) throw Invalid("military.fortify_turns", "only the existing one-turn settlement is implemented");+ foreach (var biome in new[] { "coastal_plain", "lowland", "valley", "hills", "mountains", "desert" })+ {+ Terrain(c, biome, "infantry"); Terrain(c, biome, "armour"); Defence(c, biome);+ }+ foreach (var water in new[] { "sea", "lake" })+ if (Entry(c, water).Expression != "impassable" || Entry(c, water).Values.Count != 0 || Entry(c, water).Parts.Count != 0)+ throw Invalid(water, "must remain impassable");+ foreach (var t in c.UnitTypes.Where(t => t.Side != ""))+ if (t.Class != "infantry" && t.Class != "armour" && t.Class != Combat.ArtilleryClass)+ throw new ContentException("unit_types.yaml", t.Id + ".class", "no gdd-0.3 movement mapping for role " + t.Class);+ foreach (var fort in c.MapLocations.Where(l => l.Kind == "fort"))+ if (!(c.HexAt(fort.Q, fort.R) is MapHex h) || !h.Land)+ throw new ContentException(ContentLoader.MapLocationsFileName, fort.Id, "permanent fort must occupy effective land hex");+ }+ }+}diff --git a/sim/Statecraft.Sim/Movement.cs b/sim/Statecraft.Sim/Movement.csindex a093f8288..34aa898eb 100644--- a/sim/Statecraft.Sim/Movement.cs+++ b/sim/Statecraft.Sim/Movement.cs@@ -27,7 +27,30 @@ namespace Statecraft.Simstatic bool IsEnemy(Unit u) => u.Side != "" && u.Side != PlayerSide;- internal static int Points(Content c, Unit u) => c.UnitTypes.FirstOrDefault(t => t.Id == u.Type)?.MovementPoints ?? 0;+ /// <summary>R-MOVE-001: effective movement allowance, shared by simulation and presentation.+ /// Artillery movement in 0.3 is blocked until its Deferred allowance and terrain column are approved.</summary>+ public static int Allowance(Content c, Unit u)+ {+ var type = c.UnitTypes.FirstOrDefault(t => t.Id == u.Type);+ if (type == null) return 0;+ if (!Gdd03Military.Applies(c) || type.Side == "") return type.MovementPoints;+ if (type.Class == "infantry") return Gdd03Military.Scalar(c, "military.move_infantry");+ if (type.Class == "armour") return Gdd03Military.Scalar(c, "military.move_armoured");+ return 0; // no fallback to an older identity's number for Deferred/unknown roles+ }++ public const string MissingArtilleryMovement = "Artillery cannot move: the gdd-0.3 artillery movement allowance is not specified.";+ public static bool MovementDeferred(Content c, Unit u) => Gdd03Military.Applies(c)+ && c.UnitTypes.FirstOrDefault(t => t.Id == u.Type)?.Class == Combat.ArtilleryClass;+ /// <summary>Existing action budget, including artillery fire; not a new movement allowance.</summary>+ public static int ActionsLeft(Content c, GameState s, int id, IReadOnlyDictionary<int, int> spent) =>+ s.Units.TryGetValue(id, out var u) ? Math.Max(0, AttackPoints(c, u) - (spent.TryGetValue(id, out var used) ? used : 0)) : 0;+ internal static int Points(Content c, Unit u) => Allowance(c, u);++ // #1708 does not adopt an artillery allowance or redesign #1706's existing fire/shot accounting.+ internal static int AttackPoints(Content c, Unit u) => Gdd03Military.Applies(c)+ && c.UnitTypes.FirstOrDefault(t => t.Id == u.Type)?.Class == Combat.ArtilleryClass+ ? c.UnitTypes.First(t => t.Id == u.Type).MovementPoints : Points(c, u);/// <summary>The hexes unit <paramref name="unitId"/> can move to this turn, each with its path's cost, in (q, r) order:/// what Move accepts on a turn the unit has not moved yet (R-MOVE-001 to R-MOVE-005). Empty for an unknown unit, an@@ -118,6 +141,7 @@ namespace Statecraft.Simif (q == null || r == null) return "A route names a hex";if (!s.Units.TryGetValue(unitId, out var u)) return "There is no such unit";if (IsEnemy(u)) return "That unit is not yours";+ if (MovementDeferred(c, u)) return MissingArtilleryMovement;if (Points(c, u) == 0) return "That unit cannot move";if (u.Q == q && u.R == r) return "That unit is already there";if (!(c.HexAt(q.Value, r.Value) is MapHex hex) || !hex.Land) return "Units cannot enter water or leave the map";@@ -180,7 +204,7 @@ namespace Statecraft.Sim/// attacked this turn (nothing in <paramref name="spent"/>) and have no order (fortify, fortifying, hold and go-to are/// orders). End turn waits for them (spec 2026-10-23 section 7); Skip is the UI's and not in the sim.</summary>public static IReadOnlyList<int> NeedsOrders(Content c, GameState s, IReadOnlyDictionary<int, int> spent) =>- s.Units.Values.Where(u => u.Side == PlayerSide && Points(c, u) > 0 && u.Order == ""+ s.Units.Values.Where(u => u.Side == PlayerSide && AttackPoints(c, u) > 0 && u.Order == ""&& !(spent.TryGetValue(u.Id, out var used) && used > 0)).Select(u => u.Id).ToList();@@ -193,6 +217,7 @@ namespace Statecraft.Sim{if (!s.Units.TryGetValue(unitId, out var u)) return "There is no such unit";if (IsEnemy(u) != enemy) return "That unit is not yours";+ if (MovementDeferred(c, u)) return MissingArtilleryMovement;var points = Points(c, u);if (points == 0) return "That unit cannot move";if (u.Q == q && u.R == r) return "That unit is already there";@@ -219,10 +244,13 @@ namespace Statecraft.Simreturn null;}+ internal static int StackLimit(Content c, GameState s) => Gdd03Military.Applies(c)+ ? Gdd03Military.Scalar(c, "military.stack_limit") : c.RulesAt(s.Date).Mvp!.StackLimit!.Value;+/// <summary>R-MOVE-003: the refusal when (q, r) already holds stack_limit units of <paramref name="u"/>'s side, else null.</summary>internal static string? Full(Content c, GameState s, Unit u, int q, int r){- var limit = c.RulesAt(s.Date).Mvp!.StackLimit!.Value; // the loader requires it in the GDD loop+ var limit = StackLimit(c, s); // the loader requires it in the GDD loopvar held = s.Units.Values.Count(x => x.Id != u.Id && x.Side == u.Side && x.Q == q && x.R == r);return held >= limit ? FormattableString.Invariant($"That hex already holds {held} units of that side, the most one hex can hold") : null;}@@ -256,11 +284,13 @@ namespace Statecraft.Sim/// <paramref name="r"/>), by the same search as Move, or null when no path leads there or its first step is out of reach.</summary>internal static (int Q, int R)? Toward(Content c, GameState s, Unit u, int q, int r){+ var points = Points(c, u);+ if (points == 0) return null;var (dist, prev) = Search(c, s, u, int.MaxValue);if (!dist.ContainsKey((q, r)) || (u.Q, u.R) == (q, r)) return null;- var points = Points(c, u);var h = (q, r);- while (dist[h] > points) h = prev[h];+ while (dist[h] > points && prev[h] != (u.Q, u.R)) h = prev[h];+ if (dist[h] > points && !Gdd03Military.Applies(c)) h = prev[h];return h == (u.Q, u.R) ? ((int, int)?)null : h;}@@ -275,7 +305,9 @@ namespace Statecraft.Simfor (int i = 0; i < d.Segments.Count; i++)if (w.Segments[i]?.BuiltOn != null)built.Add((new HashSet<(int Q, int R)>(d.Segments[i].Hexes.Select(h => (h[0], h[1]))),- d.Kind == Corridors.Rail ? m.RailMoveCost!.Value : m.RoadMoveCost!.Value));+ Gdd03Military.Applies(c)+ ? Gdd03Military.Scalar(c, d.Kind == Corridors.Rail ? "military.move_rail" : "military.move_road")+ : d.Kind == Corridors.Rail ? m.RailMoveCost!.Value : m.RoadMoveCost!.Value));return built;}@@ -297,6 +329,7 @@ namespace Statecraft.Simvar dist = new Dictionary<(int Q, int R), int> { [(u.Q, u.R)] = 0 };var prev = new Dictionary<(int Q, int R), (int Q, int R)>();var frontier = new SortedSet<(int Cost, int Q, int R)> { (0, u.Q, u.R) };+ var role = c.UnitTypes.FirstOrDefault(t => t.Id == u.Type)?.Class ?? "";while (frontier.Count > 0){var (cost, q, r) = frontier.Min;@@ -305,16 +338,16 @@ namespace Statecraft.Sim{var next = (q + dq, r + dr);if (!(c.HexAt(next.Item1, next.Item2) is MapHex hex) || !hex.Land || blocked.Contains(next)) continue;- var step = costs[hex.Biome];+ var step = Gdd03Military.Applies(c) && role != "" ? Gdd03Military.Terrain(c, hex.Biome, role) : costs[hex.Biome];foreach (var (hexes, kindCost) in built)if (kindCost < step && hexes.Contains((q, r)) && hexes.Contains(next)) step = kindCost;- var total = cost + step;+ var total = Gdd03Military.Applies(c) ? (long)cost + step : cost + step;if (fresh && cost == 0 && total > budget) total = budget; // R-MOVE-001: with full points a unit can always move one hex (OQ-3)if (total > budget || (dist.TryGetValue(next, out var known) && known <= total)) continue;if (dist.ContainsKey(next)) frontier.Remove((known, next.Item1, next.Item2));- dist[next] = total;+ dist[next] = (int)total;prev[next] = (q, r);- frontier.Add((total, next.Item1, next.Item2));+ frontier.Add(((int)total, next.Item1, next.Item2));}}return (dist, prev);diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex 2ac25c37b..d2857f67e 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -364,7 +364,7 @@ namespace Statecraft.Game.UIunitLayer.Show(bridge.Content, bridge.State);unitLayer.Dim(unitLayer.Tokens.Where(t => t.Token.Unit.Side == Statecraft.Game.Map.Units.UnitData.Israel).Where(t => UnitCard.SimUnit(bridge.Content, bridge.State, t.Token) is int id- && Movement.PointsLeft(bridge.Content, bridge.State, id, bridge.Spent) == 0)+ && Movement.ActionsLeft(bridge.Content, bridge.State, id, bridge.Spent) == 0).Select(t => t.Token.Unit.Id).ToList());};bridge.Changed += showUnits;diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.csindex 6488f0e13..17a8a3f3e 100644--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs@@ -643,8 +643,10 @@ namespace Statecraft.Game.UI: bridge.QueuedLike(new UnitOrder(su, Demobilization.SendHome)) != null ? text["unit.send_home_queued"] : "": "";var points = shownUnit is int pu && s.Units.TryGetValue(pu, out var military) && military.Side == Movement.PlayerSide- && c.UnitTypes.FirstOrDefault(t => t.Id == military.Type) is { MovementPoints: > 0 } type- ? text.Format("unit.points", Movement.PointsLeft(c, s, pu, bridge.Spent), type.MovementPoints) : "";+ && Movement.Allowance(c, military) > 0+ ? text.Format("unit.points", Movement.PointsLeft(c, s, pu, bridge.Spent), Movement.Allowance(c, military)) : "";+ if (shownUnit is int gunId && s.Units.TryGetValue(gunId, out var gun) && Movement.MovementDeferred(c, gun))+ points = text["unit.artillery_move_missing"] + "\n" + text[Movement.ActionsLeft(c, s, gunId, bridge.Spent) > 0 ? "unit.fire_ready" : "unit.fire_spent"];var routeLine = shownUnit is int routeUnit ? GoToLine(routeUnit) : "";var lines = new[] { card.Body, points, order, routeLine, standing, reinforceQueued ? text["unit.reinforce_queued"] : "" }.Where(x => x != "");title.text = card.Title; subtitle.text = card.Subtitle; settlements.text = string.Join("\n", lines);diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex 18a37e256..d8a9838a0 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -210,7 +210,7 @@ namespace Statecraft.Game.UI}}- string? Refuse(string reason) { Refused?.Invoke(reason); return reason; }+ string? Refuse(string reason) { if (reason == Movement.MissingArtilleryMovement) reason = text["unit.artillery_move_missing"]; Refused?.Invoke(reason); return reason; }static void Notify(Action? handlers){diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.csindex ceff3fa40..aad91d562 100644--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs@@ -39,7 +39,8 @@ public class InfoPanelLayoutTests/// card and the info panel (with the region lines) on the session given.</summary>static IEnumerator Rendered(int w, int h, GameSession g, System.Action<VisualElement, InfoPanelPresenter> act, System.Action<VisualElement> check,UiText? text = null, bool hebrew = false, System.Action<VisualElement>? settled = null,- System.Func<Statecraft.Game.Map.Units.PlacedToken?>? unit = null, System.Func<int, string?>? unitName = null)+ System.Func<Statecraft.Game.Map.Units.PlacedToken?>? unit = null, System.Func<int, string?>? unitName = null,+ System.Action<IReadOnlyCollection<(int q, int r)>>? showReachable = null){var t = text ?? Text;var rt = new RenderTexture(w, h, 0);@@ -57,7 +58,7 @@ public class InfoPanelLayoutTestsvar bridge = new SimBridge(g, t);var hud = new HudPresenter(root, bridge, t);var card = new EventCardPresenter(root, bridge, t, null);- var info = new InfoPanelPresenter(root, bridge, t, Names(), regions: Regions(), selectedUnit: unit, unitName: unitName);+ var info = new InfoPanelPresenter(root, bridge, t, Names(), regions: Regions(), selectedUnit: unit, unitName: unitName, showReachable: showReachable);try{act(root, info);@@ -582,4 +583,131 @@ public class InfoPanelLayoutTests}, text: text, hebrew: hebrew, unit: () => selected);}+ // R-MOVE-001 (#1708): both locales display the same effective allowance used by sim reachability.+ [UnityTest]+ public IEnumerator Gdd03UnitCardUsesEffectivePointsDenominator([Values(false, true)] bool hebrew)+ {+ var c = ContentLoader.Load(rel =>+ {+ var path = Path.Combine(Paths.Content, rel);+ if (!File.Exists(path)) return null;+ var source = File.ReadAllText(path);+ return rel == "eras.yaml" ? source.Replace("loop: gdd", "loop: gdd, ruleset: gdd-0.3") : source;+ }, Directory.GetFiles(Path.Combine(Paths.Content, "events"), "*.yaml").Select(p => "events/" + Path.GetFileName(p)));+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(hebrew ? UiPaths.StringsHebrew : UiPaths.Strings).text);+ var g = GameSession.New(c, GoldenRun.Seed, Mode.Historical);+ var data = Statecraft.Game.Map.Units.UnitData.Parse(MapFile(Statecraft.Game.Map.Units.UnitData.DefaultFileName));+ var token = Statecraft.Game.Map.Units.UnitRoster.FromState(data, c, g.State, _ => true, (row, a, q, r) => a).Single(t => t.Unit.Id == "golani");+ var id = UnitCard.SimUnit(c, g.State, token.Unit)!.Value;+ Assert.AreEqual(2, Movement.Allowance(c, g.State.Units[id]));+ Statecraft.Game.Map.Units.PlacedToken? selected = new Statecraft.Game.Map.Units.PlacedToken(token, new Statecraft.Game.Map.Units.AnchorSpot(0, 0, 0, 0, false));+ yield return Rendered(1512, 982, g, (root, info) => info.ShowUnit(), root =>+ {+ StringAssert.Contains(text.Format("unit.points", 2, 2), root.Q<Label>("info-settlements").text);+ }, text: text, hebrew: hebrew, unit: () => selected);+ }++ static (GameSession session, Statecraft.Game.Map.Units.PlacedToken token, int id) MilitaryFixture(string role)+ {+ var c = ContentLoader.Load(rel => {+ var path=Path.Combine(Paths.Content,rel); if(!File.Exists(path)) return null;+ var source=File.ReadAllText(path);+ return rel=="eras.yaml" ? source.Replace("loop: gdd","loop: gdd, ruleset: gdd-0.3") : source;+ },Directory.GetFiles(Path.Combine(Paths.Content,"events"),"*.yaml").Select(p=>"events/"+Path.GetFileName(p)));+ var g=GameSession.New(c,GoldenRun.Seed,Mode.Historical);+ var data=Statecraft.Game.Map.Units.UnitData.Parse(MapFile(Statecraft.Game.Map.Units.UnitData.DefaultFileName));+ var token=Statecraft.Game.Map.Units.UnitRoster.FromState(data,c,g.State,_=>true,(row,a,q,r)=>a).Single(t=>t.Unit.Id=="golani");+ var id=UnitCard.SimUnit(c,g.State,token.Unit)!.Value;+ var type=c.UnitTypes.First(t=>t.Side==Movement.PlayerSide && t.Class==role).Id;+ c.Hexes=Enumerable.Range(0,8).SelectMany(q=>Enumerable.Range(0,3).Select(r=>new MapHex { Q=q,R=r,Biome="coastal_plain",Land=true })).ToList();+ c.Corridors.Clear();c.MapLocations.Clear();+ g.State.Units.Clear();g.State.PendingEvents.Clear();+ g.State.Units[id]=new Unit(id,type,0,1,side:Movement.PlayerSide,strength:6);+ g.State.Arms=0;g.State.GameOver=null;+ return (g,new Statecraft.Game.Map.Units.PlacedToken(token,new Statecraft.Game.Map.Units.AnchorSpot(0,0,0,0,false)),id);+ }++ // R-MOVE-001/002: actual committed movement, both role denominators and UI reachability in both locales.+ [UnityTest]+ public IEnumerator Gdd03AfterMoveUsesRemainingRolePointsAndReach([Values(false,true)] bool hebrew,[Values("infantry","armour")] string role)+ {+ var f=MilitaryFixture(role);var g=f.session;var text=UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(hebrew?UiPaths.StringsHebrew:UiPaths.Strings).text);+ var bridge=new SimBridge(g,text);Assert.IsNull(bridge.Queue(new Move(f.id,1,1)));+ var allowance=Movement.Allowance(g.Content,bridge.State.Units[f.id]);+ var reach=InfoPanelPresenter.MoveReach(bridge,f.id)!;+ CollectionAssert.AreEquivalent(Movement.Reachable(g.Content,bridge.State,f.id,bridge.Spent).Keys,reach.Keys);+ Assert.AreEqual((1, 1), (bridge.State.Units[f.id].Q, bridge.State.Units[f.id].R), "the committed Move put the unit on (1,1)");+ // The lit hexes the card hands the map, pinned by hand on the all-plain 8x3 board: one point left (infantry, 2 of 2+ // spent 1) reaches the six neighbours of (1,1); two points left (armour, 3 less 1) reach every hex within two steps.+ var expected = role == "infantry"+ ? new[] { (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1) }+ : new[] { (0, 0), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1) };+ var lit = new List<IReadOnlyCollection<(int q, int r)>>();+ yield return Rendered(1512,982,g,(root,info)=>info.ShowUnit(),root=> {+ StringAssert.Contains(text.Format("unit.points",allowance-1,allowance),root.Q<Label>("info-settlements").text);+ Assert.IsNotEmpty(lit, "the card lit the unit's reach on the map");+ CollectionAssert.AreEquivalent(expected, lit[lit.Count - 1].Select(h => (h.q, h.r)), "the highlighted hexes are the remaining-points reach");+ },text:text,hebrew:hebrew,unit:()=>f.token,showReachable:hexes=>lit.Add(hexes.ToList()));+ }++ // R-MOVE-008/009: standing route ETA is computed on the post-commit state and same effective points.+ [UnityTest]+ public IEnumerator Gdd03RouteEtaUsesCommittedRemainder([Values(false,true)] bool hebrew)+ {+ var f=MilitaryFixture("infantry");var g=f.session;var text=UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(hebrew?UiPaths.StringsHebrew:UiPaths.Strings).text);+ var bridge=new SimBridge(g,text);Assert.IsNull(bridge.Queue(new UnitOrder(f.id,Movement.GoTo,6,1)));+ var route=Movement.Route(g.Content,bridge.State,f.id,6,1,bridge.Spent);Assert.IsNotEmpty(route);+ yield return Rendered(1512,982,g,(root,info)=>info.ShowUnit(),root=> {+ StringAssert.Contains(text.Format("unit.go_to_given",System.Math.Max(0,route[route.Count-1].Turn-1)),root.Q<Label>("info-settlements").text);+ },text:text,hebrew:hebrew,unit:()=>f.token);+ }++ // R-COMBAT-010/002: attack pick renders the sim's additive permanent+settled Fortify odds.+ [UnityTest]+ public IEnumerator Gdd03FortifiedDefenderOddsComeFromTheSim([Values(false,true)] bool hebrew)+ {+ var f=MilitaryFixture("infantry");var g=f.session;var c=g.Content;+ g.State.Units[9000]=new Unit(9000,c.UnitTypes.First(t=>t.Side!=""&&t.Side!=Movement.PlayerSide&&t.Class=="infantry").Id,1,1,side:"egypt",strength:6,order:Orders.Fortify,orderTarget:"1,1");+ c.MapLocations.Add(new MapLocation { Id="fixture_fort",Kind="fort",Q=1,R=1 });+ var text=UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(hebrew?UiPaths.StringsHebrew:UiPaths.Strings).text);+ var expected=Combat.Preview(c,g.State,f.id,1,1)!.Value.RatioPercent;Assert.AreEqual(57,expected);+ yield return Rendered(1512,982,g,(root,info)=>info.ShowUnit(),root=> {+ StringAssert.Contains(text.Format("unit.attack_odds","1,1",expected),root.Q<Label>("info-settlements").text);+ },text:text,hebrew:hebrew,unit:()=>f.token,settled:root=>UiTestKit.Press(root.Q<Button>("info-attack")));+ }++ // R-MOVE-010/#1749: a gun retains its action prompt/fire, but move explicitly refuses without a guessed allowance.+ [UnityTest]+ public IEnumerator Gdd03GunPromptsBeforeFireAndStopsAfterShot([Values(false,true)] bool hebrew)+ {+ var f=MilitaryFixture(Combat.ArtilleryClass);var g=f.session;var c=g.Content;+ g.State.Units[9000]=new Unit(9000,c.UnitTypes.First(t=>t.Side!=""&&t.Side!=Movement.PlayerSide&&t.Class=="infantry").Id,2,1,side:"egypt",strength:6);+ var text=UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(hebrew?UiPaths.StringsHebrew:UiPaths.Strings).text);+ var bridge=new SimBridge(g,text);CollectionAssert.Contains(bridge.NeedsOrders,f.id);+ Assert.Greater(Movement.ActionsLeft(c,bridge.State,f.id,bridge.Spent),0);+ Assert.AreEqual(text["unit.artillery_move_missing"],bridge.Queue(new Move(f.id,1,1)));+ var odds = Combat.Preview(c, bridge.State, f.id, 2, 1)!.Value.RatioPercent;+ InfoPanelPresenter? shown = null;+ // The card's own Fire control: shown and pressed, its pick shows the sim's odds while the movement refusal stays on+ // the card, and the lit target fires through the same pick a map click uses.+ yield return Rendered(1512,982,g,(root,info)=>{ info.ShowUnit(); shown = info; },root=> {+ var card = root.Q<Label>("info-settlements").text;+ Assert.IsTrue(Shown(root.Q<Button>("info-attack")), "the gun's attack control stays visible while movement is blocked");+ Assert.IsFalse(Shown(root.Q<Button>("info-move")), "no Move is offered for the gun");+ StringAssert.Contains(text["unit.fire_ready"], card);+ StringAssert.Contains(text["unit.artillery_move_missing"], card);+ StringAssert.Contains(text.Format("unit.attack_odds", "2,1", odds), card);+ Assert.IsTrue(shown!.PickTarget(2, 1), "the lit enemy hex takes the shot");+ },text:text,hebrew:hebrew,unit:()=>f.token,settled:root=>UiTestKit.Press(root.Q<Button>("info-attack")));+ var after = new SimBridge(g, text);+ CollectionAssert.DoesNotContain(after.NeedsOrders,f.id);+ Assert.AreEqual(0,Movement.ActionsLeft(c,after.State,f.id,after.Spent));Assert.AreEqual(0,after.State.Arms);+ yield return Rendered(1512,982,g,(root,info)=>info.ShowUnit(),root=> {+ var card = root.Q<Label>("info-settlements").text;+ StringAssert.Contains(text["unit.fire_spent"], card);+ StringAssert.Contains(text["unit.artillery_move_missing"], card);+ Assert.IsFalse(Shown(root.Q<Button>("info-attack")), "no second shot is offered");+ },text:text,hebrew:hebrew,unit:()=>f.token);+ }+}diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex f571bf74f..3db75ee76 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -877,3 +877,8 @@ why.cause.event_policy_from: "{0} set to {1} ({2})"why.cause.objective_completed: "{0}: completed, {1} points"why.cause.prisoners_returned: "Prisoners exchanged: {0:N0} prisoners returned to {1}"why.cause.soldiers_returned: "Prisoners exchanged: {0:N0} of our soldiers came home from {1}"++# #1708 artillery action status. Hebrew: native review pending (#564).+unit.artillery_move_missing: "Artillery cannot move yet: its movement points have not been set"+unit.fire_ready: "Fire available"+unit.fire_spent: "Fired this turn"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 83aa40c55..69e25532f 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -976,3 +976,8 @@ why.cause.objective_completed: "היעד הושלם: {0}; ניקוד: {1}"why.cause.prisoners_returned: "חילופי שבויים: {0:N0} שבויים הוחזרו אל {1}"# C166: agent-drafted Hebrew; native review: owner, in chat on 25 Oct 2026 (approved as drafted, C155 HE-V031.md row 33).why.cause.soldiers_returned: "חילופי שבויים: {0:N0} מחיילינו חזרו הביתה מידי {1}"++# #1708 artillery action status. Hebrew: native review pending (#564).+unit.artillery_move_missing: "לא ניתן להזיז ארטילריה עדיין: נקודות התנועה שלה טרם נקבעו"+unit.fire_ready: "ניתן לירות"+unit.fire_spent: "הירי בוצע בתור הזה"