A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
using System.Collections.Generic;
using System.Linq;
using Statecraft.Sim;
/// <summary>content/map/hexes.json and settlement_hexes.yaml as the sim loads them.</summary>
public class MapContentTests
{
[Fact]
public void TheFixtureMapLoads()
{
var c = ContentLoader.Load(Fixture.Write());
Assert.Equal(9, c.Hexes.Count);
Assert.False(c.HexAt(0, 0)!.Land);
Assert.Equal("hills", c.HexAt(2, 1)!.Biome);
Assert.Null(c.HexAt(9, 9));
Assert.Equal(("town_a", 1, 0), (c.SettlementHexes[0].Id, c.SettlementHexes[0].Q, c.SettlementHexes[0].R));
Assert.Equal(("town_a", "city", "must_have"), (c.MapLocations[0].Id, c.MapLocations[0].Kind, c.MapLocations[0].Priority));
}
// #1007, owner 21 October 2026: an outpost is optional map metadata, with no implied gameplay role.
[Fact]
public void AnOptionalOutpostLoadsAsMetadataOnly()
{
var yaml = Fixture.Files["map/locations_1948.yaml"]
.Replace("kind: city", "kind: outpost")
.Replace("priority: must_have", "priority: optional")
.Replace("managed_city: true", "managed_city: false");
var c = ContentLoader.Load(Fixture.Write(new Dictionary<string, string>
{ ["map/locations_1948.yaml"] = yaml }));
var location = Assert.Single(c.MapLocations);
Assert.Equal("outpost", location.Kind);
Assert.Equal("optional", location.Priority);
Assert.True(location.Marker);
Assert.False(location.ManagedCity);
Assert.False(location.DesignatedSite);
Assert.False(location.SettlementControlTarget);
}
[Fact]
public void UmmRashrashIsAnOptionalOutpostWithoutGameplayRoles()
{
var c = ContentLoader.Load(RealContentTests.ContentRoot());
var location = Assert.Single(c.MapLocations, x => x.Id == "umm_rashrash");
Assert.Equal("Umm Rashrash", location.Name);
Assert.Equal("אום רשרש", location.NameHe);
Assert.Equal("outpost", location.Kind);
Assert.Equal("optional", location.Priority);
Assert.True(c.HexAt(location.Q, location.R)!.Land);
Assert.True(location.Marker);
Assert.False(location.ManagedCity);
Assert.False(location.DesignatedSite);
Assert.False(location.SettlementControlTarget);
Assert.Empty(location.StartingControl);
Assert.Null(location.ControlChange);
Assert.DoesNotContain(c.Cities, x => x.Id == location.Id);
Assert.DoesNotContain(c.Sites, x => x.Id == location.Id);
Assert.DoesNotContain(c.SettlementTargets, x => x.Id == location.Id);
Assert.DoesNotContain(c.SettlementHexes, x => x.Id == location.Id);
}
// #1719 (owner, 1 November 2026: "No reception-bed layer (Recommended)"): the named camps are map records only. A
// record adds no city, site, capture target, people or starting control; Rosh HaAyin and Pardes Hanna have no
// sourced camp point yet (research_notes/Map/camps-1948-51.md), so they have no record.
[Theory]
[InlineData("military_tzrifin", "military_camp")]
[InlineData("military_tel_litvinsky", "military_camp")]
[InlineData("military_schneller", "military_camp")]
[InlineData("military_camp_80", "military_camp")]
[InlineData("reception_atlit", "reception_camp")]
[InlineData("reception_beit_lid", "reception_camp")]
public void ANamedCampIsAnOptionalMapRecordOnly(string id, string kind)
{
var c = ContentLoader.Load(RealContentTests.ContentRoot());
var location = Assert.Single(c.MapLocations, x => x.Id == id);
Assert.Equal(kind, location.Kind);
Assert.Equal("optional", location.Priority);
Assert.True(c.HexAt(location.Q, location.R)!.Land);
Assert.True(location.Marker);
Assert.False(location.ManagedCity);
Assert.False(location.DesignatedSite);
Assert.False(location.SettlementControlTarget);
Assert.Empty(location.StartingControl);
Assert.Null(location.ControlChange);
Assert.Empty(location.HistoricalReference);
Assert.Equal("draft", location.Status);
Assert.DoesNotContain(c.Cities, x => x.Id == location.Id);
Assert.DoesNotContain(c.Sites, x => x.Id == location.Id);
Assert.DoesNotContain(c.SettlementTargets, x => x.Id == location.Id);
Assert.DoesNotContain(c.SettlementHexes, x => x.Id == location.Id);
}
[Theory]
[InlineData("kind: city", "kind: citty", "locations[town_a].kind", "unknown kind")]
[InlineData("priority: must_have", "priority: urgent", "locations[town_a].priority", "unknown priority")]
[InlineData("kind: city", "kind: outpost", "locations[town_a].priority", "an outpost must be optional")]
[InlineData(" name_he: עיר א\n", "", "locations[town_a].name_he", "required")]
[InlineData(" name_he_sources: [{ url: 'https://example.org/town-a-he', checked: 2026-10-18 }]\n", "", "locations[town_a].name_he_sources", "needs a source")]
[InlineData(" name_he: עיר א\n", " name_he: עיר א\n name_he_review: checked\n", "locations[town_a].name_he_review", "not agent-checked")]
[InlineData(" name_he: עיר א\n", " name_he: עיר א\n name_he_review: checked\n", "locations[town_a].name_he_review", "an AI-assisted contributor who discloses it")] // #564
[InlineData(" name_he: עיר א\n", " name_he: עיר א\n name_he_review: \"\"\n", "locations[town_a].name_he_review", "not agent-checked")] // #2804 item 9: blank is not a review
[InlineData(" name_he: עיר א\n", " name_he: עיר א\n name_he_review:\n", "locations[town_a].name_he_review", "not agent-checked")]
[InlineData("q: 1", "q: 9", "locations[town_a].q", "not a land hex")]
[InlineData(" sources: [{ url: 'https://example.org/town-a', checked: 2026-10-18 }]\n", "", "locations[town_a].sources", "required")]
[InlineData(" status: draft", " starting_control: arab_forces\n status: draft", "locations[town_a].control_date", "required with starting_control")]
public void AMapLocationRecordIsValidated(string before, string after, string field, string message)
{
var bad = Fixture.Files["map/locations_1948.yaml"].Replace(before, after);
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["map/locations_1948.yaml"] = bad })));
Assert.Equal("map/locations_1948.yaml", ex.File);
Assert.Equal(field, ex.Field);
Assert.Contains(message, ex.Message);
}
[Fact]
public void AMapLocationControlChangeLoads()
{
var yaml = Fixture.Files["map/locations_1948.yaml"].Replace(
" sources: [{ url: 'https://example.org/town-a', checked: 2026-10-18 }]",
" starting_control: israeli\n control_date: 1948-05-15\n control_change: { date: 1948-05-28, control: arab_forces, sources: [{ url: 'https://example.org/control', checked: 2026-10-18 }] }\n sources: [{ url: 'https://example.org/town-a', checked: 2026-10-18 }]");
var location = Assert.Single(ContentLoader.Load(Fixture.Write(new Dictionary<string, string>
{ ["map/locations_1948.yaml"] = yaml })).MapLocations);
Assert.Equal(new System.DateTime(1948, 5, 28), location.ControlChange!.Date);
Assert.Equal("arab_forces", location.ControlChange.Control);
Assert.Equal("https://example.org/control", Assert.Single(location.ControlChange.Sources).Url);
}
[Theory]
[InlineData("1948-05-14", "arab_forces", "[{ url: 'https://example.org/control', checked: 2026-10-18 }]", "date", "must be after control_date")]
[InlineData("1948-05-28", "foreign_army", "[{ url: 'https://example.org/control', checked: 2026-10-18 }]", "control", "unknown control")]
[InlineData("1948-05-28", "arab_forces", "[]", "sources", "required")]
[InlineData("1948-05-28", "arab_forces", "[{ url: 'http://example.org/control', checked: 2026-10-18 }]", "sources[0]", "needs an https url and a checked date")]
public void AnInvalidMapLocationControlChangeIsALoadError(string date, string control, string sources, string field, string message)
{
var yaml = Fixture.Files["map/locations_1948.yaml"].Replace(
" sources: [{ url: 'https://example.org/town-a', checked: 2026-10-18 }]",
$" starting_control: israeli\n control_date: 1948-05-15\n control_change: {{ date: {date}, control: {control}, sources: {sources} }}\n sources: [{{ url: 'https://example.org/town-a', checked: 2026-10-18 }}]");
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string>
{ ["map/locations_1948.yaml"] = yaml })));
Assert.Equal("map/locations_1948.yaml", ex.File);
Assert.Equal($"locations[town_a].control_change.{field}", ex.Field);
Assert.Contains(message, ex.Message);
}
[Fact]
public void AMapLocationControlChangeWithoutAControlDateIsALoadError()
{
var yaml = Fixture.Files["map/locations_1948.yaml"].Replace(
" sources: [{ url: 'https://example.org/town-a', checked: 2026-10-18 }]",
" control_change: { date: 1948-05-28, control: arab_forces, sources: [{ url: 'https://example.org/control', checked: 2026-10-18 }] }\n sources: [{ url: 'https://example.org/town-a', checked: 2026-10-18 }]");
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string>
{ ["map/locations_1948.yaml"] = yaml })));
Assert.Equal("locations[town_a].control_change.date", ex.Field);
Assert.Contains("requires control_date", ex.Message);
}
[Fact]
public void ASettlementOnASeaHexIsALoadError()
{
var bad = Fixture.Files["map/settlement_hexes.yaml"].Replace("q: 1, r: 0", "q: 0, r: 0");
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["map/settlement_hexes.yaml"] = bad })));
Assert.Equal("map/settlement_hexes.yaml", ex.File);
Assert.Equal("settlements[town_a]", ex.Field);
Assert.Contains("hex q=0 r=0 is not a land hex", ex.Message);
}
[Fact]
public void ASettlementOffTheMapIsALoadError()
{
var bad = Fixture.Files["map/settlement_hexes.yaml"].Replace("q: 1, r: 0", "q: 40, r: 0");
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["map/settlement_hexes.yaml"] = bad })));
Assert.Contains("hex q=40 r=0 is not a land hex", ex.Message);
}
[Fact]
public void ADuplicateHexIsALoadError()
{
var bad = Fixture.Files["map/hexes.json"].Replace(@"{""q"":4,""r"":0,", @"{""q"":3,""r"":0,");
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["map/hexes.json"] = bad })));
Assert.Equal("map/hexes.json", ex.File);
Assert.Equal("hexes[q=3,r=0]", ex.Field);
}
[Fact]
public void AnUnknownKeyInHexesJsonIsALoadError()
{
var bad = Fixture.Files["map/hexes.json"].Replace(@"""layout""", @"""layuot""");
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["map/hexes.json"] = bad })));
Assert.Equal("map/hexes.json", ex.File);
}
[Fact]
public void ASettlementHexRowForAnUnknownSettlementIsALoadError()
{
var bad = Fixture.Files["map/settlement_hexes.yaml"] + " - { id: town_b, q: 2, r: 0 }\n";
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["map/settlement_hexes.yaml"] = bad })));
Assert.Equal("map/settlement_hexes.yaml", ex.File);
Assert.Equal("settlements[town_b]", ex.Field);
Assert.Contains("is not in map/settlements_1948.yaml", ex.Message);
}
[Fact]
public void ASettlementWithoutAHexRowIsALoadError()
{
var bad = Fixture.Files["map/settlements_1948.yaml"] + " - { id: town_c, name: Town C, lon: 34.4, lat: 33.3, type: town, founded: 1900, pre_modern: false }\n";
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(new Dictionary<string, string> { ["map/settlements_1948.yaml"] = bad })));
Assert.Equal("map/settlements_1948.yaml", ex.File);
Assert.Equal("settlements[town_c]", ex.Field);
Assert.Contains("has no hex in map/settlement_hexes.yaml", ex.Message);
}
[Fact]
public void AMissingSettlementHexesFileIsALoadError()
{
var dir = Fixture.Write();
var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(rel =>
{
var path = System.IO.Path.Combine(dir, rel);
return rel == "map/settlement_hexes.yaml" || !System.IO.File.Exists(path) ? null : System.IO.File.ReadAllText(path);
}, new string[0]));
Assert.Equal("map/settlement_hexes.yaml", ex.File);
Assert.Contains("missing file", ex.Message);
}
[Fact]
public void TheRealMapHas1419HexesAndEvery1948Settlement()
{
var c = ContentLoader.Load(RealContentTests.ContentRoot());
Assert.Equal(1419, c.Hexes.Count);
Assert.Equal(1118, c.Hexes.Count(h => h.Land));
Assert.Equal(25, c.SettlementHexes.Count);
Assert.Equal(18, c.MapLocations.Count); // ten must_have rows, umm_rashrash (#1007), nirim (#2113) and six named camps (#1719)
var nirim = Assert.Single(c.MapLocations, x => x.Id == "nirim"); // #2113: the 1948 site at Dangur
Assert.Equal((-16, 36, "israeli", new System.DateTime(1948, 5, 15), "optional"), (nirim.Q, nirim.R, nirim.StartingControl, nirim.ControlDate, nirim.Priority));
// The CBS 2024 point of Nir Yitzhak, which stands on the 1948 site (#2111's note), and the row's names and roles.
Assert.Equal(31.23768, nirim.Lat, 4);
Assert.Equal(34.35765, nirim.Lon, 4);
Assert.Equal(("Nirim", "נירים", "agent-checked", "kibbutz"), (nirim.Name, nirim.NameHe, nirim.NameHeReview, nirim.Kind));
Assert.Equal((true, false, false, false), (nirim.Marker, nirim.ManagedCity, nirim.DesignatedSite, nirim.SettlementControlTarget));
Assert.Equal(10, c.MapLocations.Count(x => x.Priority == "must_have"));
Assert.Contains(c.SettlementHexes, s => s.Id == "tiberias");
Assert.Contains(c.MapLocations, x => x.Id == "jerusalem" && x.Name == "West Jerusalem" && x.StartingControl == "israeli");
var eastJerusalem = Assert.Single(c.MapLocations, x => x.Id == "east_jerusalem_old_city");
Assert.Equal("israeli", eastJerusalem.StartingControl);
Assert.Equal(new System.DateTime(1948, 5, 28), eastJerusalem.ControlChange!.Date);
Assert.Equal("arab_forces", eastJerusalem.ControlChange.Control);
}
}