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.

feat(map): sourced 1948 settlements and shore placement rule

eyalgolan8b1429fb129b
diff --git a/content/map/settlements_1948.yaml b/content/map/settlements_1948.yaml
new file mode 100644
index 000000000..d204dea17
--- /dev/null
+++ b/content/map/settlements_1948.yaml
@@ -0,0 +1,239 @@
+# Key places that existed in May 1948 (M2 map seed). Coordinates: Wikipedia API prop=coordinates;
+# founding years: the cited article's text. founded: null + pre_modern: true = pre-19th-century city.
+# Naming follows the spec's Israeli-perspective rule.
+settlements:
+- id: jerusalem
+ name: Jerusalem
+ lon: 35.2256
+ lat: 31.7789
+ type: city
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Jerusalem
+ checked: '2026-10-09'
+- id: tel_aviv
+ name: Tel Aviv
+ lon: 34.78
+ lat: 32.08
+ type: city
+ founded: 1909
+ sources:
+ - url: https://en.wikipedia.org/wiki/Tel_Aviv
+ checked: '2026-10-09'
+- id: jaffa
+ name: Jaffa
+ lon: 34.7531
+ lat: 32.0522
+ type: arab_town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Jaffa
+ checked: '2026-10-09'
+- id: haifa
+ name: Haifa
+ lon: 34.9992
+ lat: 32.8192
+ type: city
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Haifa
+ checked: '2026-10-09'
+- id: acre
+ name: Acre
+ lon: 35.0817
+ lat: 32.9278
+ type: arab_town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Acre,_Israel
+ checked: '2026-10-09'
+- id: tiberias
+ name: Tiberias
+ lon: 35.5333
+ lat: 32.7944
+ type: town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Tiberias
+ checked: '2026-10-09'
+- id: safed
+ name: Safed
+ lon: 35.4983
+ lat: 32.9658
+ type: town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Safed
+ checked: '2026-10-09'
+- id: nazareth
+ name: Nazareth
+ lon: 35.3033
+ lat: 32.7019
+ type: arab_town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Nazareth
+ checked: '2026-10-09'
+- id: lod
+ name: Lod
+ lon: 34.8881
+ lat: 31.9519
+ type: arab_town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Lod
+ checked: '2026-10-09'
+- id: ramla
+ name: Ramla
+ lon: 34.8625
+ lat: 31.9275
+ type: arab_town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Ramla
+ checked: '2026-10-09'
+- id: gaza
+ name: Gaza
+ lon: 34.4597
+ lat: 31.5075
+ type: arab_town
+ founded: null
+ pre_modern: true
+ sources:
+ - url: https://en.wikipedia.org/wiki/Gaza_City
+ checked: '2026-10-09'
+- id: beersheba
+ name: Beersheba
+ lon: 34.7867
+ lat: 31.2522
+ type: arab_town
+ founded: 1900
+ sources:
+ - url: https://en.wikipedia.org/wiki/Beersheba
+ checked: '2026-10-09'
+- id: petah_tikva
+ name: Petah Tikva
+ lon: 34.8864
+ lat: 32.0889
+ type: town
+ founded: 1878
+ sources:
+ - url: https://en.wikipedia.org/wiki/Petah_Tikva
+ checked: '2026-10-09'
+- id: rishon_lezion
+ name: Rishon LeZion
+ lon: 34.8
+ lat: 31.95
+ type: town
+ founded: 1882
+ sources:
+ - url: https://en.wikipedia.org/wiki/Rishon_LeZion
+ checked: '2026-10-09'
+- id: zikhron_yaakov
+ name: Zikhron Ya'akov
+ lon: 34.9517
+ lat: 32.5708
+ type: town
+ founded: 1882
+ sources:
+ - url: https://en.wikipedia.org/wiki/Zikhron_Ya'akov
+ checked: '2026-10-09'
+- id: rosh_pinna
+ name: Rosh Pinna
+ lon: 35.5422
+ lat: 32.97
+ type: town
+ founded: 1878
+ sources:
+ - url: https://en.wikipedia.org/wiki/Rosh_Pinna
+ checked: '2026-10-09'
+- id: rehovot
+ name: Rehovot
+ lon: 34.8167
+ lat: 31.8969
+ type: town
+ founded: 1890
+ sources:
+ - url: https://en.wikipedia.org/wiki/Rehovot
+ checked: '2026-10-09'
+- id: hadera
+ name: Hadera
+ lon: 34.9167
+ lat: 32.45
+ type: town
+ founded: 1891
+ sources:
+ - url: https://en.wikipedia.org/wiki/Hadera
+ checked: '2026-10-09'
+- id: netanya
+ name: Netanya
+ lon: 34.8567
+ lat: 32.3286
+ type: town
+ founded: 1929
+ sources:
+ - url: https://en.wikipedia.org/wiki/Netanya
+ checked: '2026-10-09'
+- id: degania_alef
+ name: Degania Alef
+ lon: 35.5747
+ lat: 32.7081
+ type: kibbutz
+ founded: 1910
+ sources:
+ - url: https://en.wikipedia.org/wiki/Degania_Alef
+ checked: '2026-10-09'
+- id: ein_harod
+ name: Ein Harod
+ lon: 35.3908
+ lat: 32.5603
+ type: kibbutz
+ founded: 1921
+ sources:
+ - url: https://en.wikipedia.org/wiki/Ein_Harod
+ checked: '2026-10-09'
+- id: nahalal
+ name: Nahalal
+ lon: 35.1967
+ lat: 32.69
+ type: moshav
+ founded: 1921
+ sources:
+ - url: https://en.wikipedia.org/wiki/Nahalal
+ checked: '2026-10-09'
+- id: hanita
+ name: Hanita
+ lon: 35.1736
+ lat: 33.0875
+ type: kibbutz
+ founded: 1938
+ sources:
+ - url: https://en.wikipedia.org/wiki/Hanita
+ checked: '2026-10-09'
+- id: revivim
+ name: Revivim
+ lon: 34.7211
+ lat: 31.0436
+ type: kibbutz
+ founded: 1943
+ sources:
+ - url: https://en.wikipedia.org/wiki/Revivim
+ checked: '2026-10-09'
+- id: yad_mordechai
+ name: Yad Mordechai
+ lon: 34.5583
+ lat: 31.5886
+ type: kibbutz
+ founded: 1943
+ sources:
+ - url: https://en.wikipedia.org/wiki/Yad_Mordechai
+ checked: '2026-10-09'
diff --git a/tools/hexgrid.py b/tools/hexgrid.py
index ae6715ea2..9240f6ad1 100644
--- a/tools/hexgrid.py
+++ b/tools/hexgrid.py
@@ -30,12 +30,18 @@ MAP_DIR = ROOT / "unity" / "Assets" / "StreamingAssets" / "map"
OUT = ROOT / "content" / "map" / "hexes.json"
HEX_SIZE_KM = 5.0 # circumradius (centre to corner)
SQRT3 = math.sqrt(3)
+NEIGHBOURS = [(1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1)] # axial directions
def km_per_deg_lon(meta: dict) -> float:
return KM_PER_DEG_LON_EQ * math.cos(math.radians((meta["lat0"] + meta["lat1"]) / 2))
+def lonlat_to_km(lon: float, lat: float, b: dict) -> tuple[float, float]:
+ """Map projection used by every tool: x km east of lon0, y km south of lat1."""
+ return (lon - b["lon0"]) * km_per_deg_lon(b), (b["lat1"] - lat) * KM_PER_DEG_LAT
+
+
def hex_center_km(q: int, r: int, size: float) -> tuple[float, float]:
return size * (SQRT3 * q + SQRT3 / 2 * r), size * 1.5 * r
@@ -63,6 +69,21 @@ def water_share(v: np.ndarray) -> float:
return float(np.mean((v < -150) & (np.abs(v - level) < 1.5)))
+def settlement_hex(lon: float, lat: float, grid: dict) -> tuple[int, int]:
+ """Placement rule: the containing hex if it is land, else the land neighbour with the nearest centre
+ (shore towns such as Tiberias). Raises if neither exists, which the content tests turn into a failure."""
+ size = grid["hex_size_km"]
+ x, y = lonlat_to_km(lon, lat, grid["bounds"])
+ (q,), (r,) = point_to_hex(np.array([x]), np.array([y]), size)
+ land = {(h["q"], h["r"]) for h in grid["hexes"] if h["land"]}
+ if (q, r) in land:
+ return q, r
+ options = [(q + dq, r + dr) for dq, dr in NEIGHBOURS if (q + dq, r + dr) in land]
+ if not options:
+ raise ValueError(f"no land hex at or next to ({lon}, {lat})")
+ return min(options, key=lambda c: math.dist(hex_center_km(*c, size), (x, y)))
+
+
def classify(st: dict, lat: float, lon: float) -> str:
if st["sea_share"] >= 0.5:
return "sea"
diff --git a/tools/tests/test_settlements.py b/tools/tests/test_settlements.py
new file mode 100644
index 000000000..534a9fe08
--- /dev/null
+++ b/tools/tests/test_settlements.py
@@ -0,0 +1,40 @@
+"""Checks the committed map content: content/map/settlements_1948.yaml against content/map/hexes.json."""
+import json
+from pathlib import Path
+
+import numpy as np
+import pytest
+import yaml
+
+import hexgrid as hg
+
+ROOT = Path(__file__).resolve().parents[2]
+TYPES = {"city", "town", "kibbutz", "moshav", "arab_town", "village"}
+HEXES = json.loads((ROOT / "content" / "map" / "hexes.json").read_text())
+TOWNS = yaml.safe_load((ROOT / "content" / "map" / "settlements_1948.yaml").read_text())["settlements"]
+BY_QR = {(h["q"], h["r"]): h for h in HEXES["hexes"]}
+
+
+def test_ids_unique_and_fields_valid():
+ assert len({s["id"] for s in TOWNS}) == len(TOWNS) >= 20
+ for s in TOWNS:
+ assert s["type"] in TYPES, s["id"]
+ assert (s["founded"] is None and s.get("pre_modern") is True) or s["founded"] <= 1948, s["id"]
+ assert s["sources"] and all(src["url"].startswith("https://") and src["checked"] for src in s["sources"])
+
+
[email protected]("s", TOWNS, ids=lambda s: s["id"])
+def test_settlement_inside_bounds_on_land_hex(s):
+ b = HEXES["bounds"]
+ assert b["lon0"] <= s["lon"] <= b["lon1"] and b["lat0"] <= s["lat"] <= b["lat1"]
+ q, r = hg.settlement_hex(s["lon"], s["lat"], HEXES)
+ assert BY_QR[(q, r)]["land"], f"{s['id']} placed on {BY_QR[(q, r)]['biome']} hex ({q},{r})"
+
+
+def test_shore_settlement_moves_to_nearest_land_neighbour():
+ tiberias = next(s for s in TOWNS if s["id"] == "tiberias")
+ x, y = hg.lonlat_to_km(tiberias["lon"], tiberias["lat"], HEXES["bounds"])
+ (q0,), (r0,) = hg.point_to_hex(np.array([x]), np.array([y]), HEXES["hex_size_km"])
+ assert BY_QR[(q0, r0)]["biome"] == "lake" # its own hex is mostly Sea of Galilee
+ q, r = hg.settlement_hex(tiberias["lon"], tiberias["lat"], HEXES)
+ assert (q - q0, r - r0) in hg.NEIGHBOURS