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: build the nine regions' hexes from their Mandate sub-districts (Refs #1691) (#2004)

Eyal Golan4c7e04e8e494
diff --git a/changelog.d/gdd-regions-from-subdistricts.md b/changelog.d/gdd-regions-from-subdistricts.md
new file mode 100644
index 000000000..9d8d25afc
--- /dev/null
+++ b/changelog.d/gdd-regions-from-subdistricts.md
@@ -0,0 +1 @@
+- Generate the nine inactive GDD 0.3 design-region hex lists deterministically from their approved Mandate sub-district coverage, while retaining unresolved place bindings for human review.
diff --git a/research_notes/gdd03-regions-capitals-fields.md b/research_notes/gdd03-regions-capitals-fields.md
index df8d6c9d8..862a5020c 100644
--- a/research_notes/gdd03-regions-capitals-fields.md
+++ b/research_notes/gdd03-regions-capitals-fields.md
@@ -34,9 +34,28 @@ The camp is `kiryat_shmuel_camp_haifa`. Only its design `region_binding` becomes
## Schema adaptation and activation
-The follow-up adaptation supplies `research_notes/gdd03-regions.schema-input.yaml`, mapping each region's id, capital, full member-id list, disclaimer, provenance, capital approval, binding status and opening control to the shared geography schema. All nine original `boundary_hexes` are null. The follow-up schema `member_hexes` lists are empty, an explicit absence of geometry. Candidate marker hexes are preserved only in the evidence ledger; they are not substituted for full extents.
+The follow-up adaptation supplies `research_notes/gdd03-regions.schema-input.yaml`, mapping each region's id, capital, full member-id list, disclaimer, provenance, capital approval, binding status and opening control to the shared geography schema. All nine original `boundary_hexes` remain null historical-evidence fields. Under the owner ruling of 30 October 2026, verbatim choice **“C: sub-district, then Amir adjusts”**, `tools/gdd03_region_hexes.py` now derives the design `member_hexes` from each region's `reference_subdistricts`; these are design regions, not a claim that the Mandate sub-districts were Israeli administrative regions. The lists use runtime canonical order (q, then r). Amir's later named-hex adjustments are not anticipated here.
-**All nine rows fail the strict loader** at `player_regions[0].member_hexes` when submitted separately: `galilee`, `valleys`, `haifa_sharon`, `tel_aviv_jaffa`, `central_plain`, `jerusalem_hills`, `northern_hills`, `southern_coast`, `negev`. A combined submission stops at the first row. Later placement/identity/overlap checks are not reached; they are not claimed to pass. Haifa-Sharon's 52 and Jerusalem's 61 named associations do not resolve their boundaries or place bindings.
+The generated partition claims 410 mapped land hexes: Galilee 25; Valleys 22; Haifa-Sharon 31; Tel Aviv-Jaffa 6; Central Plain 14; Jerusalem Hills 68; Northern Hills 36; Southern Coast 18; Negev 190. The other 460 mapped land hexes are the source layer's `outside` sub-district and remain in no player region. No hex is claimed twice. The strict loader now advances from geometry into named-place validation; unresolved place rows below are not silently reassigned.
+
+Owner ruling on farming, 30 October 2026: **“Yes, same region”**. This generator does not change the separately approved opening allocations, capitals or approvals.
+
+### Place-binding exceptions after sub-district generation
+
+The generator derives a place binding only where the evidence supplies one unambiguous sub-district or an already authored candidate hex agrees with the generated region. These exception rows remain unchanged and require human review; absence is not guessed from a nearby place.
+
+| Status | Region | Place(s) | Exception |
+| --- | --- | --- | --- |
+| NEEDS-HUMAN-CHECK | galilee | `acre`, `safed`, `rosh_pinna`, `hanita`, `kiryat_shmona`, `kiryat_shmona_field`, `hula`, `hula_field` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | valleys | `tiberias`, `nazareth`, `degania_alef`, `ein_harod`, `nahalal`, `gesher` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | haifa_sharon | `haifa`, `zikhron_yaakov`, `hadera`, `netanya`, `shaar_haaliyah`, `camp_80` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | tel_aviv_jaffa | `tel_aviv`, `jaffa`, `petah_tikva`, `rosh_haayin_camp` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | central_plain | `lod`, `ramla`, `rishon_lezion`, `rehovot`, `tzrifin` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | jerusalem_hills | `jerusalem`, `shaar_hagai`, `east_jerusalem_old_city`, `beit_shemesh`, `beit_shemesh_field` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | southern_coast | `gaza`, `yad_mordechai`, `negba`, `nir_am`, `iraq_suwaydan_fort`, `ad_halom_bridge`, `mefalsim`, `mefalsim_field`, `nitzanim` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | negev | `beersheba`, `revivim`, `beit_kama`, `beit_kama_field`, `reim`, `reim_field`, `gilat`, `gilat_field`, `umm_rashrash` | No usable sub-district label in the imported place evidence. |
+| NEEDS-HUMAN-CHECK | haifa_sharon | `ijzim` | Imported strings mention both Haifa and Nazareth; the evidence ledger's sourced correction says Haifa, but the generator does not resolve the conflicting strings. |
+| NEEDS-HUMAN-CHECK | central_plain | `tzrifin` | Its authored candidate hex `{-3, 20}` falls in generated Tel Aviv-Jaffa (Jaffa Sub-District), not its retained Central Plain membership. No membership is moved. |
The follow-up adaptation supplies `content/regions.yaml` with an empty `player_regions` list for the existing exact `gdd-0.3` reader; legacy/gdd-0.1 do not read it. This evidence import supplies no runtime content. Regional activation remains off. No incomplete row is loaded, no validator is weakened, and no production initializer changes.
diff --git a/research_notes/gdd03-regions.schema-input.yaml b/research_notes/gdd03-regions.schema-input.yaml
index 2752bd1e1..29565448a 100644
--- a/research_notes/gdd03-regions.schema-input.yaml
+++ b/research_notes/gdd03-regions.schema-input.yaml
@@ -4,7 +4,32 @@ player_regions:
- id: galilee
capital_location: safed
capital_approval: NEEDS-RESEARCH
- member_hexes: []
+ member_hexes:
+ - { q: 7, r: 6 }
+ - { q: 7, r: 7 }
+ - { q: 8, r: 4 }
+ - { q: 8, r: 5 }
+ - { q: 8, r: 6 }
+ - { q: 8, r: 7 }
+ - { q: 8, r: 8 }
+ - { q: 9, r: 4 }
+ - { q: 9, r: 5 }
+ - { q: 9, r: 6 }
+ - { q: 9, r: 7 }
+ - { q: 10, r: 4 }
+ - { q: 10, r: 5 }
+ - { q: 10, r: 6 }
+ - { q: 11, r: 5 }
+ - { q: 11, r: 6 }
+ - { q: 12, r: 4 }
+ - { q: 12, r: 5 }
+ - { q: 12, r: 6 }
+ - { q: 13, r: 4 }
+ - { q: 13, r: 5 }
+ - { q: 14, r: 2 }
+ - { q: 14, r: 3 }
+ - { q: 15, r: 1 }
+ - { q: 15, r: 2 }
member_locations:
- acre
- safed
@@ -55,7 +80,29 @@ player_regions:
- id: valleys
capital_location: tiberias
capital_approval: APPROVED
- member_hexes: []
+ member_hexes:
+ - { q: 6, r: 10 }
+ - { q: 6, r: 11 }
+ - { q: 7, r: 9 }
+ - { q: 7, r: 10 }
+ - { q: 7, r: 11 }
+ - { q: 7, r: 12 }
+ - { q: 8, r: 9 }
+ - { q: 8, r: 10 }
+ - { q: 8, r: 11 }
+ - { q: 8, r: 12 }
+ - { q: 8, r: 13 }
+ - { q: 9, r: 8 }
+ - { q: 9, r: 9 }
+ - { q: 9, r: 10 }
+ - { q: 9, r: 11 }
+ - { q: 9, r: 12 }
+ - { q: 10, r: 7 }
+ - { q: 10, r: 8 }
+ - { q: 10, r: 9 }
+ - { q: 10, r: 10 }
+ - { q: 11, r: 7 }
+ - { q: 12, r: 8 }
member_locations:
- tiberias
- nazareth
@@ -89,7 +136,38 @@ player_regions:
- id: haifa_sharon
capital_location: haifa
capital_approval: NEEDS-RESEARCH
- member_hexes: []
+ member_hexes:
+ - { q: -1, r: 16 }
+ - { q: -1, r: 18 }
+ - { q: 0, r: 15 }
+ - { q: 0, r: 16 }
+ - { q: 0, r: 17 }
+ - { q: 0, r: 18 }
+ - { q: 1, r: 13 }
+ - { q: 1, r: 14 }
+ - { q: 1, r: 15 }
+ - { q: 1, r: 16 }
+ - { q: 1, r: 17 }
+ - { q: 2, r: 12 }
+ - { q: 2, r: 13 }
+ - { q: 2, r: 14 }
+ - { q: 2, r: 15 }
+ - { q: 2, r: 16 }
+ - { q: 3, r: 10 }
+ - { q: 3, r: 11 }
+ - { q: 3, r: 12 }
+ - { q: 3, r: 13 }
+ - { q: 3, r: 14 }
+ - { q: 4, r: 9 }
+ - { q: 4, r: 10 }
+ - { q: 4, r: 11 }
+ - { q: 5, r: 8 }
+ - { q: 5, r: 9 }
+ - { q: 5, r: 10 }
+ - { q: 5, r: 11 }
+ - { q: 6, r: 8 }
+ - { q: 6, r: 9 }
+ - { q: 7, r: 8 }
member_locations:
- haifa
- zikhron_yaakov
@@ -150,7 +228,13 @@ player_regions:
- id: tel_aviv_jaffa
capital_location: tel_aviv
capital_approval: APPROVED
- member_hexes: []
+ member_hexes:
+ - { q: -4, r: 20 }
+ - { q: -3, r: 19 }
+ - { q: -3, r: 20 }
+ - { q: -2, r: 18 }
+ - { q: -2, r: 19 }
+ - { q: -1, r: 17 }
member_locations:
- tel_aviv
- jaffa
@@ -186,7 +270,21 @@ player_regions:
- id: central_plain
capital_location: rishon_lezion
capital_approval: APPROVED
- member_hexes: []
+ member_hexes:
+ - { q: -5, r: 21 }
+ - { q: -5, r: 22 }
+ - { q: -5, r: 23 }
+ - { q: -4, r: 21 }
+ - { q: -4, r: 22 }
+ - { q: -4, r: 23 }
+ - { q: -3, r: 21 }
+ - { q: -3, r: 22 }
+ - { q: -3, r: 23 }
+ - { q: -2, r: 20 }
+ - { q: -2, r: 21 }
+ - { q: -2, r: 22 }
+ - { q: -1, r: 19 }
+ - { q: -1, r: 20 }
member_locations:
- lod
- ramla
@@ -231,7 +329,75 @@ player_regions:
- id: jerusalem_hills
capital_location: jerusalem
capital_approval: NEEDS-RESEARCH
- member_hexes: []
+ member_hexes:
+ - { q: -7, r: 28 }
+ - { q: -6, r: 26 }
+ - { q: -6, r: 27 }
+ - { q: -6, r: 28 }
+ - { q: -6, r: 29 }
+ - { q: -6, r: 30 }
+ - { q: -5, r: 24 }
+ - { q: -5, r: 25 }
+ - { q: -5, r: 26 }
+ - { q: -5, r: 27 }
+ - { q: -5, r: 28 }
+ - { q: -5, r: 29 }
+ - { q: -5, r: 30 }
+ - { q: -4, r: 24 }
+ - { q: -4, r: 25 }
+ - { q: -4, r: 26 }
+ - { q: -4, r: 27 }
+ - { q: -4, r: 28 }
+ - { q: -4, r: 29 }
+ - { q: -4, r: 30 }
+ - { q: -4, r: 31 }
+ - { q: -3, r: 24 }
+ - { q: -3, r: 25 }
+ - { q: -3, r: 26 }
+ - { q: -3, r: 27 }
+ - { q: -3, r: 28 }
+ - { q: -3, r: 29 }
+ - { q: -3, r: 30 }
+ - { q: -3, r: 31 }
+ - { q: -2, r: 23 }
+ - { q: -2, r: 24 }
+ - { q: -2, r: 25 }
+ - { q: -2, r: 26 }
+ - { q: -2, r: 27 }
+ - { q: -2, r: 28 }
+ - { q: -2, r: 29 }
+ - { q: -2, r: 30 }
+ - { q: -1, r: 21 }
+ - { q: -1, r: 22 }
+ - { q: -1, r: 23 }
+ - { q: -1, r: 24 }
+ - { q: -1, r: 25 }
+ - { q: -1, r: 26 }
+ - { q: -1, r: 27 }
+ - { q: -1, r: 28 }
+ - { q: 0, r: 20 }
+ - { q: 0, r: 21 }
+ - { q: 0, r: 22 }
+ - { q: 0, r: 23 }
+ - { q: 0, r: 24 }
+ - { q: 0, r: 25 }
+ - { q: 0, r: 26 }
+ - { q: 1, r: 19 }
+ - { q: 1, r: 20 }
+ - { q: 1, r: 21 }
+ - { q: 1, r: 22 }
+ - { q: 1, r: 23 }
+ - { q: 1, r: 24 }
+ - { q: 1, r: 25 }
+ - { q: 2, r: 20 }
+ - { q: 2, r: 21 }
+ - { q: 2, r: 22 }
+ - { q: 2, r: 23 }
+ - { q: 3, r: 20 }
+ - { q: 3, r: 21 }
+ - { q: 3, r: 22 }
+ - { q: 3, r: 23 }
+ - { q: 4, r: 21 }
member_locations:
- jerusalem
- hebron
@@ -301,7 +467,43 @@ player_regions:
- id: northern_hills
capital_location: nablus
capital_approval: NEEDS-RESEARCH
- member_hexes: []
+ member_hexes:
+ - { q: 0, r: 19 }
+ - { q: 1, r: 18 }
+ - { q: 2, r: 17 }
+ - { q: 2, r: 18 }
+ - { q: 2, r: 19 }
+ - { q: 3, r: 15 }
+ - { q: 3, r: 16 }
+ - { q: 3, r: 17 }
+ - { q: 3, r: 18 }
+ - { q: 3, r: 19 }
+ - { q: 4, r: 12 }
+ - { q: 4, r: 13 }
+ - { q: 4, r: 14 }
+ - { q: 4, r: 15 }
+ - { q: 4, r: 16 }
+ - { q: 4, r: 17 }
+ - { q: 4, r: 18 }
+ - { q: 4, r: 19 }
+ - { q: 4, r: 20 }
+ - { q: 5, r: 12 }
+ - { q: 5, r: 13 }
+ - { q: 5, r: 14 }
+ - { q: 5, r: 15 }
+ - { q: 5, r: 16 }
+ - { q: 5, r: 17 }
+ - { q: 5, r: 18 }
+ - { q: 5, r: 19 }
+ - { q: 6, r: 12 }
+ - { q: 6, r: 13 }
+ - { q: 6, r: 14 }
+ - { q: 6, r: 15 }
+ - { q: 6, r: 16 }
+ - { q: 6, r: 17 }
+ - { q: 7, r: 13 }
+ - { q: 7, r: 14 }
+ - { q: 7, r: 15 }
member_locations:
- nablus
- tubas
@@ -346,7 +548,25 @@ player_regions:
- id: southern_coast
capital_location: gaza
capital_approval: NEEDS-RESEARCH
- member_hexes: []
+ member_hexes:
+ - { q: -15, r: 31 }
+ - { q: -14, r: 30 }
+ - { q: -13, r: 29 }
+ - { q: -12, r: 28 }
+ - { q: -11, r: 27 }
+ - { q: -11, r: 28 }
+ - { q: -10, r: 27 }
+ - { q: -10, r: 28 }
+ - { q: -9, r: 26 }
+ - { q: -9, r: 27 }
+ - { q: -8, r: 25 }
+ - { q: -8, r: 26 }
+ - { q: -7, r: 24 }
+ - { q: -7, r: 25 }
+ - { q: -7, r: 26 }
+ - { q: -6, r: 23 }
+ - { q: -6, r: 24 }
+ - { q: -6, r: 25 }
member_locations:
- gaza
- yad_mordechai
@@ -393,7 +613,197 @@ player_regions:
- id: negev
capital_location: beersheba
capital_approval: NEEDS-RESEARCH
- member_hexes: []
+ member_hexes:
+ - { q: -20, r: 56 }
+ - { q: -19, r: 52 }
+ - { q: -19, r: 53 }
+ - { q: -19, r: 54 }
+ - { q: -19, r: 55 }
+ - { q: -18, r: 47 }
+ - { q: -18, r: 48 }
+ - { q: -18, r: 49 }
+ - { q: -18, r: 50 }
+ - { q: -18, r: 51 }
+ - { q: -18, r: 52 }
+ - { q: -18, r: 53 }
+ - { q: -18, r: 54 }
+ - { q: -17, r: 41 }
+ - { q: -17, r: 42 }
+ - { q: -17, r: 43 }
+ - { q: -17, r: 44 }
+ - { q: -17, r: 45 }
+ - { q: -17, r: 46 }
+ - { q: -17, r: 47 }
+ - { q: -17, r: 48 }
+ - { q: -17, r: 49 }
+ - { q: -17, r: 50 }
+ - { q: -17, r: 51 }
+ - { q: -17, r: 52 }
+ - { q: -16, r: 36 }
+ - { q: -16, r: 37 }
+ - { q: -16, r: 38 }
+ - { q: -16, r: 39 }
+ - { q: -16, r: 40 }
+ - { q: -16, r: 41 }
+ - { q: -16, r: 42 }
+ - { q: -16, r: 43 }
+ - { q: -16, r: 44 }
+ - { q: -16, r: 45 }
+ - { q: -16, r: 46 }
+ - { q: -16, r: 47 }
+ - { q: -16, r: 48 }
+ - { q: -16, r: 49 }
+ - { q: -16, r: 50 }
+ - { q: -15, r: 32 }
+ - { q: -15, r: 33 }
+ - { q: -15, r: 34 }
+ - { q: -15, r: 35 }
+ - { q: -15, r: 36 }
+ - { q: -15, r: 37 }
+ - { q: -15, r: 38 }
+ - { q: -15, r: 39 }
+ - { q: -15, r: 40 }
+ - { q: -15, r: 41 }
+ - { q: -15, r: 42 }
+ - { q: -15, r: 43 }
+ - { q: -15, r: 44 }
+ - { q: -15, r: 45 }
+ - { q: -15, r: 46 }
+ - { q: -15, r: 47 }
+ - { q: -15, r: 48 }
+ - { q: -15, r: 49 }
+ - { q: -14, r: 31 }
+ - { q: -14, r: 32 }
+ - { q: -14, r: 33 }
+ - { q: -14, r: 34 }
+ - { q: -14, r: 35 }
+ - { q: -14, r: 36 }
+ - { q: -14, r: 37 }
+ - { q: -14, r: 38 }
+ - { q: -14, r: 39 }
+ - { q: -14, r: 40 }
+ - { q: -14, r: 41 }
+ - { q: -14, r: 42 }
+ - { q: -14, r: 43 }
+ - { q: -14, r: 44 }
+ - { q: -14, r: 45 }
+ - { q: -14, r: 46 }
+ - { q: -14, r: 47 }
+ - { q: -14, r: 48 }
+ - { q: -13, r: 30 }
+ - { q: -13, r: 31 }
+ - { q: -13, r: 32 }
+ - { q: -13, r: 33 }
+ - { q: -13, r: 34 }
+ - { q: -13, r: 35 }
+ - { q: -13, r: 36 }
+ - { q: -13, r: 37 }
+ - { q: -13, r: 38 }
+ - { q: -13, r: 39 }
+ - { q: -13, r: 40 }
+ - { q: -13, r: 41 }
+ - { q: -13, r: 42 }
+ - { q: -13, r: 43 }
+ - { q: -13, r: 44 }
+ - { q: -13, r: 45 }
+ - { q: -13, r: 46 }
+ - { q: -13, r: 47 }
+ - { q: -12, r: 29 }
+ - { q: -12, r: 30 }
+ - { q: -12, r: 31 }
+ - { q: -12, r: 32 }
+ - { q: -12, r: 33 }
+ - { q: -12, r: 34 }
+ - { q: -12, r: 35 }
+ - { q: -12, r: 36 }
+ - { q: -12, r: 37 }
+ - { q: -12, r: 38 }
+ - { q: -12, r: 39 }
+ - { q: -12, r: 40 }
+ - { q: -12, r: 41 }
+ - { q: -12, r: 42 }
+ - { q: -12, r: 43 }
+ - { q: -12, r: 44 }
+ - { q: -12, r: 45 }
+ - { q: -11, r: 29 }
+ - { q: -11, r: 30 }
+ - { q: -11, r: 31 }
+ - { q: -11, r: 32 }
+ - { q: -11, r: 33 }
+ - { q: -11, r: 34 }
+ - { q: -11, r: 35 }
+ - { q: -11, r: 36 }
+ - { q: -11, r: 37 }
+ - { q: -11, r: 38 }
+ - { q: -11, r: 39 }
+ - { q: -11, r: 40 }
+ - { q: -11, r: 41 }
+ - { q: -11, r: 42 }
+ - { q: -11, r: 43 }
+ - { q: -10, r: 29 }
+ - { q: -10, r: 30 }
+ - { q: -10, r: 31 }
+ - { q: -10, r: 32 }
+ - { q: -10, r: 33 }
+ - { q: -10, r: 34 }
+ - { q: -10, r: 35 }
+ - { q: -10, r: 36 }
+ - { q: -10, r: 37 }
+ - { q: -10, r: 38 }
+ - { q: -10, r: 39 }
+ - { q: -10, r: 40 }
+ - { q: -10, r: 41 }
+ - { q: -9, r: 28 }
+ - { q: -9, r: 29 }
+ - { q: -9, r: 30 }
+ - { q: -9, r: 31 }
+ - { q: -9, r: 32 }
+ - { q: -9, r: 33 }
+ - { q: -9, r: 34 }
+ - { q: -9, r: 35 }
+ - { q: -9, r: 36 }
+ - { q: -9, r: 37 }
+ - { q: -9, r: 38 }
+ - { q: -9, r: 39 }
+ - { q: -9, r: 40 }
+ - { q: -8, r: 27 }
+ - { q: -8, r: 28 }
+ - { q: -8, r: 29 }
+ - { q: -8, r: 30 }
+ - { q: -8, r: 31 }
+ - { q: -8, r: 32 }
+ - { q: -8, r: 33 }
+ - { q: -8, r: 34 }
+ - { q: -8, r: 35 }
+ - { q: -8, r: 36 }
+ - { q: -8, r: 37 }
+ - { q: -8, r: 38 }
+ - { q: -8, r: 39 }
+ - { q: -7, r: 27 }
+ - { q: -7, r: 29 }
+ - { q: -7, r: 30 }
+ - { q: -7, r: 31 }
+ - { q: -7, r: 32 }
+ - { q: -7, r: 33 }
+ - { q: -7, r: 34 }
+ - { q: -7, r: 35 }
+ - { q: -7, r: 36 }
+ - { q: -7, r: 37 }
+ - { q: -7, r: 38 }
+ - { q: -6, r: 31 }
+ - { q: -6, r: 32 }
+ - { q: -6, r: 33 }
+ - { q: -6, r: 34 }
+ - { q: -6, r: 35 }
+ - { q: -6, r: 36 }
+ - { q: -5, r: 31 }
+ - { q: -5, r: 32 }
+ - { q: -5, r: 33 }
+ - { q: -5, r: 34 }
+ - { q: -5, r: 35 }
+ - { q: -4, r: 32 }
+ - { q: -4, r: 33 }
+ - { q: -4, r: 34 }
member_locations:
- beersheba
- revivim
diff --git a/sim/Statecraft.Sim.Tests/Gdd03RegionAuthoringTests.cs b/sim/Statecraft.Sim.Tests/Gdd03RegionAuthoringTests.cs
index b66169ee7..b039cef50 100644
--- a/sim/Statecraft.Sim.Tests/Gdd03RegionAuthoringTests.cs
+++ b/sim/Statecraft.Sim.Tests/Gdd03RegionAuthoringTests.cs
@@ -116,6 +116,12 @@ public class Gdd03RegionAuthoringTests
Assert.Equal(9, staged.Length);
Assert.Equal(evidence.Select(r => Text(r, "id")), staged.Select(r => Text(r, "id")));
Assert.Equal(326, staged.Sum(r => Strings(r, "member_locations").Length));
+ var hexCounts = new Dictionary<string, int>(StringComparer.Ordinal)
+ {
+ ["galilee"] = 25, ["valleys"] = 22, ["haifa_sharon"] = 31, ["tel_aviv_jaffa"] = 6,
+ ["central_plain"] = 14, ["jerusalem_hills"] = 68, ["northern_hills"] = 36,
+ ["southern_coast"] = 18, ["negev"] = 190,
+ };
var approved = new[] { "valleys", "tel_aviv_jaffa", "central_plain" };
foreach (var row in staged)
{
@@ -128,9 +134,15 @@ public class Gdd03RegionAuthoringTests
Assert.Equal("NEEDS-RESEARCH", Text(original, "capital_status"));
Assert.Equal(approved.Contains(Text(row, "id")) ? "APPROVED" : "NEEDS-RESEARCH", Text(row, "capital_approval"));
Assert.True(Unknown(Get(original, "boundary_hexes")));
- Assert.Empty(Assert.IsType<YamlSequenceNode>(Get(row, "member_hexes")).Children);
+ var hexes = Assert.IsType<YamlSequenceNode>(Get(row, "member_hexes")).Children
+ .Select(n => Assert.IsType<YamlMappingNode>(n))
+ .Select(h => (Q: int.Parse(Text(h, "q")!, CultureInfo.InvariantCulture),
+ R: int.Parse(Text(h, "r")!, CultureInfo.InvariantCulture))).ToArray();
+ Assert.Equal(hexCounts[Text(row, "id")!], hexes.Length);
+ Assert.Equal(hexes.OrderBy(h => h.Q).ThenBy(h => h.R), hexes);
Assert.Equal("design value, not a historical boundary", Text(row, "design_note"));
}
+ Assert.Equal(410, staged.Sum(r => Assert.IsType<YamlSequenceNode>(Get(r, "member_hexes")).Children.Count));
}
// #1852 review: the imported evidence keeps the owner-approved draft's membership and opening control, identity by
@@ -181,12 +193,12 @@ public class Gdd03RegionAuthoringTests
[InlineData("northern_hills")]
[InlineData("southern_coast")]
[InlineData("negev")]
- public void EveryIncompleteRegionIsRejectedByTheSharedStrictLoader(string id)
+ public void EveryUnresolvedPlaceRosterIsRejectedAfterGeneratedGeometry(string id)
{
var row = Rows(Parse(Staged), "player_regions").Single(r => Text(r, "id") == id);
var error = Assert.Throws<ContentException>(() => PlayerRegionsContentTests.Load(SingleRow(row)));
Assert.Equal("regions.yaml", error.File);
- Assert.Equal("player_regions[0].member_hexes", error.Field);
+ Assert.StartsWith("player_regions[0].member_locations", error.Field, StringComparison.Ordinal);
}
[Fact]
diff --git a/tools/gdd03_region_hexes.py b/tools/gdd03_region_hexes.py
new file mode 100644
index 000000000..df27f58a8
--- /dev/null
+++ b/tools/gdd03_region_hexes.py
@@ -0,0 +1,168 @@
+# /// script
+# requires-python = ">=3.11"
+# dependencies = ["pyyaml==6.0.3"]
+# ///
+"""Fill the GDD 0.3 schema-input member_hexes from its approved Mandate sub-districts.
+
+Only empty ``member_hexes: []`` fields are replaced. All other bytes are retained.
+The report includes unclaimed and multiply claimed map hexes, per-region counts, and
+place rows whose source material cannot supply one unambiguous sub-district.
+
+Usage: uv run tools/gdd03_region_hexes.py [--check]
+"""
+from __future__ import annotations
+
+import argparse
+import re
+import sys
+from collections import defaultdict
+from pathlib import Path
+from typing import Any, Iterable
+
+import yaml12
+
+ROOT = Path(__file__).resolve().parents[1]
+EVIDENCE = ROOT / "research_notes" / "gdd03-regions-capitals-fields.yaml"
+SUBDISTRICTS = ROOT / "content" / "map" / "subdistrict_hexes_1948.yaml"
+TARGET = ROOT / "research_notes" / "gdd03-regions.schema-input.yaml"
+
+
+def memberships(evidence: dict[str, Any], subdistricts: dict[str, Any]):
+ number_to_key = {int(row["id"]): row["key"].casefold() for row in subdistricts["regions"]}
+ owner: dict[str, str] = {}
+ region_order: list[str] = []
+ for region in evidence["regions"]:
+ region_id = region["id"]
+ region_order.append(region_id)
+ for name in region["reference_subdistricts"]:
+ key = name.casefold()
+ if key not in number_to_key.values():
+ raise ValueError(f"unknown sub-district {name!r} in {region_id}")
+ if key in owner:
+ raise ValueError(f"sub-district {name!r} is claimed by {owner[key]} and {region_id}")
+ owner[key] = region_id
+
+ by_region: dict[str, list[tuple[int, int]]] = {region_id: [] for region_id in region_order}
+ claims: dict[tuple[int, int], list[str]] = defaultdict(list)
+ for q, r, number in subdistricts["hexes"]:
+ key = number_to_key[int(number)]
+ if key in owner:
+ region_id = owner[key]
+ by_region[region_id].append((int(q), int(r)))
+ claims[(int(q), int(r))].append(region_id)
+ for values in by_region.values():
+ values.sort() # Runtime canonical order: q, then r (PlayerRegionGeography).
+
+ all_hexes = {(int(q), int(r)) for q, r, _ in subdistricts["hexes"]}
+ unassigned = sorted(all_hexes - set(claims))
+ doubled = sorted((hex_, regions) for hex_, regions in claims.items() if len(regions) > 1)
+ return by_region, unassigned, doubled
+
+
+def _strings(value: Any) -> Iterable[str]:
+ if isinstance(value, str):
+ yield value
+ elif isinstance(value, dict):
+ for child in value.values():
+ yield from _strings(child)
+ elif isinstance(value, list):
+ for child in value:
+ yield from _strings(child)
+
+
+def place_exceptions(evidence: dict[str, Any], subdistricts: dict[str, Any]):
+ names = [row["key"] for row in subdistricts["regions"] if row["key"] != "outside"]
+ patterns = {name: re.compile(rf"\b{re.escape(name)} sub-?district\b", re.IGNORECASE) for name in names}
+ missing: list[tuple[str, str]] = []
+ multiple: list[tuple[str, str, tuple[str, ...]]] = []
+ for region in evidence["regions"]:
+ for member in region["members"]:
+ text = list(_strings(member.get("sources", []))) + list(_strings(member.get("source_records", [])))
+ found = {name for name, pattern in patterns.items() if any(pattern.search(value) for value in text)}
+ if member.get("mandate_subdistrict"):
+ found.add(member["mandate_subdistrict"].casefold())
+ if not found:
+ missing.append((region["id"], member["id"]))
+ elif len(found) > 1:
+ multiple.append((region["id"], member["id"], tuple(sorted(found))))
+ return missing, multiple
+
+
+def placed_member_mismatches(evidence: dict[str, Any], by_region: dict[str, list[tuple[int, int]]]):
+ hex_owner = {hex_: region for region, hexes in by_region.items() for hex_ in hexes}
+ mismatches: list[tuple[str, str, int, int, str | None]] = []
+ for region in evidence["regions"]:
+ for member in region["members"]:
+ q, r = member.get("hex", {}).get("q"), member.get("hex", {}).get("r")
+ if isinstance(q, int) and isinstance(r, int) and hex_owner.get((q, r)) != member["region_id"]:
+ mismatches.append((member["region_id"], member["id"], q, r, hex_owner.get((q, r))))
+ return mismatches
+
+
+def replace_member_hex_fields(text: str, by_region: dict[str, list[tuple[int, int]]]) -> str:
+ lines = text.splitlines(keepends=True)
+ current: str | None = None
+ seen: set[str] = set()
+ out: list[str] = []
+ i = 0
+ while i < len(lines):
+ line = lines[i]
+ match = re.fullmatch(r"- id: ([a-z0-9_]+)\r?\n?", line)
+ if match:
+ current = match.group(1)
+ if re.fullmatch(r" member_hexes:\r?\n?", line): # already populated (e.g. adjusted by hand): keep as is
+ seen.add(current)
+ out.append(line)
+ i += 1
+ elif re.fullmatch(r" member_hexes: \[\]\r?\n?", line):
+ if current not in by_region:
+ raise ValueError(f"member_hexes has no approved region at {current!r}")
+ newline = "\r\n" if line.endswith("\r\n") else "\n"
+ out.append(" member_hexes:" + newline)
+ out.extend(f" - {{ q: {q}, r: {r} }}{newline}" for q, r in by_region[current])
+ seen.add(current)
+ i += 1
+ while i < len(lines) and re.fullmatch(r" - \{ q: -?\d+, r: -?\d+ \}\r?\n?", lines[i]):
+ i += 1
+ else:
+ out.append(line)
+ i += 1
+ missing = set(by_region) - seen
+ if missing:
+ raise ValueError("no member_hexes field for: " + ", ".join(sorted(missing)))
+ return "".join(out)
+
+
+def report(by_region, unassigned, doubled, missing, multiple, mismatches) -> str:
+ lines = [*(f"{region}: {len(hexes)}" for region, hexes in by_region.items()),
+ f"unassigned: {len(unassigned)}", f"double: {len(doubled)}",
+ f"places_without_subdistrict: {len(missing)}", f"places_with_multiple_subdistricts: {len(multiple)}"]
+ for region, place, names in multiple:
+ lines.append(f"NEEDS-HUMAN-CHECK multiple: {region}/{place}: {', '.join(names)}")
+ for region, place, q, r, derived in mismatches:
+ lines.append(f"NEEDS-HUMAN-CHECK hex mismatch: {region}/{place} at {q},{r}: {derived or 'no region'}")
+ return "\n".join(lines)
+
+
+def main(argv: list[str] | None = None) -> int:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--check", action="store_true")
+ args = parser.parse_args(argv)
+ evidence = yaml12.load(EVIDENCE.read_text(encoding="utf-8"))
+ subdistricts = yaml12.load(SUBDISTRICTS.read_text(encoding="utf-8"))
+ by_region, unassigned, doubled = memberships(evidence, subdistricts)
+ missing, multiple = place_exceptions(evidence, subdistricts)
+ mismatches = placed_member_mismatches(evidence, by_region)
+ old = TARGET.read_text(encoding="utf-8")
+ new = replace_member_hex_fields(old, by_region)
+ if new != old:
+ if args.check:
+ print(f"{TARGET.relative_to(ROOT)} needs regeneration", file=sys.stderr)
+ return 1
+ TARGET.write_text(new, encoding="utf-8")
+ print(report(by_region, unassigned, doubled, missing, multiple, mismatches))
+ return 1 if doubled else 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/tools/tests/test_gdd03_region_hexes.py b/tools/tests/test_gdd03_region_hexes.py
new file mode 100644
index 000000000..f60a12d63
--- /dev/null
+++ b/tools/tests/test_gdd03_region_hexes.py
@@ -0,0 +1,72 @@
+import gdd03_region_hexes as regions
+
+
+def sample():
+ evidence = {"regions": [
+ {"id": "north", "reference_subdistricts": ["Acre"], "members": []},
+ {"id": "south", "reference_subdistricts": ["Gaza"], "members": []},
+ ]}
+ subdistricts = {
+ "regions": [{"id": 1, "key": "acre"}, {"id": 2, "key": "gaza"}, {"id": 3, "key": "outside"}],
+ "hexes": [[3, 1, 1], [1, 2, 1], [0, 0, 2], [9, 9, 3]],
+ }
+ return evidence, subdistricts
+
+
+def test_memberships_use_runtime_q_then_r_order_and_report_unassigned():
+ evidence, subdistricts = sample()
+ by_region, unassigned, doubled = regions.memberships(evidence, subdistricts)
+ assert by_region == {"north": [(1, 2), (3, 1)], "south": [(0, 0)]}
+ assert unassigned == [(9, 9)]
+ assert doubled == []
+
+
+def test_replacement_changes_only_empty_member_hex_fields():
+ evidence, subdistricts = sample()
+ by_region, _, _ = regions.memberships(evidence, subdistricts)
+ original = """# retained\nplayer_regions:\n- id: north\n capital_location: a\n member_hexes: []\n sources: [x]\n- id: south\n capital_location: b\n member_hexes: []\n sources: [y]\n"""
+ generated = regions.replace_member_hex_fields(original, by_region)
+ assert generated == """# retained\nplayer_regions:\n- id: north\n capital_location: a\n member_hexes:\n - { q: 1, r: 2 }\n - { q: 3, r: 1 }\n sources: [x]\n- id: south\n capital_location: b\n member_hexes:\n - { q: 0, r: 0 }\n sources: [y]\n"""
+ assert regions.replace_member_hex_fields(generated, by_region) == generated
+
+
+def test_duplicate_subdistrict_claim_is_rejected():
+ evidence, subdistricts = sample()
+ evidence["regions"][1]["reference_subdistricts"] = ["Acre"]
+ try:
+ regions.memberships(evidence, subdistricts)
+ except ValueError as error:
+ assert "claimed by north and south" in str(error)
+ else:
+ raise AssertionError("duplicate sub-district claim was accepted")
+
+
+def test_placed_member_mismatch_is_reported_not_reassigned():
+ evidence, subdistricts = sample()
+ evidence["regions"][0]["members"] = [
+ {"id": "border_place", "region_id": "north", "hex": {"q": 0, "r": 0}},
+ ]
+ by_region, _, _ = regions.memberships(evidence, subdistricts)
+ assert regions.placed_member_mismatches(evidence, by_region) == [
+ ("north", "border_place", 0, 0, "south"),
+ ]
+
+
+def test_an_adjusted_member_hex_list_is_kept_not_regenerated():
+ # Owner ruling C (30 Oct 2026): generated from sub-districts, then Amir adjusts; a rerun must not undo the adjustment.
+ evidence, subdistricts = sample()
+ by_region, _, _ = regions.memberships(evidence, subdistricts)
+ adjusted = """player_regions:\n- id: north\n member_hexes:\n - { q: 3, r: 1 }\n - { q: 5, r: 5 }\n- id: south\n member_hexes: []\n"""
+ assert regions.replace_member_hex_fields(adjusted, by_region) == (
+ """player_regions:\n- id: north\n member_hexes:\n - { q: 3, r: 1 }\n - { q: 5, r: 5 }\n- id: south\n member_hexes:\n - { q: 0, r: 0 }\n""")
+
+
+def test_an_unknown_reference_subdistrict_is_rejected():
+ evidence, subdistricts = sample()
+ evidence["regions"][0]["reference_subdistricts"] = ["Akko"]
+ try:
+ regions.memberships(evidence, subdistricts)
+ except ValueError as error:
+ assert "Akko" in str(error)
+ else:
+ raise AssertionError("an unknown sub-district name was silently dropped")