A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
sim: the settlement target list and the settlement-control state (R-CTRL-001 to R-CTRL-003; refs #795) (#1077)
Eyal Golan4742b6258c59
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c83db4e29..5276584af 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBexplanation under the bar. English and Hebrew; no rule or number is computed in the UI (refs #1037).- The `displacement` event tag now has an absolute no-gain rule and blocks a shareable build until the event issensitivity-reviewed (R-EFX-007, R-GATE-001; refs #794). No content uses the tag, so no golden moves.+- The settlement target list and the settlement-control state (GDD Phase 6 PR 3): `settlement_targets.yaml` admits+ only sourced `arab_town` rows of `settlements_1948.yaml` and ships empty until a person and the sensitivity review+ have checked its rows. The state is written into the state hash only when set, so no golden moves (R-CTRL-001 to+ R-CTRL-003; refs #795).- The military unit record (GDD Phase 5 PR 2): a unit can hold a side, a strength and a standing order with its target,each written into the state hash only when set, so a halutz hashes as before and no golden moves. `unit_types.yaml`gains Israel's `veteran_soldier` (infantry), `artillery` and `armoured_car` (armour) with a `side` and a `class`; thediff --git a/content/settlement_targets.yaml b/content/settlement_targets.yamlnew file mode 100644index 000000000..864088e27--- /dev/null+++ b/content/settlement_targets.yaml@@ -0,0 +1,6 @@+# GDD Phase 6 settlement-control targets (docs/gdd/settlement-control.md; R-CTRL-001). Owner ruling Q-TGT-1 (a), 18 October+# 2026 (#783): only the `arab_town` rows of map/settlements_1948.yaml that a sourced operation names. Each row:+# { id, q, r, operation, sources: [{ url, checked }], status }+# The list ships empty. Rows come from research_notes/GDD phase 6/settlement-targets.md in a later content PR, after a+# person has checked each one and the sensitivity review is complete (Q-TGT-3).+targets: []diff --git a/docs/gdd/settlement-control.md b/docs/gdd/settlement-control.mdindex c2eeeff80..0fa4fb821 100644--- a/docs/gdd/settlement-control.md+++ b/docs/gdd/settlement-control.md@@ -6,10 +6,10 @@ As the player, I want a captured settlement to present a sober choice between le## Rules-- Only `arab_town` rows of `settlements_1948.yaml` that a sourced operation names may enter the curated target list (planned R-CTRL-001). Jaffa and Gaza require the target research before they can enter it. Every target row is `sensitivity-reviewed`, and an unreviewed row is refused by the release gate (`Q-TGT-1`, `Q-TGT-3`, owner ruling [S3]). **Then decided (owner, 18 Oct 2026, "Only in a what-if"; [#793](https://github.com/eyalgolan/statecraft-israel/issues/793#issuecomment-6254333177)):** Jaffa stays on the target list, but is a target in play only if an alternate-timeline card returns it to Arab control; in the historical course it is Israeli-held from the start and no capture decision is offered [S9].+- Only `arab_town` rows of `settlements_1948.yaml` that a sourced operation names may enter the curated target list (R-CTRL-001). Jaffa and Gaza require the target research before they can enter it. Every target row is `sensitivity-reviewed`, and an unreviewed row is refused by the release gate (`Q-TGT-1`, `Q-TGT-3`, owner ruling [S3]). **Then decided (owner, 18 Oct 2026, "Only in a what-if"; [#793](https://github.com/eyalgolan/statecraft-israel/issues/793#issuecomment-6254333177)):** Jaffa stays on the target list, but is a target in play only if an alternate-timeline card returns it to Arab control; in the historical course it is Israeli-held from the start and no capture decision is offered [S9].- Enemy units may capture the player's localities. The capture changes their state, and every place tied by sources to a dated loss receives a sourced card. A capture that exists only in an alternate timeline also requires researched cards (`Q-TGT-2`; planned R-CTRL-006; owner ruling [S3]).-- Settlement state uses one immutable record per settlement in an ordinal `SortedDictionary<string, SettlementControl>`. It is written to the deterministic hash as `ctrl{...}` only when non-empty, and each field is written only when it differs from its default. `DisplacedByPlayer` is an integer count of places and is written only when non-zero (`Q-TECH-2`, `Q-CAP-2`; planned R-CTRL-002; owner rulings [S3], [S4]).-- Residents and combatants are distinct. The state records only whether a place is inhabited, not a resident count, and only enemy military units on its hex are combatants (`Q-CAP-2`, `Q-CAP-3`; planned R-CTRL-003; owner ruling [S4]).+- Settlement state uses one immutable record per settlement in an ordinal `SortedDictionary<string, SettlementControl>`. It is written to the deterministic hash as `ctrl{...}` only when non-empty, and each field is written only when it differs from its default. `DisplacedByPlayer` is an integer count of places and is written only when non-zero (`Q-TECH-2`, `Q-CAP-2`; R-CTRL-002 for the collection; owner rulings [S3], [S4]).+- Residents and combatants are distinct. The state records only whether a place is inhabited, not a resident count, and only enemy military units on its hex are combatants (`Q-CAP-2`, `Q-CAP-3`; R-CTRL-003; owner ruling [S4]).- A target is captured at turn end when its hex contains no enemy combatant and a player unit holds it (`Q-CAP-1` / `D-F2`; planned R-CTRL-004; owner ruling [S4]).- A capture awaiting a decision remains pending and the player's units stay in place. What happens if that decision is still pending at the MVP's end remains open (`Q-HIST-1`; planned R-CTRL-008; owner ruling [S5]). **Then decided (owner, 18 Oct 2026, "Counts as Raid"; [#797](https://github.com/eyalgolan/statecraft-israel/issues/797#issuecomment-6254333420)):** at the MVP's end the units leave, nothing changes for the residents and the pending capture adds nothing to the score [S10].- Capture outcomes use one `ResolveCapture(settlement, outcome)` command and one Attention-cost key. End-of-occupation outcomes likewise use one `EndOccupation(settlement, outcome)` command. The capture dialog reads its options and cost preview from public simulation helpers and sends the selected command through the existing queue; it holds no rule of its own (`Q-TECH-3`, `Q-TECH-5`; owner ruling [S3]).diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex 5840d2465..6406e8a9f 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -28,6 +28,14 @@ R-LOOP-005: Every balance number of the GDD loop (all of `cities.yaml` and `unitThe ID R-LOOP-003 (the Phase 1 overlay, `MvpSlice.Overlay`) is retired with the overlay at the cutover and is not reused.+## Settlement control++R-CTRL-001: Only a settlement in `settlement_targets.yaml` may be captured. Each target is an `arab_town` row of `map/settlements_1948.yaml` (Q-TGT-1 (a), owner ruling of 18 October 2026), stands on a land hex of `map/hexes.json`, names a sourced operation (each source an https URL with a `checked` date) and carries a review status; any other row is a load error naming file and field. The shipped list is empty until researched rows have a person's check and the sensitivity review (D-F5).++R-CTRL-002: Settlement control is an ordinal `SortedDictionary<string, SettlementControl>`. It is written to the state hash as `ctrl{...}` only when non-empty, in ordinal id order; each record field is written only when it differs from its default (R-LOOP-002).++R-CTRL-003: Residents and combatants are distinct fields. Residents are a state, inhabited or depopulated, not a count (Q-CAP-2 (b)). No rule reads residents as combatants, prisoners, refugee units, labour or a resource; annexation is the one place a later owner-approved rule may say otherwise.+## SavesR-SAVE-001: A save names the ruleset it was played under (`ruleset legacy` or `ruleset gdd-0.1`, save schema 2). A game refuses a save made under another ruleset. A schema 1 save has no ruleset line and is legacy, so the GDD game refuses it as made under earlier rules. The refusal carries a code (`older_rules`) the UI translates, and the sim's reason does not itself ask for a new game: the player reads that once (N4).diff --git a/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs b/sim/Statecraft.Sim.Tests/ContentLoaderTests.csindex 6d8fa387a..4c95aa68d 100644--- a/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs+++ b/sim/Statecraft.Sim.Tests/ContentLoaderTests.cs@@ -5,6 +5,60 @@ using Statecraft.Sim;public class ContentLoaderTests{+ const string Target = @"+targets:+ - id: town_a+ q: 1+ r: 0+ operation: fixture_operation+ sources: [{ url: ""https://example.org/operation"", checked: 2026-10-18 }]+ status: sensitivity-reviewed+";++ /// <summary>The fixture with town_a as an arab_town row (Q-TGT-1 (a)) and <paramref name="targets"/> as the target list.</summary>+ static Dictionary<string, string> WithTargets(string targets) => new Dictionary<string, string>+ {+ ["map/settlements_1948.yaml"] = Fixture.Files["map/settlements_1948.yaml"].Replace("type: town,", "type: arab_town,"),+ ["settlement_targets.yaml"] = targets,+ };++ // R-CTRL-001+ [Fact]+ public void AValidSettlementTargetLoads()+ {+ var target = Assert.Single(ContentLoader.Load(Fixture.Write(WithTargets(Target))).SettlementTargets);+ Assert.Equal("town_a", target.Id);+ Assert.Equal((1, 0), (target.Q, target.R));+ Assert.Equal("fixture_operation", target.Operation);+ Assert.Equal("sensitivity-reviewed", target.Status);+ }++ // R-CTRL-001+ [Theory]+ [InlineData("town_a", "unknown", ".id", "is not an arab_town row of map/settlements_1948.yaml")]+ [InlineData(" q: 1\n", " q: 0\n", ".q", "is not a land hex")]+ [InlineData(" operation: fixture_operation\n", "", ".operation", "required")]+ [InlineData(" sources: [{ url: \"https://example.org/operation\", checked: 2026-10-18 }]\n", "", ".sources", "needs at least one source")]+ [InlineData(", checked: 2026-10-18", "", ".sources[0]", "needs an https url and a checked date")]+ [InlineData(" status: sensitivity-reviewed\n", "", ".status", "unknown status")]+ public void SettlementTargetsNeedAnArabTownLandHexOperationSourcesAndStatus(string before, string after, string field, string message)+ {+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(WithTargets(Target.Replace(before, after)))));+ Assert.Equal(ContentLoader.SettlementTargetsFileName, ex.File);+ Assert.Contains(field, ex.Field);+ Assert.Contains(message, ex.Message);+ }++ // R-CTRL-001: Q-TGT-1 (a) admits only arab_town rows, so a settlement of another type is refused.+ [Fact]+ public void ASettlementThatIsNotAnArabTownIsNotATarget()+ {+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(+ new Dictionary<string, string> { ["settlement_targets.yaml"] = Target })));+ Assert.Equal(ContentLoader.SettlementTargetsFileName, ex.File);+ Assert.Equal("targets[town_a].id", ex.Field);+ }+[Fact]public void LoadsValidFixture(){diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.csindex 1faec5a2a..34f6e1a16 100644--- a/sim/Statecraft.Sim.Tests/Fixture.cs+++ b/sim/Statecraft.Sim.Tests/Fixture.cs@@ -167,6 +167,9 @@ budget_start: { finance_minister: 1.0 }",["population.yaml"] = @"anchors: []+",+ ["settlement_targets.yaml"] = @"+targets: []",// A 5 x 2 map: one sea hex, the rest land; one settlement at (1, 0).["map/hexes.json"] = @"{""attribution"":[""test""],""bounds"":{""lon0"":34.2,""lon1"":35.9,""lat0"":29.45,""lat1"":33.35},""hex_size_km"":5.0,""layout"":""pointy"",""hexes"":[diff --git a/sim/Statecraft.Sim.Tests/RealContentTests.cs b/sim/Statecraft.Sim.Tests/RealContentTests.csindex b5df54448..b64b3c748 100644--- a/sim/Statecraft.Sim.Tests/RealContentTests.cs+++ b/sim/Statecraft.Sim.Tests/RealContentTests.cs@@ -18,6 +18,14 @@ public class RealContentTestsstatic readonly Content C = ContentLoader.Load(ContentRoot());static readonly DateTime Checked = new DateTime(2026, 10, 9);+ // R-CTRL-001: rows ship only after research, a person's check and sensitivity review.+ [Fact]+ public void SettlementTargetsAreSensitivityReviewed()+ {+ Assert.Empty(C.SettlementTargets);+ Assert.All(C.SettlementTargets, target => Assert.Equal(ReleaseGate.ReviewedStatus, target.Status));+ }+[Fact]public void MaimonBirthUsesHebrewBiographyDateAndSource(){diff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.csindex 87340dfe7..6a901c941 100644--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs@@ -204,6 +204,16 @@ public class SaveGameTestsAssert.NotEqual(a.Hash, map.Hash);}+ [Fact]+ public void TheContentHashCoversSettlementTargets()+ {+ var before = ContentLoader.Load(Fixture.Write()).Hash;+ var edited = Fixture.Files["settlement_targets.yaml"] + "# edited\n";+ var after = ContentLoader.Load(Fixture.Write(new Dictionary<string, string>+ { ["settlement_targets.yaml"] = edited })).Hash;+ Assert.NotEqual(before, after);+ }+/// <summary>Every command type the sim has must be savable: the played session uses each one, and a new Command type/// that the save format cannot write fails here.</summary>[Fact]diff --git a/sim/Statecraft.Sim.Tests/SettlementStateTests.cs b/sim/Statecraft.Sim.Tests/SettlementStateTests.csnew file mode 100644index 000000000..81935ede8--- /dev/null+++ b/sim/Statecraft.Sim.Tests/SettlementStateTests.cs@@ -0,0 +1,57 @@+using System;+using System.Collections.Generic;+using System.Linq;+using System.Reflection;+using Statecraft.Sim;++public class SettlementStateTests+{+ // R-CTRL-002+ [Fact]+ public void AnEmptyStateHashesAsBefore()+ {+ var state = new GameState();+ var before = state.Describe();+ state.Settlements = new SortedDictionary<string, SettlementControl>(StringComparer.Ordinal);+ Assert.Equal(before, state.Describe());+ Assert.DoesNotContain("ctrl", state.Describe());+ }++ // R-CTRL-002+ [Fact]+ public void ASettlementStateHashesInOrdinalOrderAndOmitsDefaultFields()+ {+ var state = new GameState();+ state.Settlements["z_place"] = new SettlementControl(state: "occupied", combatants: 2);+ state.Settlements["m_place"] = new SettlementControl(depopulated: true);+ state.Settlements["a_place"] = new SettlementControl(owner: "player");+ var text = state.Describe();+ Assert.Contains("ctrl{\n a_place=owner=player\n m_place=depopulated=1\n z_place=state=occupied,combatants=2", text);+ Assert.DoesNotContain("since=", text);+ Assert.DoesNotContain("buildings=", text);+ Assert.True(text.IndexOf("a_place", StringComparison.Ordinal) < text.IndexOf("z_place", StringComparison.Ordinal));+ }++ // R-CTRL-002+ [Fact]+ public void CloneCopiesTheCollectionButSharesItsImmutableRecords()+ {+ var state = new GameState();+ state.Settlements["place"] = new SettlementControl(depopulated: true);+ var clone = state.Clone();+ Assert.NotSame(state.Settlements, clone.Settlements);+ Assert.Same(state.Settlements["place"], clone.Settlements["place"]);+ }++ // R-CTRL-003+ [Fact]+ public void ResidentsAreNotCombatants()+ {+ var properties = typeof(SettlementControl).GetProperties(BindingFlags.Instance | BindingFlags.Public);+ // Q-CAP-2 (b): the residents are one yes/no state, not a count; the only count on the record is the combatants.+ Assert.Equal(typeof(bool), properties.Single(x => x.Name == nameof(SettlementControl.Depopulated)).PropertyType);+ Assert.Equal(new[] { nameof(SettlementControl.Combatants) },+ properties.Where(x => x.PropertyType == typeof(int) || x.PropertyType == typeof(long) || x.PropertyType == typeof(double)).Select(x => x.Name).ToArray());+ Assert.DoesNotContain(properties, x => x.Name.Contains("Resident", StringComparison.Ordinal) || x.Name.Contains("Population", StringComparison.Ordinal));+ }+}diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.csindex d4b3864a9..e986431bb 100644--- a/sim/Statecraft.Sim/Content.cs+++ b/sim/Statecraft.Sim/Content.cs@@ -983,6 +983,19 @@ namespace Statecraft.Simpublic int R { get; set; }}+ /// <summary>A curated settlement-control target (settlement_targets.yaml). The operation and sources are historical+ /// evidence for including the place; no capture behaviour reads this record yet (R-CTRL-001).</summary>+ public sealed class SettlementTarget+ {+ public string Id { get; set; } = "";+ public int Q { get; set; }+ public int R { get; set; }+ public string Operation { get; set; } = "";+ public List<Source> Sources { get; set; } = new List<Source>();+ /// <summary>Required on every row; empty means the key was missing and is rejected by the loader.</summary>+ public string Status { get; set; } = "";+ }+public sealed class Content{public List<Office> Offices = new List<Office>();@@ -1082,6 +1095,8 @@ namespace Statecraft.Simpublic List<SettlementHex> SettlementHexes = new List<SettlementHex>();/// <summary>Named GDD map locations. Presentation metadata only; gameplay roles remain in their owning systems.</summary>public List<MapLocation> MapLocations = new List<MapLocation>();+ /// <summary>The curated settlement-control targets, in file order (R-CTRL-001).</summary>+ public List<SettlementTarget> SettlementTargets = new List<SettlementTarget>();/// <summary>The display name of each settlement id (map/settlements_1948.yaml name), for text the player reads.</summary>public Dictionary<string, string> SettlementNames = new Dictionary<string, string>();/// <summary>The GDD cities' start values (cities.yaml), in file order. Empty in the legacy loop.</summary>diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex a00578e5d..d54af4da3 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -46,6 +46,7 @@ namespace Statecraft.Sim}sealed class SettlementHexesFile { public List<SettlementHex> Settlements { get; set; } = new List<SettlementHex>(); }sealed class MapLocationsFile { public List<MapLocation> Locations { get; set; } = new List<MapLocation>(); }+ sealed class SettlementTargetsFile { public List<SettlementTarget> Targets { get; set; } = new List<SettlementTarget>(); }sealed class CitiesFile { public List<CityStart> Cities { get; set; } = new List<CityStart>(); }sealed class UnitTypesFile { public List<UnitType> Types { get; set; } = new List<UnitType>(); }sealed class SitesFile { public List<Site> Sites { get; set; } = new List<Site>(); }@@ -56,10 +57,13 @@ namespace Statecraft.Simpublic const string SettlementHexesFileName = "map/settlement_hexes.yaml";public const string SettlementsFileName = "map/settlements_1948.yaml";public const string MapLocationsFileName = "map/locations_1948.yaml";+ public const string SettlementTargetsFileName = "settlement_targets.yaml";+ /// <summary>The settlements_1948.yaml row type a settlement target must have (Q-TGT-1 (a)).</summary>+ public const string ArabTown = "arab_town";/// <summary>The ids and names of settlements_1948.yaml, which the tools own (its other keys are not the sim's business),/// so it is read as plain maps rather than through the strict content types.</summary>- static List<(string id, string name)> ReadSettlements(Func<string, string?> readFile)+ static List<(string id, string name, string type)> ReadSettlements(Func<string, string?> readFile){string? text;try { text = readFile(SettlementsFileName); }@@ -83,7 +87,7 @@ namespace Statecraft.SimHebrewName(SettlementsFileName, $"settlements[{sid}]", "name_he", r.TryGetValue("name_he", out var he) && he is string hs ? hs : "",SettlementSources(r, $"settlements[{sid}].name_he_sources"),r.TryGetValue("name_he_review", out var rv) && rv is string rs ? rs : "", r.ContainsKey("name_he_review"));- return (sid, sname);+ return (sid, sname, r.TryGetValue("type", out var ty) && ty is string ts ? ts : "");}).ToList();}catch (YamlException e) { throw new ContentException(SettlementsFileName, $"line {e.Start.Line}", e.InnerException?.Message ?? e.Message); }@@ -324,7 +328,9 @@ namespace Statecraft.Simc.MapLocations = Read<MapLocationsFile>(readFile, MapLocationsFileName).Locations;var settlements = ReadSettlements(readFile);var settlementIds = settlements.Select(x => x.id).ToList();- foreach (var (id, name) in settlements) c.SettlementNames[id] = name; // a duplicate id fails in ValidateMap+ foreach (var (id, name, _) in settlements) c.SettlementNames[id] = name; // a duplicate id fails in ValidateMap+ c.SettlementTargets = Read<SettlementTargetsFile>(readFile, SettlementTargetsFileName).Targets;+ ValidateSettlementTargets(c, settlements.Where(x => x.type == ArabTown).Select(x => x.id));// Event files (content/events/*.yaml), one GameEvent each. Keys, for content authors:// id, title, text text may name office holders only through {office_id} placeholders, which// must have a holder on every day of the window@@ -1401,5 +1407,31 @@ namespace Statecraft.Simthrow new ContentException(SettlementHexesFileName, $"settlements[{s.Id}]", FormattableString.Invariant($"hex q={s.Q} r={s.R} is not a land hex in {HexesFile}"));}}++ /// <summary>R-CTRL-001 (Q-TGT-1 (a)): every target is an arab_town row of settlements_1948.yaml on a land hex, with a+ /// sourced operation and a review status.</summary>+ static void ValidateSettlementTargets(Content c, IEnumerable<string> arabTownIds)+ {+ Unique(SettlementTargetsFileName, "targets", c.SettlementTargets.Select(x => x.Id));+ var known = new HashSet<string>(arabTownIds, StringComparer.Ordinal);+ foreach (var x in c.SettlementTargets)+ {+ var at = $"targets[{x.Id}]";+ if (!known.Contains(x.Id))+ throw new ContentException(SettlementTargetsFileName, at + ".id", $"is not an {ArabTown} row of {SettlementsFileName}");+ var hex = c.HexAt(x.Q, x.R);+ if (hex == null || !hex.Land)+ throw new ContentException(SettlementTargetsFileName, at + ".q", FormattableString.Invariant($"hex q={x.Q} r={x.R} is not a land hex in {HexesFile}"));+ if (string.IsNullOrWhiteSpace(x.Operation)) throw new ContentException(SettlementTargetsFileName, at + ".operation", "required");+ if (x.Sources.Count == 0) throw new ContentException(SettlementTargetsFileName, at + ".sources", "needs at least one source");+ for (int i = 0; i < x.Sources.Count; i++)+ {+ var source = x.Sources[i];+ if (!Uri.TryCreate(source.Url, UriKind.Absolute, out var uri) || uri.Scheme != "https" || source.Checked == default)+ throw new ContentException(SettlementTargetsFileName, at + $".sources[{i}]", "needs an https url and a checked date");+ }+ Status(SettlementTargetsFileName, at + ".status", x.Status);+ }+ }}}diff --git a/sim/Statecraft.Sim/GameState.cs b/sim/Statecraft.Sim/GameState.csindex 0565d1686..e1d10cf72 100644--- a/sim/Statecraft.Sim/GameState.cs+++ b/sim/Statecraft.Sim/GameState.cs@@ -74,6 +74,8 @@ namespace Statecraft.Simpublic int NextId;/// <summary>The date each completed objective was completed, by objective id (ordinal).</summary>public SortedDictionary<string, DateTime> Objectives = new SortedDictionary<string, DateTime>(StringComparer.Ordinal);+ /// <summary>Settlement control by target id, ordinal (R-CTRL-002).</summary>+ public SortedDictionary<string, SettlementControl> Settlements = new SortedDictionary<string, SettlementControl>(StringComparer.Ordinal);/// <summary>The player's score (GDD "Objectives": bonus points). An int assumes whole-number points; the point values and/// the timing bonus are open decisions with the owner (D-B2, D-B6), so the type is revisited when they are set.</summary>public int Score;@@ -109,6 +111,7 @@ namespace Statecraft.Simc.Sites = new SortedDictionary<string, SiteWork>(Sites, StringComparer.Ordinal);c.CityProjects = new SortedList<int, CityProject>(CityProjects);c.Objectives = new SortedDictionary<string, DateTime>(Objectives, StringComparer.Ordinal);+ c.Settlements = new SortedDictionary<string, SettlementControl>(Settlements, StringComparer.Ordinal);return c;}@@ -199,6 +202,8 @@ namespace Statecraft.Simif (NextId != 0) { Sep(); Nl(); sb.Append("next=").Append(NextId.ToString(CultureInfo.InvariantCulture)); }if (Objectives.Count > 0)Section("obj", '{', '}', Objectives.Select(kv => kv.Key + "=" + kv.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)));+ if (Settlements.Count > 0)+ Section("ctrl", '{', '}', Settlements.Select(kv => kv.Key + "=" + kv.Value.Canonical()));if (Score != 0) { Sep(); Nl(); sb.Append("score=").Append(Score.ToString(CultureInfo.InvariantCulture)); }if (Food != 0 || FoodNeed != 0 || FoodUnmet != 0){diff --git a/sim/Statecraft.Sim/GddState.cs b/sim/Statecraft.Sim/GddState.csindex 86e256823..325b2fa93 100644--- a/sim/Statecraft.Sim/GddState.cs+++ b/sim/Statecraft.Sim/GddState.cs@@ -1,8 +1,39 @@using System;+using System.Collections.Generic;using System.Globalization;namespace Statecraft.Sim{+ /// <summary>One settlement's control state. Residents are a state, inhabited (the default) or depopulated, never a count+ /// or a combatant field (Q-CAP-2 (b); R-CTRL-003). Immutable so <see cref="GameState.Clone"/> can copy the containing map+ /// shallowly.</summary>+ public sealed class SettlementControl+ {+ public string Owner { get; }+ public string State { get; }+ public DateTime Since { get; }+ public bool Depopulated { get; }+ public int Combatants { get; }+ public string Buildings { get; }++ public SettlementControl(string owner = "", string state = "", DateTime since = default, bool depopulated = false, int combatants = 0, string buildings = "")+ {+ Owner = owner; State = state; Since = since; Depopulated = depopulated; Combatants = combatants; Buildings = buildings;+ }++ public string Canonical()+ {+ var fields = new List<string>();+ if (Owner != "") fields.Add("owner=" + Owner);+ if (State != "") fields.Add("state=" + State);+ if (Since != default) fields.Add("since=" + Since.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));+ if (Depopulated) fields.Add("depopulated=1");+ if (Combatants != 0) fields.Add("combatants=" + Combatants.ToString(CultureInfo.InvariantCulture));+ if (Buildings != "") fields.Add("buildings=" + Buildings);+ return string.Join(",", fields);+ }+ }+/// <summary>A city in the GDD v0.1 loop (docs/GDD.md "Cities and construction"; owner decision D-A2: civilians and/// refugees are counts per city). Counts are population units, each a group (D-A1). Immutable, so GameState.Clone can copy/// the map shallowly; a change replaces the record. Only the attributes approved decisions define are here.</summary>