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(map): matte terrain layers, wider biome blend band; plan biome counts

eyalgolanb6de50e1413b
diff --git a/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.md b/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.md
index 941c205f2..5248821cd 100644
--- a/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.md
+++ b/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.md
@@ -4420,7 +4420,9 @@ uv run --quiet --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 -
- Layout: `{"bounds":{lon0,lon1,lat0,lat1},"hex_size_km":5.0,"layout":"pointy","hexes":[{q,r,lon,lat,elev_m,land,biome}]}`.
- Coordinates are Red Blob Games axial, pointy-top. The hex size is the circumradius.
- Projection: x is km east of `lon0`, y is km **south** of `lat1`. Longitude km use the cosine of the bounds' mid-latitude (31.4°).
- - The real grid has **1,102 hexes**: coastal_plain 108, desert 309, hills 143, lake 16, mountains 251, sea 216, valley 59.
+ - The real grid has **1,102 hexes**: coastal_plain 108, desert 337, hills 143, lake 16, mountains 251, sea 216, valley 31.
+ (Task 24's fix round changed these from desert 309 / valley 59: below-sea-level hexes south of the Dead Sea's north tip,
+ lat < 31.77, i.e. the Dead Sea basin and northern Arava, are now desert, not valley.)
- `content/map/settlements_1948.yaml` lists 25 sourced places, in the shape `{settlements:[{id,name,lon,lat,type,founded,pre_modern?,sources:[{url,checked}]}]}`.
- `founded` is `null` with `pre_modern: true` for cities that predate the modern era.
- **Hex ownership rule (for the sim, M3):** a settlement belongs to the hex that contains it, if that hex is land. Otherwise it belongs to the land neighbour whose centre is nearest. This is `hexgrid.settlement_hex`, and Tiberias is the case that needs it. Unity *renders* markers at the sourced lon/lat (Task 25), which is on the real shore.
@@ -4951,7 +4953,8 @@ Expected: `16 passed`.
- [ ] **Step 5: Generate the real grid.**
Run: `uv run --quiet tools/hexgrid.py`
-Expected: `wrote …/content/map/hexes.json: 1102 hexes {'coastal_plain': 108, 'desert': 309, 'hills': 143, 'lake': 16, 'mountains': 251, 'sea': 216, 'valley': 59}`
+Expected: `wrote …/content/map/hexes.json: 1102 hexes {'coastal_plain': 108, 'desert': 337, 'hills': 143, 'lake': 16, 'mountains': 251, 'sea': 216, 'valley': 31}`
+(Originally desert 309 / valley 59; Task 24's fix round added the Dead Sea basin / Arava desert rule, lat < 31.77 below 0 m.)
- [ ] **Step 6: Commit.**
@@ -5480,7 +5483,7 @@ if __name__ == "__main__":
- [ ] **Step 4: Run the tests to verify they pass.**
Run: the shared test command.
-Expected: `44 passed`.
+Expected: `48 passed` (44 when Task 22 first landed; Task 24's fix round added 4 Dead Sea basin / Arava biome cases).
- [ ] **Step 5: Render the image and check the geography by eye.** This is the M2 gate. Do not accept the map data until every item passes.
diff --git a/unity/Assets/Editor/MapMaterials.cs b/unity/Assets/Editor/MapMaterials.cs
index d6d95e361..1278ef59e 100644
--- a/unity/Assets/Editor/MapMaterials.cs
+++ b/unity/Assets/Editor/MapMaterials.cs
@@ -15,12 +15,16 @@ namespace Statecraft.Game.EditorTools
public static void Create()
{
if (!AssetDatabase.IsValidFolder(Folder)) AssetDatabase.CreateFolder("Assets", "Materials");
- Make(TerrainPath, "Universal Render Pipeline/Terrain/Lit", null);
+ var terrain = Make(TerrainPath, "Universal Render Pipeline/Terrain/Lit", null);
+ // Matte defaults. The terrain overrides these from each TerrainLayer (MapBuilder sets 0 there too); URP Terrain/Lit
+ // exposes no specular-highlight or environment-reflection toggle.
+ for (int i = 0; i < 4; i++) { terrain.SetFloat("_Smoothness" + i, 0f); terrain.SetFloat("_Metallic" + i, 0f); }
+ EditorUtility.SetDirty(terrain);
Make(OverlayPath, "Universal Render Pipeline/Unlit", new Color(0.15f, 0.12f, 0.08f, 1f));
AssetDatabase.SaveAssets();
}
- static void Make(string path, string shaderName, Color? colour)
+ static Material Make(string path, string shaderName, Color? colour)
{
var shader = Shader.Find(shaderName); // editor only: fine here
if (shader == null) throw new System.InvalidOperationException($"shader not found: {shaderName}");
@@ -30,6 +34,7 @@ namespace Statecraft.Game.EditorTools
mat.enableInstancing = true;
if (colour.HasValue) mat.color = colour.Value;
EditorUtility.SetDirty(mat);
+ return mat;
}
}
}
diff --git a/unity/Assets/Materials/Terrain.mat b/unity/Assets/Materials/Terrain.mat
index 2a8ad8ce2..16e63b056 100644
--- a/unity/Assets/Materials/Terrain.mat
+++ b/unity/Assets/Materials/Terrain.mat
@@ -93,10 +93,10 @@ Material:
- _Metallic2: 0
- _Metallic3: 0
- _NumLayersCount: 1
- - _Smoothness0: 0.5
- - _Smoothness1: 0.5
- - _Smoothness2: 0.5
- - _Smoothness3: 0.5
+ - _Smoothness0: 0
+ - _Smoothness1: 0
+ - _Smoothness2: 0
+ - _Smoothness3: 0
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
diff --git a/unity/Assets/Scripts/Map/BiomeBlender.cs b/unity/Assets/Scripts/Map/BiomeBlender.cs
index eb5d6572b..570320c96 100644
--- a/unity/Assets/Scripts/Map/BiomeBlender.cs
+++ b/unity/Assets/Scripts/Map/BiomeBlender.cs
@@ -9,7 +9,10 @@ namespace Statecraft.Game.Map
/// edge, beyond the outermost centres) takes the nearest centre's biome. Deterministic: fixed iteration order.</summary>
public sealed class BiomeBlender
{
- public const float BlendRadiusHexes = 1.25f;
+ /// <summary>Falloff radius in hex radii. Neighbouring centres are sqrt(3) = 1.732 radii apart, so 1.72 keeps every
+ /// neighbour out of reach of a hex's own centre (centre weight stays 1) while making the band where both biomes
+ /// have more than 10% weight about 0.6 of a hex width (1.25 gave about 0.24).</summary>
+ public const float BlendRadiusHexes = 1.72f;
readonly Dictionary<(int, int), List<(Vector2 p, int layer)>> grid = new Dictionary<(int, int), List<(Vector2, int)>>();
readonly List<(Vector2 p, int layer)> all = new List<(Vector2, int)>();
diff --git a/unity/Assets/Scripts/Map/MapBuilder.cs b/unity/Assets/Scripts/Map/MapBuilder.cs
index 593c00c0f..0d951a778 100644
--- a/unity/Assets/Scripts/Map/MapBuilder.cs
+++ b/unity/Assets/Scripts/Map/MapBuilder.cs
@@ -76,9 +76,13 @@ namespace Statecraft.Game.Map
var layers = new TerrainLayer[names.Count];
for (int i = 0; i < names.Count; i++)
{
- var tex = assets.Own(new Texture2D(1, 1) { name = "Biome_" + names[i] });
+ var tex = assets.Own(new Texture2D(1, 1, TextureFormat.RGB24, false) { name = "Biome_" + names[i] }); // no alpha: Terrain/Lit would read it as smoothness 1
tex.SetPixel(0, 0, Biome[names[i]]); tex.Apply();
- layers[i] = assets.Own(new TerrainLayer { name = names[i], diffuseTexture = tex, tileSize = new Vector2(BiomeLayerTileSizeM, BiomeLayerTileSizeM) });
+ layers[i] = assets.Own(new TerrainLayer
+ {
+ name = names[i], diffuseTexture = tex, tileSize = new Vector2(BiomeLayerTileSizeM, BiomeLayerTileSizeM),
+ smoothness = 0f, metallic = 0f, // matte: URP Terrain/Lit's default 0.5 smoothness gives white streaks on slopes
+ });
}
data.terrainLayers = layers;
int res = AlphamapResolution; data.alphamapResolution = res;
diff --git a/unity/Assets/Tests/EditMode/MapTests.cs b/unity/Assets/Tests/EditMode/MapTests.cs
index 03034f570..26213afbd 100644
--- a/unity/Assets/Tests/EditMode/MapTests.cs
+++ b/unity/Assets/Tests/EditMode/MapTests.cs
@@ -87,6 +87,32 @@ public class MapTests
Assert.Throws<System.ArgumentNullException>(() => MapBuilder.Build(Paths.StreamingMap, HexesJson, null, null));
}
+ [Test]
+ public void BiomeLayersAreMatte()
+ {
+ var (terrainMat, overlayMat) = Materials();
+ var go = MapBuilder.Build(Paths.StreamingMap, HexesJson, terrainMat, overlayMat);
+ try
+ {
+ var layers = go.GetComponent<Terrain>().terrainData.terrainLayers;
+ Assert.IsNotEmpty(layers);
+ foreach (var l in layers)
+ {
+ Assert.AreEqual(0f, l.smoothness, $"{l.name} smoothness"); Assert.AreEqual(0f, l.metallic, $"{l.name} metallic");
+ // URP Terrain/Lit uses diffuse alpha as smoothness and forces _SmoothnessN to 1 when the diffuse has alpha.
+ Assert.IsFalse(UnityEngine.Experimental.Rendering.GraphicsFormatUtility.HasAlphaChannel(l.diffuseTexture.graphicsFormat),
+ $"{l.name} diffuse must have no alpha channel");
+ }
+ // URP Terrain/Lit has no specular-highlight or environment-reflection toggle; its per-layer defaults are zeroed.
+ for (int i = 0; i < 4; i++)
+ {
+ Assert.AreEqual(0f, terrainMat.GetFloat("_Smoothness" + i), $"Terrain.mat _Smoothness{i}");
+ Assert.AreEqual(0f, terrainMat.GetFloat("_Metallic" + i), $"Terrain.mat _Metallic{i}");
+ }
+ }
+ finally { Object.DestroyImmediate(go); }
+ }
+
// --- Overlay drape (M1, L6) ---
[Test]
@@ -154,6 +180,20 @@ public class MapTests
Assert.AreEqual(0f, w[2], 1e-6);
}
+ [Test]
+ public void BlendBandIsAboutSixTenthsOfAHex()
+ {
+ // Along the line between two neighbouring centres, the band where both biomes have > 10% weight spans ~0.6 hex widths.
+ var b = new BiomeBlender(new[] { Vector2.zero, new Vector2(W, 0) }, new[] { 0, 1 }, S, 2);
+ var w = new float[2]; float lo = float.MaxValue, hi = float.MinValue;
+ for (int i = 0; i <= 1000; i++)
+ {
+ float x = W * i / 1000f; b.Weights(new Vector2(x, 0), w);
+ if (w[0] > 0.1f && w[1] > 0.1f) { lo = Mathf.Min(lo, x); hi = Mathf.Max(hi, x); }
+ }
+ Assert.That((hi - lo) / W, Is.InRange(0.55f, 0.65f));
+ }
+
[Test]
public void BlendWeightsSumToOneEverywhere()
{