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.

fix(tools): exact coast distance, a 1 km2 minimum lake area and real-terrain bake tests

eyalgolan895fcda282fd
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index 4c4928f1e..b34d23d8d 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -65,6 +65,13 @@ Notes:
- Superseded first recording (commit `33fb072`, before the CDP viewport): headless ran at `res=1920x937` and headed at
`res=1728x860`, with a first-pose spread of 0.68 ms (headless) and one headed run that stalled; do not compare with it.
+## Baked textures (Task 5)
+`tools/terrain_bake.py` regenerates `unity/Assets/Textures/Map/terrain_bake.png` and `coast.png` from the committed
+heightmap in about 10 s. The output is deterministic per toolchain: re-running it with the pinned numpy 2.5.3 and
+pillow 12.3.0 on the same machine gives byte-identical PNGs. Another platform may differ in its zlib build or in
+1-ulp `sin`/`arctan` results. Compare decoded pixels (`np.array_equal`), not file bytes; R and B may then differ by
+one level here and there.
+
## Checkpoints
| Task | Name | Images | Owner verdict |
|---|---|---|---|
diff --git a/tools/README.md b/tools/README.md
index e45d20558..a49eb349b 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -17,7 +17,8 @@ Offline data tools (uv inline-script Python). Run from the repo root.
(exit 1) until every sensitive event is `sensitivity-reviewed` (docs/m3-release.md).
- `preview_map.py` renders the geography check image `tools/.cache/map-preview.png`.
- `terrain_bake.py` writes `unity/Assets/Textures/Map/terrain_bake.png` (AO, curvature, sky-view) and `coast.png`
- (signed distance to the shoreline) from the committed heightmap (no network). Re-run it whenever the heightmap changes.
+ (exact signed Euclidean distance to the shoreline; lakes under 1 km2 count as land) from the committed heightmap (no
+ network). Re-run it whenever the heightmap changes; its PNG bytes are reproducible only on the same toolchain.
- `art_compare.py` puts screenshots next to the promo image of their pose, writes deuteranopia and protanopia copies and
logs rough colour numbers; `art_checkpoint.sh [--no-build] <name>` builds WebGL, takes the screenshots
(`web_check.py --shots`) and runs it (docs/visual-v1.md).
@@ -36,7 +37,7 @@ Run from the repo root; this installs every pinned dependency (rasterio included
uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q
```
-Expected: `153 passed, 1 skipped` (the skipped one is the headed browser check; add `--headed` and `--with websockets==15.0.1` to run it). Omitting a dependency (e.g. rasterio) silently drops tests or fails collection.
+Expected: `164 passed, 1 skipped` (the skipped one is the headed browser check; add `--headed` and `--with websockets==15.0.1` to run it). Omitting a dependency (e.g. rasterio) silently drops tests or fails collection.
## Required attribution (Copernicus DEM licence, modified data)
diff --git a/tools/terrain_bake.py b/tools/terrain_bake.py
index b33dd0667..870a66ed0 100644
--- a/tools/terrain_bake.py
+++ b/tools/terrain_bake.py
@@ -9,13 +9,16 @@ Reads unity/Assets/StreamingAssets/map/heightmap.r16 + heightmap.json; writes, 2
unity/Assets/Textures/Map/terrain_bake.png RGB8: R ambient occlusion (horizon search to AO_RADIUS_M; 1 = open),
G curvature (0.5 flat, > 0.5 convex), B sky-view factor (horizon search to SKY_RADIUS_M)
unity/Assets/Textures/Map/coast.png L8: 0.5 + d / (2 COAST_RANGE_M), clamped; d = signed distance (m) to the
- nearest shoreline, < 0 in water (open sea: |elevation| <= SEA_EPS_M and connected to the map's border; lakes: flat
- water below LAKE_BELOW_M), the rules tools/hexgrid.py uses for its sea and lake biomes
+ nearest shoreline, < 0 in water (open sea: |elevation| < SEA_EPS_M and connected to the map's border; lakes: flat
+ water below LAKE_BELOW_M covering at least MIN_LAKE_AREA_KM2), the rules tools/hexgrid.py uses for its sea and lake
+ biomes; the area floor drops the Karameh reservoir (0.3 km2, built in the 1990s) and dike slivers between the pans
Heights are multiplied by VERTICAL_EXAGGERATION (MapBuilder.VerticalExaggeration) so the shading matches the relief the
game draws. Texel (j, i) is the mean of heightmap samples j..j+1, i..i+1, so its centre sits at terrain UV (j + 0.5) / 2048.
-Distances use each axis' own sample spacing (about 79 m east-west, 211 m north-south)."""
+Distances are exact Euclidean (a Felzenszwalb-Huttenlocher two-pass transform) with each axis' own sample spacing (about
+79 m east-west, 211 m north-south). The PNG pixels are reproducible; their bytes are identical only on the same toolchain."""
import json
import math
+from collections import deque
from pathlib import Path
import numpy as np
@@ -34,6 +37,7 @@ CURVATURE_SCALE_M = 150.0 # exaggerated metres above or below the local mea
SEA_EPS_M = 0.5
LAKE_BELOW_M = -150.0
LAKE_FLAT_M = 0.25 # largest height range in a 3x3 window that is still a water surface
+MIN_LAKE_AREA_KM2 = 1.0 # smaller flat pools are land (Karameh 0.30 km2; the smallest kept pan is 1.05 km2)
COAST_RANGE_M = 12000.0 # StatecraftMap.hlsl ScCoastRangeM
@@ -117,32 +121,98 @@ def border_connected(candidate: np.ndarray) -> np.ndarray:
return reached
-def lake_mask(elev: np.ndarray) -> np.ndarray:
+def components(mask: np.ndarray) -> list[tuple[np.ndarray, np.ndarray]]:
+ """The 4-connected components of mask, each as (rows, cols), in scan order."""
+ label = np.zeros(mask.shape, dtype=np.int32)
+ h, w = mask.shape
+ out = []
+ for y0, x0 in zip(*np.nonzero(mask)):
+ if label[y0, x0]:
+ continue
+ n = len(out) + 1
+ label[y0, x0] = n
+ queue, ys, xs = deque([(int(y0), int(x0))]), [], []
+ while queue:
+ y, x = queue.popleft()
+ ys.append(y); xs.append(x)
+ for ny, nx in ((y + 1, x), (y - 1, x), (y, x + 1), (y, x - 1)):
+ if 0 <= ny < h and 0 <= nx < w and mask[ny, nx] and not label[ny, nx]:
+ label[ny, nx] = n
+ queue.append((ny, nx))
+ out.append((np.array(ys), np.array(xs)))
+ return out
+
+
+def lake_mask(elev: np.ndarray, dx: float, dy: float) -> np.ndarray:
hi, lo = elev.copy(), elev.copy()
for oy in (-1, 0, 1):
for ox in (-1, 0, 1):
s = shifted(elev, oy, ox)
np.maximum(hi, s, out=hi); np.minimum(lo, s, out=lo)
flat = (elev < LAKE_BELOW_M) & (hi - lo <= LAKE_FLAT_M)
- return grow(grow(shrink(shrink(flat)))) & flat # an opening: specks of flat rift floor drop out
-
-
-def water_mask(elev: np.ndarray) -> np.ndarray:
- return border_connected(np.abs(elev) <= SEA_EPS_M) | lake_mask(elev)
+ opened = grow(grow(shrink(shrink(flat)))) & flat # an opening: specks of flat rift floor drop out
+ lakes = np.zeros_like(opened)
+ for ys, xs in components(opened):
+ if len(ys) * dx * dy / 1e6 >= MIN_LAKE_AREA_KM2:
+ lakes[ys, xs] = True
+ return lakes
+
+
+def water_mask(elev: np.ndarray, dx: float, dy: float) -> np.ndarray:
+ return border_connected(np.abs(elev) < SEA_EPS_M) | lake_mask(elev, dx, dy)
+
+
+def column_distance(target: np.ndarray) -> np.ndarray:
+ """Samples to the nearest target pixel in the same column (inf where the column has none)."""
+ h = target.shape[0]
+ up = np.full(target.shape, np.inf)
+ down = np.full(target.shape, np.inf)
+ run = np.full(target.shape[1], np.inf)
+ for y in range(h):
+ run = np.where(target[y], 0.0, run + 1); up[y] = run
+ run = np.full(target.shape[1], np.inf)
+ for y in range(h - 1, -1, -1):
+ run = np.where(target[y], 0.0, run + 1); down[y] = run
+ return np.minimum(up, down)
+
+
+def lower_envelope(f: np.ndarray, step: float) -> np.ndarray:
+ """Felzenszwalb-Huttenlocher: d[q] = min over p of (step (q - p))^2 + f[p], in O(n); f may hold inf."""
+ n = len(f)
+ finite = np.nonzero(np.isfinite(f))[0]
+ if len(finite) == 0:
+ return np.full(n, np.inf)
+ pos = [float(p) * step for p in finite]
+ val = [float(f[p]) for p in finite]
+ v = [0] # indices into pos/val of the parabolas on the envelope
+ z = [-math.inf, math.inf] # their boundaries
+ for k in range(1, len(pos)):
+ while True:
+ j = v[-1]
+ s = ((val[k] + pos[k] * pos[k]) - (val[j] + pos[j] * pos[j])) / (2 * (pos[k] - pos[j]))
+ if s <= z[-2]:
+ v.pop(); z.pop()
+ else:
+ break
+ z[-1] = s
+ v.append(k); z.append(math.inf)
+ out = np.empty(n)
+ k = 0
+ for q in range(n):
+ x = q * step
+ while z[k + 1] < x:
+ k += 1
+ j = v[k]
+ out[q] = (x - pos[j]) ** 2 + val[j]
+ return out
def distance_to(target: np.ndarray, dx: float, dy: float, cap: float) -> np.ndarray:
- """Chamfer distance (m, 8 neighbours, each axis its own spacing) to the nearest target pixel, capped at cap."""
- d = np.where(target, 0.0, cap).astype(np.float32)
- diag = math.hypot(dx, dy)
- moves = [(0, 1, dx), (0, -1, dx), (1, 0, dy), (-1, 0, dy), (1, 1, diag), (1, -1, diag), (-1, 1, diag), (-1, -1, diag)]
- while True:
- new = d.copy()
- for oy, ox, step in moves:
- np.minimum(new, shifted(d, oy, ox) + np.float32(step), out=new)
- if np.array_equal(new, d):
- return d
- d = new
+ """Exact Euclidean distance (m, float64, each axis its own spacing) to the nearest target pixel, capped at cap: the
+ column pass, then the Felzenszwalb-Huttenlocher lower envelope along each row."""
+ g = column_distance(target) * dy
+ d2 = np.stack([lower_envelope(row * row, dx) for row in g])
+ return np.minimum(np.sqrt(d2), cap)
def to_texels(a: np.ndarray) -> np.ndarray:
@@ -161,7 +231,7 @@ def bake(elev: np.ndarray, meta: dict) -> tuple[np.ndarray, np.ndarray]:
dx, dy = spacing_m(meta)
z = elev * np.float32(VERTICAL_EXAGGERATION)
ao, sky, curv = openness(z, dx, dy, AO_RADIUS_M), openness(z, dx, dy, SKY_RADIUS_M), curvature(z, dx, dy)
- water = water_mask(elev)
+ water = water_mask(elev, dx, dy)
signed = np.where(water, -distance_to(~water, dx, dy, COAST_RANGE_M), distance_to(water, dx, dy, COAST_RANGE_M))
rgb = np.stack([to_u8(to_texels(ao)), to_u8(to_texels(curv)), to_u8(to_texels(sky))], axis=-1)
return rgb, encode_coast(to_texels(signed.astype(np.float32)))
diff --git a/tools/tests/test_terrain_bake.py b/tools/tests/test_terrain_bake.py
index 5fe6c0861..3c5488b6e 100644
--- a/tools/tests/test_terrain_bake.py
+++ b/tools/tests/test_terrain_bake.py
@@ -10,6 +10,11 @@ import terrain_bake as tb
ROOT = Path(__file__).resolve().parents[2]
+def png(path: Path) -> Image.Image:
+ with Image.open(path) as im:
+ return im.copy()
+
+
def meta_for(h: int, w: int, dx: float, dy: float) -> dict:
return {"width": w, "height": h, "width_km": (w - 1) * dx / 1000, "length_km": (h - 1) * dy / 1000,
"lon0": 34.2, "lon1": 35.9, "lat0": 29.45, "lat1": 33.35}
@@ -25,8 +30,9 @@ def test_a_pit_sees_less_sky_than_its_rim():
y, x = np.mgrid[0:65, 0:65]
z = (100 + 2.0 * ((x - 32) ** 2 + (y - 32) ** 2)).astype(np.float32) # a bowl: 0 at the centre, ~2 km at the corners
sky = tb.openness(z, 100, 100, 2000)
- assert sky[32, 32] < 0.9
assert sky[32, 32] < sky[0, 0]
+ # every ray from the centre reaches about 20 samples (2 km), where the rim stands 2 r^2 m above it at 100 r m: tan = r / 50
+ assert sky[32, 32] == pytest.approx(1 - np.sin(np.arctan(20 / 50)), abs=0.01)
def test_ridges_are_convex_and_valleys_concave():
@@ -34,13 +40,17 @@ def test_ridges_are_convex_and_valleys_concave():
z = np.tile(500 + 300 * np.cos(2 * np.pi * x / 32), (65, 1)).astype(np.float32) # crests at x = 0, 32, 64
c = tb.curvature(z, 100, 100)
assert c[32, 32] > 0.55 and c[32, 16] < 0.45
+ # the tent (two 13-sample boxes) keeps f^2 of a cosine's amplitude: c = 0.5 +- 300 (1 - f^2) / (2 * 150)
+ f = (1 + 2 * sum(np.cos(2 * np.pi * k / 32) for k in range(1, 7))) / 13
+ assert c[32, 32] == pytest.approx(0.5 + (1 - f * f), abs=1e-3)
+ assert c[32, 16] == pytest.approx(0.5 - (1 - f * f), abs=1e-3)
def test_sea_is_border_connected_zero_and_an_inland_zero_pocket_is_land():
elev = np.full((40, 40), 50.0, dtype=np.float32)
elev[:, :10] = 0.0 # the sea along the west border
elev[19:22, 29:32] = 0.0 # an enclosed 0 m pocket
- water = tb.water_mask(elev)
+ water = tb.water_mask(elev, 1000, 1000)
assert water[:, :10].all()
assert not water[19:22, 29:32].any()
assert not water[:, 10:].any()
@@ -50,7 +60,7 @@ def test_flat_water_below_minus_150_is_a_lake_and_a_slope_is_not():
elev = np.full((40, 40), 300.0, dtype=np.float32)
elev[5:17, 5:17] = -420.0 # the Dead Sea's surface: flat
elev[22:34, 5:17] = (-200.0 - 10.0 * np.arange(12))[None, :] # the rift floor: sloping
- water = tb.water_mask(elev)
+ water = tb.water_mask(elev, 200, 200) # 12 x 12 samples of 200 m: 5.76 km2
assert water[8:14, 8:14].all()
assert not water[22:34, 5:17].any()
@@ -58,7 +68,7 @@ def test_flat_water_below_minus_150_is_a_lake_and_a_slope_is_not():
def test_coast_distance_is_signed_metres_across_a_straight_coast():
elev = np.full((30, 60), 50.0, dtype=np.float32)
elev[:, :20] = 0.0 # sea columns 0..19
- water = tb.water_mask(elev)
+ water = tb.water_mask(elev, 100, 100)
to_water = tb.distance_to(water, 100, 100, 12000)
to_land = tb.distance_to(~water, 100, 100, 12000)
assert to_water[15, 30] == pytest.approx(1100) # 11 columns east of the last sea column
@@ -69,10 +79,63 @@ def test_coast_distance_is_signed_metres_across_a_straight_coast():
def test_distance_uses_each_axis_own_spacing():
elev = np.full((40, 30), 50.0, dtype=np.float32)
elev[:20, :] = 0.0 # sea in the north rows (row 0 = north)
- d = tb.distance_to(tb.water_mask(elev), 79.0, 211.0, 12000)
+ d = tb.distance_to(tb.water_mask(elev, 79.0, 211.0), 79.0, 211.0, 12000)
assert d[25, 15] == pytest.approx(6 * 211.0)
+def test_a_flat_pool_below_minus_150_smaller_than_the_minimum_lake_area_is_land():
+ elev = np.full((60, 60), 300.0, dtype=np.float32)
+ elev[5:45, 5:45] = -420.0 # 40 x 40 samples of 79 x 211 m: 26.7 km2, a lake
+ elev[50:57, 50:57] = -312.0 # 7 x 7: 0.82 km2 (Karameh is 0.30 km2): opened, but under 1 km2
+ water = tb.water_mask(elev, 79.0, 211.0)
+ assert water[10:40, 10:40].all()
+ assert not water[48:60, 48:60].any()
+ assert tb.MIN_LAKE_AREA_KM2 == 1.0
+
+
+def test_sea_is_strictly_within_half_a_metre_as_hexgrid_rules():
+ elev = np.full((20, 20), 50.0, dtype=np.float32)
+ elev[:, :5] = 0.5
+ elev[3:17, 5:8] = 0.49 # off the top and bottom border rows
+ water = tb.water_mask(elev, 100, 100)
+ assert not water[:, :5].any() # 0.5 m is not sea (hexgrid.py: |elevation| < 0.5); the border run is land
+ assert not water[:, 5:8].any() # so the 0.49 m strip is not connected to the border
+ elev[:, :5] = 0.49
+ water = tb.water_mask(elev, 100, 100)
+ assert water[:, :5].all() and water[3:17, 5:8].all()
+
+
+def brute_distance(target: np.ndarray, dx: float, dy: float) -> np.ndarray:
+ ty, tx = np.nonzero(target)
+ y, x = np.mgrid[0:target.shape[0], 0:target.shape[1]]
+ d2 = ((y[..., None] - ty) * dy) ** 2 + ((x[..., None] - tx) * dx) ** 2
+ return np.sqrt(d2.min(axis=-1))
+
+
[email protected]("seed", range(6))
+def test_distance_is_the_exact_euclidean_distance_on_an_anisotropic_grid(seed):
+ rng = np.random.default_rng(seed)
+ h, w = int(rng.integers(5, 40)), int(rng.integers(5, 40))
+ target = rng.random((h, w)) < float(rng.choice([0.01, 0.05, 0.3]))
+ target[rng.integers(h), rng.integers(w)] = True
+ dx, dy = float(rng.uniform(20, 300)), float(rng.uniform(20, 300))
+ got = tb.distance_to(target, dx, dy, 1e9)
+ assert np.allclose(got, brute_distance(target, dx, dy), rtol=0, atol=1e-6)
+ capped = tb.distance_to(target, dx, dy, 500.0)
+ assert np.allclose(capped, np.minimum(brute_distance(target, dx, dy), 500.0), rtol=0, atol=1e-6)
+
+
+def test_distance_from_a_point_is_round_in_metres_in_every_octant():
+ dx, dy = 78.87, 210.56 # the real heightmap's spacing (the chamfer was 22% off at 45 degrees)
+ y, x = np.mgrid[0:61, 0:161]
+ r = np.hypot((x - 80) * dx, (y - 30) * dy)
+ d = tb.distance_to(r == 0, dx, dy, 12000)
+ ring = np.abs(r - 3000) < 110 # the 3 km ring, every octant
+ assert ring.sum() > 50
+ assert np.abs(d[ring] - r[ring]).max() < 1e-6
+ assert np.allclose(d, np.minimum(r, 12000), rtol=0, atol=1e-6)
+
+
def test_texels_average_four_samples_and_coast_encoding_is_centred():
a = np.arange(9, dtype=np.float32).reshape(3, 3)
assert np.array_equal(tb.to_texels(a), np.array([[2, 3], [5, 6]], dtype=np.float32))
@@ -89,13 +152,15 @@ def test_main_writes_both_textures_one_texel_smaller_and_deterministically(tmp_p
np.round((elev - lo) / (hi - lo) * 65535).astype("<u2").tofile(map_dir / "heightmap.r16")
(map_dir / "heightmap.json").write_text(json.dumps({**meta_for(n, n, 79.0, 211.0), "elev_min_m": lo, "elev_max_m": hi}))
tb.main(map_dir, tmp_path / "a"); tb.main(map_dir, tmp_path / "b")
- bake = Image.open(tmp_path / "a" / "terrain_bake.png"); coast = Image.open(tmp_path / "a" / "coast.png")
+ bake = png(tmp_path / "a" / "terrain_bake.png"); coast = png(tmp_path / "a" / "coast.png")
assert (bake.mode, bake.size) == ("RGB", (n - 1, n - 1))
assert (coast.mode, coast.size) == ("L", (n - 1, n - 1))
for name in ("terrain_bake.png", "coast.png"):
assert (tmp_path / "a" / name).read_bytes() == (tmp_path / "b" / name).read_bytes()
c = np.asarray(coast)
assert c[:, :5].max() < 128 and c[:, 12:].min() > 128 # water west, land east
+ # pixels, not bytes, are the reproducible part across toolchains (zlib builds differ; docs/visual-v1.md)
+ assert np.array_equal(np.asarray(png(tmp_path / "b" / "coast.png")), c)
def texel(lon: float, lat: float) -> tuple[int, int]:
@@ -106,12 +171,54 @@ def texel(lon: float, lat: float) -> tuple[int, int]:
def test_the_committed_coast_texture_marks_the_seas_and_lakes():
- c = np.asarray(Image.open(ROOT / "unity/Assets/Textures/Map/coast.png"))
+ c = np.asarray(png(ROOT / "unity/Assets/Textures/Map/coast.png"))
assert c.shape == (2048, 2048)
assert c[texel(34.40, 32.00)] < 64, "the Mediterranean off Tel Aviv, well offshore"
assert c[texel(35.59, 32.82)] < 128, "the Sea of Galilee"
assert c[texel(35.50, 31.50)] < 128, "the Dead Sea"
assert c[texel(34.95, 29.50)] < 128, "the Gulf of Aqaba off Eilat"
assert c[texel(35.21, 31.78)] > 192, "Jerusalem, far inland"
- b = np.asarray(Image.open(ROOT / "unity/Assets/Textures/Map/terrain_bake.png"))
+ assert c[texel(35.41, 31.18)] < 128, "the largest evaporation pan (45 km2) south of the Dead Sea"
+ assert c[texel(35.558, 32.019)] > 192, "the Karameh reservoir (0.3 km2, built in the 1990s) is not a lake"
+ assert c[texel(35.50, 32.50)] > 192, "Beit She'an in the rift (-120 m) is land, far from water"
+ b = np.asarray(png(ROOT / "unity/Assets/Textures/Map/terrain_bake.png"))
assert b.shape == (2048, 2048, 3)
+
+
+def test_the_committed_coast_crosses_one_half_at_the_shoreline():
+ c = np.asarray(png(ROOT / "unity/Assets/Textures/Map/coast.png")).astype(int)
+ for lat in (31.5, 32.0, 32.5, 32.9): # west-east across the Mediterranean shore
+ row, _ = texel(34.2, lat)
+ line = c[row, :texel(35.1, lat)[1]]
+ cross = int(np.argmax(line >= 128)) # the first land-side texel
+ assert cross > 0 and (line[:cross] < 128).all(), lat
+ assert line[cross - 1] >= 124 and line[cross] <= 131, (lat, line[cross - 3:cross + 3]) # within ~300 m of 0.5
+ assert (np.diff(line[cross - 40:cross + 40]) >= 0).all(), lat # monotone through the shore
+
+
+def box(b: np.ndarray, lon0: float, lon1: float, lat0: float, lat1: float) -> np.ndarray:
+ r0, c0 = texel(lon0, lat1)
+ r1, c1 = texel(lon1, lat0)
+ return b[r0:r1, c0:c1]
+
+
+def test_the_committed_bake_shades_real_gorges_ridges_and_plateaus():
+ b = np.asarray(png(ROOT / "unity/Assets/Textures/Map/terrain_bake.png")).astype(np.float64) / 255
+ elev, meta = tb.load_heightmap(ROOT / "unity/Assets/StreamingAssets/map")
+ # the Mujib gorge (Wadi Mujib, about 900 m deep): its thalweg is each column's lowest texel in the box
+ r0, c0 = texel(35.58, 31.50)
+ r1, c1 = texel(35.70, 31.43)
+ floor = r0 + np.argmin(tb.to_texels(elev)[r0:r1, c0:c1], axis=0)
+ gorge = b[floor, np.arange(c0, c1)].mean(axis=0)
+ plateau = box(b, 35.75, 35.85, 31.68, 31.75).reshape(-1, 3).mean(axis=0) # the Madaba plateau, 720-840 m
+ sea = box(b, 34.30, 34.50, 31.90, 32.10).reshape(-1, 3).mean(axis=0) # the open Mediterranean
+ assert gorge[0] < 0.6 and plateau[0] > 0.85 and sea[0] > 0.99, (gorge, plateau) # R: AO
+ assert gorge[1] < 0.2 and abs(sea[1] - 0.5) < 0.01 # G: a hollow; the sea is flat
+ assert gorge[2] < 0.65 and plateau[2] > 0.85 and sea[2] > 0.99 # B: sky-view
+ assert gorge[2] < plateau[2] < sea[2]
+ for lon, lat in ((35.390, 32.687), (35.4097, 32.9997)): # Mount Tabor, Mount Meron
+ r, col = texel(lon, lat)
+ assert b[r - 1:r + 2, col - 1:col + 2, 1].mean() > 0.9, "a summit is convex"
+ judean = box(b, 35.2, 35.4, 31.5, 31.8)[..., 0].mean()
+ coastal = box(b, 34.85, 34.95, 31.9, 32.3)[..., 0].mean()
+ assert judean < 0.8 and judean < coastal - 0.1, "the gullied Judean desert is darker than the coastal plain"
diff --git a/unity/Assets/Textures/Map/coast.png b/unity/Assets/Textures/Map/coast.png
index 04f5b3f0a..1bc717461 100644
Binary files a/unity/Assets/Textures/Map/coast.png and b/unity/Assets/Textures/Map/coast.png differ