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.

sim: consequence cards with the Ferguson gate, depth cap, tag inheritance and soft-slot priority (R-ALT-005 to R-ALT-008, R-ALT-012; refs #950) (#972)

Eyal Golana7f6897de615
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 78d3c4c7b..8090cd5ba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [Unreleased]
### Added
+- Events: consequence cards (`kind: consequence`) for the roads not taken. They are soft, follow only a road
+ contemporaries proposed or debated (the Ferguson test), lie at most 2 cards deep, carry the sensitive tags of the road
+ they follow and take the first soft slots of a turn (R-ALT-005 to R-ALT-008, R-ALT-012; refs #950, #939). No content
+ uses them yet.
- Event options in the GDD loop can grant units and change a city's housing capacity or job slots: `grant_units`
adds free units at the military camp or a named city, `city_effects` moves one field by whole units, both
apply after the numeric effects and show in the option's effect list, the loader refuses an unknown target, and a
diff --git a/content/schema/event.schema.json b/content/schema/event.schema.json
index c09f86020..af2f55564 100644
--- a/content/schema/event.schema.json
+++ b/content/schema/event.schema.json
@@ -45,6 +45,7 @@
},
"properties": {
"id": { "$ref": "#/definitions/id", "description": "Unique across all events." },
+ "kind": { "enum": ["historical", "consequence", "reconvergence"], "description": "Default historical. consequence: a soft card that exists only on a road not taken (R-ALT-005 to R-ALT-008). reconvergence: a real outside event that happened regardless (its variants arrive with #952)." },
"title": { "type": "string", "minLength": 1, "description": "May contain office placeholders such as {prime_minister}." },
"text": { "type": "string", "minLength": 1, "description": "May contain office placeholders. No invented quotes." },
"tags": { "type": "array", "items": { "type": "string" }, "description": "holocaust, terror, massacre and war-casualties are sensitive." },
diff --git a/docs/WRITING_EVENTS.md b/docs/WRITING_EVENTS.md
index 53eb9b256..39f383b31 100644
--- a/docs/WRITING_EVENTS.md
+++ b/docs/WRITING_EVENTS.md
@@ -37,6 +37,7 @@ schema too, or that test fails. Keep the comment when you copy a file.
| `from` | yes | First day of the window, `YYYY-MM-DD`. |
| `to` | no | Day the window ends (exclusive). Must be after `from`. Leave it out for an open window. |
| `conditions` | no | Indicator bounds that must hold when it fires. See below. |
+| `kind` | no (default `historical`) | `consequence` for a card that exists only on a road not taken. See below. |
| `requires` | no | Fires only after every listed requirement holds. See below. |
| `objective` | no | Makes the event the completion card of an objective in `objectives.yaml`, which must name this event as its `card`. It fires only once the objective is completed (GDD loop only), and has exactly one option. See `docs/gdd/objective-card.md`. |
| `options` | yes | One or more options. See below. |
@@ -112,6 +113,41 @@ conditions:
`min` and `max` are both optional, and `min` must not exceed `max`. Not every event needs this; the example has none.
+### kind
+
+Every event on the record is `historical`, the default; leave the key out. A **consequence card**, `kind: consequence`,
+exists only because the player took a road that did not happen (R-ALT-005 to R-ALT-008):
+
+```yaml
+id: after_the_road
+kind: consequence
+anchor: soft # always soft
+title: ...
+text: '...' # only what was threatened, promised or recorded as feared at the time; office placeholders
+from: 1948-07-15 # absolute dates, opening after the parent's window closes
+to: 1948-09-15
+requires: [{ event: parent_event, option: road_not_taken }] # or { event: parent_event, diverged: true }
+options:
+ - id: hold
+ text: ...
+ alternative: { basis: debated, by: ..., date: ..., sources: [...] } # every option carries one
+```
+
+The loader refuses a consequence card that:
+- is `hard`, or has an option marked `historical: true`;
+- has no requirement on a road not taken (an option that did not happen, `diverged: true`, or an option of another
+ consequence card);
+- has an option without an `alternative` record;
+- follows a road nobody is recorded proposing (the Ferguson test, R-ALT-006, owner's answer Q-ALT-3): the option it
+ follows must have `alternative.basis` `proposed` or `debated`. With `diverged: true`, every option that did not
+ happen must;
+- does not carry each sensitive tag of every event it requires (R-ALT-007). The no-gain rule then covers it too;
+- has an `objective`, or is required by an event that is not itself a consequence card;
+- lies more than 2 cards deep from the record (`EventRules.MaxConsequenceDepth`, a design value, Q-ALT-5).
+
+Consequence cards take a turn's soft slots before the other soft events (R-ALT-008). They never fire in the historical
+run (R-ALT-012), so `EventRetimingTests` counts only the other events.
+
### requires
```yaml
@@ -295,6 +331,16 @@ Errors are printed as `file: field: message`. These are the messages you are mos
| `a design alternative names nobody and no date` | A `design` alternative with a `by` or a `date`. |
| `needs at least one source` | A proposed or debated `alternative` with no `sources`. |
| `needs an https url and a checked date` | An `alternative` source without `https://` or without `checked`. |
+| `a consequence card is soft` | `kind: consequence` with `anchor: hard`. |
+| `a consequence card has no historical option` | A consequence card's option is marked `historical: true`. |
+| `a consequence card follows a road not taken` | A consequence card with no requirement on an option that did not happen. |
+| `every option of a consequence card says who proposed it` | A consequence card's option has no `alternative`. |
+| `which nobody is recorded proposing` | The road it follows has `basis: design`, or no record (R-ALT-006). |
+| `must carry '` | A consequence card lacks a sensitive tag of the event it follows (R-ALT-007). |
+| `cards deep; the most is` | A chain of consequence cards longer than `EventRules.MaxConsequenceDepth`, 2 (Q-ALT-5). |
+| `only a consequence card may follow a consequence card` | A historical event requires a consequence card. |
+| `a consequence card is not an objective's card` | A consequence card has `objective:`. |
+| `must be historical, consequence or reconvergence` | `kind` is another word. |
| `is already required` | Two `requires` entries name the same event (they could never both hold, or one is redundant). |
A full message looks like this (an effect target misspelled `securty`):
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 280fc98e8..494262268 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -168,7 +168,7 @@ D-H1 in the GDD loop (GDD Phase 7 PR 1, #805). The owner took the plan's recomme
R-EVT-001: An event fires on the first turn whose span overlaps its window `[from, to)` (or at the new game, when the start date is in it), once its `requires` is met and its conditions hold; an objective's card also waits for its objective (R-OBJ-003). Every eligible hard anchor fires. At most 3 soft events fire a turn (`EventSystem.MaxSoftEventsPerTurn`); they take the slots the hard anchors leave, `max(0, 3 - hard anchors)`, and the rest wait for a later turn (Q-CUT-6).
-R-EVT-002: The soft events take the free slots in order of `from`, then id (ordinal). The decided place of an early armistice ahead of the other soft events (Q-EVT-1, through `front_quiet`, Q-OBJ-1) lands with that key in Phase 5 PR 13 (#752), and this rule is reworded then.
+R-EVT-002: The soft events take the free slots in order: consequence cards first (R-ALT-008), then the rest by `from`, then id (ordinal). The decided place of an early armistice ahead of the other soft events (Q-EVT-1, through `front_quiet`, Q-OBJ-1) lands with that key in Phase 5 PR 13 (#752), and this rule is reworded then.
R-EVT-003: An event the player leaves unanswered at End Turn is delegated to its office's holder (Q-EVT-2): with probability competence/10 the holder picks the recommended option (else the first), otherwise a random option. In Historical mode a hard anchor takes its historical option, and an objective's card its one option, with no RNG draw.
@@ -185,3 +185,13 @@ R-ALT-001: An event's `requires` is a list, and the event is eligible only when
R-ALT-002: An entry `{ event, diverged: true }` holds when that event was resolved with any option except its historical one. An event with no historical option cannot diverge, and the loader refuses `diverged` on it.
R-ALT-003: A non-historical option may carry `alternative: { basis, by, date, sources }`. `basis` is `proposed` or `debated` (a body or office, in words, is recorded putting it forward on that date; at least one https source with a checked date) or `design` (nobody is recorded proposing it: a design assumption, which names nobody and no date; sources optional). The historical option carries none.
+
+R-ALT-005: An event of `kind: consequence` is soft, has no historical option, has at least one requirement naming a road not taken (`diverged: true`, a non-historical option, or an option of another consequence card), carries an `alternative` record on every option, and lies at most 2 cards deep from the record (`EventRules.MaxConsequenceDepth`, a labelled design value, Q-ALT-5). It is never an objective's card, and only a consequence card may require one.
+
+R-ALT-006: A consequence card may follow only an option whose `alternative.basis` is `proposed` or `debated`; with `diverged: true`, every non-historical option of that event must be (the Ferguson test, Q-ALT-3).
+
+R-ALT-007: A consequence card carries every sensitive tag (case aside) of each event it requires, so the no-gain rule (R-EFX-002, R-EFX-005) covers it.
+
+R-ALT-008: Consequence cards take a turn's soft slots before the other soft events, then by `from` and id (Q-ALT-14). A `front_quiet` armistice (Q-EVT-1, Phase 5 PR 13) will come before them. With no consequence card eligible the order is unchanged.
+
+R-ALT-012: The historical run (the reference player's orders from 15 May 1948 to 15 January 1952) raises no consequence card and diverges nowhere.
diff --git a/sim/Statecraft.Sim.Tests/AltRun.cs b/sim/Statecraft.Sim.Tests/AltRun.cs
new file mode 100644
index 000000000..d568f02ed
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/AltRun.cs
@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>A run that leaves the record: the reference player's orders (GoldenRun.Orders) on the golden seed, except that
+/// each event in <c>forced</c> is answered with the given option. Test code with a stated policy, like the scenarios.</summary>
+public static class AltRun
+{
+ public static List<GameState> Play(Content c, IReadOnlyDictionary<string, string> forced)
+ {
+ var s = Simulation.NewGame(c, GoldenRun.Seed, Mode.Historical);
+ var run = new List<GameState> { s };
+ while (s.GameOver == null && run.Count < 1000)
+ {
+ var orders = GoldenRun.Orders(c, s)
+ .Select(o => o is ChooseEventOption ch && forced.TryGetValue(ch.EventId, out var opt) ? new ChooseEventOption(ch.EventId, opt) : o)
+ .ToList();
+ s = Simulation.Step(c, s, orders).State;
+ // A forced choice goes only through an order the reference player sends; if Attention ran short and a minister
+ // answered instead, the run is not the road it claims to be, so it says so.
+ foreach (var kv in forced)
+ if (s.ChosenOptions.TryGetValue(kv.Key, out var got) && got != kv.Value)
+ throw new System.InvalidOperationException($"AltRun: {kv.Key} was answered {got}, not the forced {kv.Value}");
+ run.Add(s);
+ }
+ return run;
+ }
+
+ /// <summary>The choices that lead to <paramref name="card"/>: for each requirement, its option, or for `diverged: true`
+ /// the event's first non-historical option in file order; walked back through a parent consequence card.</summary>
+ public static Dictionary<string, string> RoadTo(Content c, GameEvent card)
+ {
+ var road = new Dictionary<string, string>();
+ foreach (var r in card.Requires)
+ {
+ var parent = c.Events.First(x => x.Id == r.Event);
+ road[r.Event] = r.Diverged ? parent.Options.First(o => !o.Historical).Id : r.Option;
+ if (parent.Kind == EventKinds.Consequence)
+ foreach (var kv in RoadTo(c, parent)) road[kv.Key] = kv.Value;
+ }
+ return road;
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs b/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs
index dd9e39bd6..3a7c58681 100644
--- a/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs
+++ b/sim/Statecraft.Sim.Tests/AlternateTimelineTests.cs
@@ -109,4 +109,285 @@ options:
var bare = Parent.Substring(0, Parent.IndexOf(" alternative:", StringComparison.Ordinal));
Assert.Null(Load(("parent.yaml", bare)).Events.Single().Options.Single(o => o.Id == "road").Alternative);
}
+
+ // ---- Task 5 (#950): consequence cards ------------------------------------------------------------------------
+
+ internal const string Consequence = @"
+id: after_road
+kind: consequence
+title: After the road
+text: 'What the record says was feared.'
+from: 1948-06-15
+to: 1948-08-15
+requires: [{ event: parent, option: road }]
+options:
+ - id: hold
+ text: Hold the course
+ alternative:
+ basis: debated
+ by: the cabinet
+ date: 1948-06-20
+ sources: [{ url: ""https://example.org/cabinet"", checked: 2026-10-17 }]
+";
+
+ const string RecordToo = "options:\n - id: record_too\n text: As recorded\n historical: true\n";
+
+ static ContentException LoadError(string consequence) =>
+ Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("after_road.yaml", consequence)));
+
+ // R-ALT-005
+ [Fact]
+ public void AConsequenceCardLoadsWithItsKind()
+ {
+ var c = Load(("parent.yaml", Parent), ("after_road.yaml", Consequence));
+ Assert.Equal(EventKinds.Consequence, c.Events.Single(e => e.Id == "after_road").Kind);
+ Assert.Equal(EventKinds.Historical, c.Events.Single(e => e.Id == "parent").Kind); // the default
+ }
+
+ // R-ALT-005
+ [Theory]
+ [InlineData("requires: [{ event: parent, option: road }]\n", "", "requires", "a consequence card follows a road not taken")]
+ [InlineData("option: road", "option: record", "requires", "a consequence card follows a road not taken")]
+ [InlineData("options:\n", RecordToo, "options", "a consequence card has no historical option")]
+ [InlineData("kind: consequence", "kind: sideways", "kind", "must be historical, consequence or reconvergence")]
+ public void AConsequenceCardHasItsShape(string from, string to, string field, string message)
+ {
+ var ex = LoadError(Consequence.Replace(from, to));
+ Assert.Equal("events/after_road.yaml", ex.File);
+ Assert.Equal("events[after_road]." + field, ex.Field);
+ Assert.Contains(message, ex.Message);
+ }
+
+ // R-ALT-005
+ [Fact]
+ public void AConsequenceCardIsSoft()
+ {
+ // A hard anchor needs a historical option (EventRules), so the fixture gives it one; the soft rule is checked first.
+ var ex = LoadError(Consequence.Replace("kind: consequence\n", "kind: consequence\nanchor: hard\n").Replace("options:\n", RecordToo));
+ Assert.Equal("events[after_road].anchor", ex.Field);
+ Assert.Contains("a consequence card is soft", ex.Message);
+ }
+
+ // R-ALT-005
+ [Fact]
+ public void DivergedCountsAsARoadNotTaken()
+ {
+ var c = Load(("parent.yaml", Parent), ("after_road.yaml", Consequence.Replace("option: road", "diverged: true")));
+ Assert.Single(c.Events.Single(e => e.Id == "after_road").Requires);
+ }
+
+ // R-ALT-005
+ [Fact]
+ public void EveryOptionOfAConsequenceCardHasARecord()
+ {
+ var ex = LoadError(Consequence.Substring(0, Consequence.IndexOf(" alternative:", StringComparison.Ordinal)));
+ Assert.Equal("events[after_road].options[hold].alternative", ex.Field);
+ Assert.Contains("every option of a consequence card says who proposed it", ex.Message);
+ }
+
+ static string DesignParent => Parent.Replace(" basis: proposed\n by: the opposition benches\n date: 1948-06-05\n sources: [{ url: \"https://example.org/minutes\", checked: 2026-10-17 }]\n", " basis: design\n");
+
+ // R-ALT-006
+ [Theory]
+ [InlineData("option: road")]
+ [InlineData("diverged: true")]
+ public void NoConsequenceFollowsADesignAlternative(string entry)
+ {
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", DesignParent), ("after_road.yaml", Consequence.Replace("option: road", entry))));
+ Assert.Equal("events[after_road].requires[0]", ex.Field);
+ Assert.Contains("follows 'parent/road', which nobody is recorded proposing (basis: design)", ex.Message);
+ }
+
+ // R-ALT-006
+ [Fact]
+ public void NoConsequenceFollowsAnAlternativeWithNoRecord()
+ {
+ // Until #949 makes the record required, an alternative without one is not "recorded proposing" either.
+ var bare = Parent.Substring(0, Parent.IndexOf(" alternative:", StringComparison.Ordinal));
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", bare), ("after_road.yaml", Consequence)));
+ Assert.Contains("which nobody is recorded proposing", ex.Message);
+ }
+
+ static string Chained(string id, string parent, string option) => Consequence
+ .Replace("id: after_road", "id: " + id)
+ .Replace("requires: [{ event: parent, option: road }]", $"requires: [{{ event: {parent}, option: {option} }}]");
+
+ // R-ALT-005, R-ALT-006
+ [Fact]
+ public void ARoadRunsAtMostTwoCardsDeep()
+ {
+ var two = Load(("parent.yaml", Parent), ("after_road.yaml", Consequence), ("second.yaml", Chained("second", "after_road", "hold")));
+ Assert.Equal(3, two.Events.Count);
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("after_road.yaml", Consequence),
+ ("second.yaml", Chained("second", "after_road", "hold")), ("third.yaml", Chained("third", "second", "hold"))));
+ Assert.Equal("events/third.yaml", ex.File);
+ Assert.Equal("events[third].requires", ex.Field);
+ Assert.Contains("3 cards deep; the most is 2", ex.Message);
+ }
+
+ // R-ALT-006: a second card follows the first card's option only if that option, too, was proposed or debated.
+ [Fact]
+ public void AChainedCardFollowsOnlyAConsideredOption()
+ {
+ var designFirst = Consequence.Replace(" basis: debated\n by: the cabinet\n date: 1948-06-20\n sources: [{ url: \"https://example.org/cabinet\", checked: 2026-10-17 }]\n", " basis: design\n");
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("after_road.yaml", designFirst), ("second.yaml", Chained("second", "after_road", "hold"))));
+ Assert.Equal("events[second].requires[0]", ex.Field);
+ Assert.Contains("follows 'after_road/hold'", ex.Message);
+ }
+
+ // R-ALT-007
+ [Fact]
+ public void AConsequenceOfASensitiveEventCarriesItsTags()
+ {
+ var sensitive = Parent.Replace("from: 1948-06-01\n", "from: 1948-06-01\ntags: [war-casualties]\n");
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", sensitive), ("after_road.yaml", Consequence)));
+ Assert.Equal("events[after_road].tags", ex.Field);
+ Assert.Contains("must carry 'war-casualties', as 'parent' does", ex.Message);
+ // Case does not matter, as for the sensitive rule itself.
+ var upper = Consequence.Replace("kind: consequence\n", "kind: consequence\ntags: [War-Casualties]\n");
+ Load(("parent.yaml", sensitive), ("after_road.yaml", upper));
+ // With the tag inherited, the existing no-gain rule refuses a reward.
+ var gain = Consequence.Replace("kind: consequence\n", "kind: consequence\ntags: [war-casualties]\n")
+ .Replace(" text: Hold the course\n", " text: Hold the course\n effects: [{ target: morale, delta: 0.01 }]\n");
+ var ex2 = Assert.Throws<ContentException>(() => Load(("parent.yaml", sensitive), ("after_road.yaml", gain)));
+ Assert.Contains("sensitive events cannot reward morale", ex2.Message);
+ }
+
+ // R-ALT-007: a second card inherits through the first card, which already carries the tag.
+ [Fact]
+ public void AChainedCardInheritsTheTagThroughTheFirstCard()
+ {
+ var sensitive = Parent.Replace("from: 1948-06-01\n", "from: 1948-06-01\ntags: [war-casualties]\n");
+ var first = Consequence.Replace("kind: consequence\n", "kind: consequence\ntags: [war-casualties]\n");
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", sensitive), ("after_road.yaml", first), ("second.yaml", Chained("second", "after_road", "hold"))));
+ Assert.Equal("events[second].tags", ex.Field);
+ }
+
+ static GameState NewState(Content c)
+ {
+ var s = new GameState { Date = new DateTime(1948, 6, 15), RngState = 3, Mode = Mode.Historical };
+ EffectsSystem.Init(c, s); EconomySystem.Init(c, s);
+ return s;
+ }
+
+ static string Soft(string id) =>
+ $"id: {id}\ntitle: {id}\ntext: 'Ordinary.'\nfrom: 1948-06-01\nto: 1948-08-15\noptions:\n - id: ok\n text: Ok\n";
+
+ static Content WithThreeSoft() => Load(("parent.yaml", Parent), ("after_road.yaml", Consequence), ("a1.yaml", Soft("a1")), ("a2.yaml", Soft("a2")), ("a3.yaml", Soft("a3")));
+
+ // R-ALT-008
+ [Fact]
+ public void ConsequenceCardsTakeTheFirstSoftSlots()
+ {
+ var c = WithThreeSoft();
+ var s = NewState(c);
+ s.ChosenOptions["parent"] = "road";
+ s.FiredEvents.Add("parent");
+ EventSystem.Trigger(c, s, new List<Cause>());
+ Assert.Equal(new[] { "after_road", "a1", "a2" }, s.PendingEvents); // a3 waits; the road's card is not crowded out
+ }
+
+ // R-ALT-008
+ [Fact]
+ public void WithNoConsequenceCardTheOrderIsUnchanged()
+ {
+ var c = WithThreeSoft();
+ var s = NewState(c);
+ s.ChosenOptions["parent"] = "record";
+ s.FiredEvents.Add("parent");
+ EventSystem.Trigger(c, s, new List<Cause>());
+ Assert.Equal(new[] { "a1", "a2", "a3" }, s.PendingEvents);
+ }
+
+ // R-ALT-005 (review): only a consequence card may follow a consequence card, so a historical event never waits on a
+ // card the record never raises, and the depth cap cannot be reset by a historical event in the middle of a chain.
+ [Fact]
+ public void OnlyAConsequenceCardFollowsAConsequenceCard()
+ {
+ var historical = "id: later\ntitle: Later\ntext: x\nfrom: 1948-09-01\nrequires: [{ event: after_road, option: hold }]\noptions:\n - id: ok\n text: Ok\n";
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("after_road.yaml", Consequence), ("later.yaml", historical)));
+ Assert.Equal("events/later.yaml", ex.File);
+ Assert.Equal("events[later].requires[0]", ex.Field);
+ Assert.Contains("only a consequence card may follow a consequence card", ex.Message);
+ }
+
+ // R-ALT-006: with diverged: true, every option that did not happen must be proposed or debated, not only the first.
+ [Fact]
+ public void DivergedNeedsEveryAlternativeConsidered()
+ {
+ var two = Parent + " - id: other_road\n text: Another road\n alternative: { basis: design }\n";
+ Load(("parent.yaml", two), ("after_road.yaml", Consequence)); // following the considered road alone is fine
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", two), ("after_road.yaml", Consequence.Replace("option: road", "diverged: true"))));
+ Assert.Contains("follows 'parent/other_road', which nobody is recorded proposing (basis: design)", ex.Message);
+ }
+
+ // R-ALT-007 (review): the tags come from every event the card requires, not only the road it follows, so a card shown
+ // after a sensitive event can never reward.
+ [Fact]
+ public void AConsequenceCarriesTheTagsOfEveryEventItRequires()
+ {
+ var sens = "id: sens\ntitle: Sens\ntext: x\nfrom: 1948-06-01\ntags: [Massacre]\noptions:\n - id: rec\n text: Rec\n historical: true\n";
+ var both = Consequence.Replace("requires: [{ event: parent, option: road }]", "requires: [{ event: parent, option: road }, { event: sens, option: rec }]");
+ var ex = Assert.Throws<ContentException>(() => Load(("parent.yaml", Parent), ("sens.yaml", sens), ("after_road.yaml", both)));
+ Assert.Equal("events[after_road].tags", ex.Field);
+ Assert.Contains("must carry 'Massacre', as 'sens' does", ex.Message);
+ Load(("parent.yaml", Parent), ("sens.yaml", sens), ("after_road.yaml", both.Replace("kind: consequence\n", "kind: consequence\ntags: [massacre]\n"))); // case aside
+ }
+
+ // R-ALT-005 (review): an objective's completion card is the record of a completed objective, never a road not taken.
+ [Fact]
+ public void AConsequenceCardIsNoObjectivesCard()
+ {
+ var ex = LoadError(Consequence.Replace("kind: consequence\n", "kind: consequence\nobjective: anything\n"));
+ Assert.Equal("events[after_road].objective", ex.Field);
+ Assert.Contains("a consequence card is not an objective's card", ex.Message);
+ }
+
+ static readonly Content Real = ContentLoader.Load(RealContentTests.ContentRoot());
+
+ // R-ALT-012
+ [Fact]
+ public void TheHistoricalRunRaisesNoConsequenceCard()
+ {
+ var end = GoldenRun.PlayToEnd(Real);
+ var raised = Real.Events.Where(e => e.Kind == EventKinds.Consequence && end.FiredEvents.Contains(e.Id)).Select(e => e.Id).ToList();
+ Assert.True(raised.Count == 0, "the historical run raised: " + string.Join(", ", raised));
+ Assert.NotEmpty(end.ChosenOptions);
+ Assert.All(end.ChosenOptions, kv => Assert.False(Timeline.Diverged(Real, end, kv.Key), $"the historical run diverged at {kv.Key}"));
+ }
+
+ /// <summary>Review focus 2: every consequence card in content/ fires in a run that takes its road (and, for a second
+ /// card, the first card's option too), with the reference player's orders everywhere else. Until a content slice adds
+ /// one, there is none; AltRunWalksTheRoadBack pins the helper on fixtures.</summary>
+ [Fact]
+ public void EveryConsequenceCardFiresWhenItsRoadIsTaken()
+ {
+ foreach (var e in Real.Events.Where(x => x.Kind == EventKinds.Consequence))
+ {
+ var forced = AltRun.RoadTo(Real, e);
+ var run = AltRun.Play(Real, forced);
+ Assert.True(run.Any(s => s.FiredEvents.Contains(e.Id)), $"{e.Id} never fired on the road {string.Join(", ", forced.Select(kv => kv.Key + "/" + kv.Value))}");
+ }
+ }
+
+ [Fact]
+ public void AltRunWalksTheRoadBack()
+ {
+ var c = Load(("parent.yaml", Parent), ("after_road.yaml", Consequence), ("second.yaml", Chained("second", "after_road", "hold")));
+ Assert.Equal(new Dictionary<string, string> { ["parent"] = "road" }, AltRun.RoadTo(c, c.Events.Single(x => x.Id == "after_road")));
+ Assert.Equal(new Dictionary<string, string> { ["after_road"] = "hold", ["parent"] = "road" }, AltRun.RoadTo(c, c.Events.Single(x => x.Id == "second")));
+ var div = Load(("parent.yaml", Parent), ("after_road.yaml", Consequence.Replace("option: road", "diverged: true")));
+ Assert.Equal(new Dictionary<string, string> { ["parent"] = "road" }, AltRun.RoadTo(div, div.Events.Single(x => x.Id == "after_road")));
+ }
+
+ /// <summary>AltRun on the real content: forcing an alternative changes the run, and only where it is forced.</summary>
+ [Fact]
+ public void AltRunForcesOnlyTheGivenChoice()
+ {
+ var run = AltRun.Play(Real, new Dictionary<string, string> { ["first_truce"] = "refuse" });
+ var end = run[run.Count - 1];
+ Assert.Equal("refuse", end.ChosenOptions["first_truce"]);
+ Assert.True(Timeline.Diverged(Real, end, "first_truce"));
+ Assert.Equal(new[] { "first_truce" }, end.ChosenOptions.Keys.Where(k => Timeline.Diverged(Real, end, k)).ToArray());
+ }
}
diff --git a/sim/Statecraft.Sim.Tests/EventRetimingTests.cs b/sim/Statecraft.Sim.Tests/EventRetimingTests.cs
index 2f4b58e4a..8a282a130 100644
--- a/sim/Statecraft.Sim.Tests/EventRetimingTests.cs
+++ b/sim/Statecraft.Sim.Tests/EventRetimingTests.cs
@@ -32,9 +32,11 @@ public class EventRetimingTests
public void EveryEventFiresInTheHistoricalMonthlyRun()
{
Assert.Equal(GameOverCodes.MvpEnded, Run[Run.Count - 1].GameOver);
- var missing = C.Events.Select(e => e.Id).Where(id => CardDate(id) == null).ToList();
+ // A consequence card (R-ALT-005) comes only on a road not taken, never in this run (R-ALT-012).
+ var record = C.Events.Where(e => e.Kind != EventKinds.Consequence).ToList();
+ var missing = record.Select(e => e.Id).Where(id => CardDate(id) == null).ToList();
Assert.True(missing.Count == 0, "never fired: " + string.Join(", ", missing));
- Assert.Equal(32, C.Events.Count);
+ Assert.Equal(32, record.Count);
}
/// <summary>The card date of every event, from #567's tables (the "Proposed" column in the war period, "Monthly" after
diff --git a/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs b/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs
index d18508dc9..96108ab93 100644
--- a/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs
+++ b/sim/Statecraft.Sim.Tests/EventRulesGddTests.cs
@@ -196,9 +196,12 @@ options:
public void ThePreviewListsEveryEffectOnTheRealContent()
{
var checkedOptions = 0;
+ // A consequence card never fires in the historical run (R-ALT-012); its state comes from a run on its road.
foreach (var e in C.Events)
{
- var s = Run.First(x => x.FiredEvents.Contains(e.Id)); // every event fires in the run (EventRetimingTests)
+ var s = e.Kind != EventKinds.Consequence
+ ? Run.First(x => x.FiredEvents.Contains(e.Id)) // every historical event fires in the run (EventRetimingTests)
+ : AltRun.Play(C, AltRun.RoadTo(C, e)).First(x => x.FiredEvents.Contains(e.Id));
foreach (var o in e.Options)
{
var expected = o.Effects.Select(fx => (fx.Target, fx.Delta))
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index fd1f39f8e..7b1e5d9ac 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -752,9 +752,18 @@ namespace Statecraft.Sim
[YamlIgnore] public bool IsConsidered => Basis == Proposed || Basis == Debated;
}
+ /// <summary>The kinds of event (R-ALT-005): the record, a card only on a road not taken, and a real outside
+ /// event that happened regardless.</summary>
+ public static class EventKinds
+ {
+ public const string Historical = "historical", Consequence = "consequence", Reconvergence = "reconvergence";
+ }
+
public sealed class GameEvent
{
public string Id { get; set; } = "";
+ /// <summary>historical (the default), consequence (R-ALT-005) or reconvergence (its variants arrive with #952).</summary>
+ public string Kind { get; set; } = EventKinds.Historical;
public string Title { get; set; } = "";
public string Text { get; set; } = "";
public List<string> Tags { get; set; } = new List<string>();
diff --git a/sim/Statecraft.Sim/EventRules.cs b/sim/Statecraft.Sim/EventRules.cs
index 801e86e4a..0a38c3bb4 100644
--- a/sim/Statecraft.Sim/EventRules.cs
+++ b/sim/Statecraft.Sim/EventRules.cs
@@ -95,6 +95,7 @@ namespace Statecraft.Sim
}
}
CheckRequirementCycles(c);
+ CheckKinds(c);
CheckObjectives(c);
}
@@ -176,6 +177,75 @@ namespace Statecraft.Sim
}
}
+ /// <summary>R-ALT-005: how far a road runs before it folds back. DESIGN VALUE: owner-set, not a historical figure
+ /// (Q-ALT-5, "Accept all recommendations", owner, 17 October 2026, #945).</summary>
+ public const int MaxConsequenceDepth = 2;
+
+ /// <summary>A requirement that names a road not taken: `diverged: true`, a non-historical option of an event that has
+ /// a historical option, or any option of a consequence card.</summary>
+ internal static bool IsAlternativeRoad(Content c, EventRequirement r)
+ {
+ var parent = c.Events.First(x => x.Id == r.Event);
+ if (r.Diverged || parent.Kind == EventKinds.Consequence) return true;
+ return parent.Options.Any(o => o.Historical) && parent.Options.Any(o => o.Id == r.Option && !o.Historical);
+ }
+
+ /// <summary>R-ALT-005 to R-ALT-007. Called after every requirement is known to exist and to form no cycle, so the depth
+ /// walk ends.</summary>
+ static void CheckKinds(Content c)
+ {
+ var byId = c.Events.ToDictionary(e => e.Id);
+ var depth = new Dictionary<string, int>();
+ int Depth(GameEvent e)
+ {
+ if (depth.TryGetValue(e.Id, out var d)) return d;
+ d = e.Kind != EventKinds.Consequence ? 0 : 1 + e.Requires.Select(r => Depth(byId[r.Event])).DefaultIfEmpty(0).Max();
+ depth[e.Id] = d;
+ return d;
+ }
+ foreach (var e in c.Events)
+ {
+ string F(string field) => $"events[{e.Id}].{field}";
+ if (e.Kind != EventKinds.Historical && e.Kind != EventKinds.Consequence && e.Kind != EventKinds.Reconvergence)
+ throw new ContentException(e.File, F("kind"), $"'{e.Kind}' must be historical, consequence or reconvergence");
+ if (e.Kind != EventKinds.Consequence)
+ {
+ // Only a consequence card may follow one: the record never raises a consequence card, and a historical
+ // event in the middle of a chain would reset the depth cap.
+ for (int i = 0; i < e.Requires.Count; i++)
+ if (byId[e.Requires[i].Event].Kind == EventKinds.Consequence)
+ throw new ContentException(e.File, F($"requires[{i}]"), $"only a consequence card may follow a consequence card ('{e.Requires[i].Event}')");
+ // kind: reconvergence carries no rule of its own until its variants arrive (#952).
+ continue;
+ }
+ if (e.Objective != "") throw new ContentException(e.File, F("objective"), "a consequence card is not an objective's card");
+ if (e.Anchor == "hard") throw new ContentException(e.File, F("anchor"), "a consequence card is soft: it exists only on a road not taken");
+ if (e.Options.Any(o => o.Historical)) throw new ContentException(e.File, F("options"), "a consequence card has no historical option");
+ if (!e.Requires.Any(r => IsAlternativeRoad(c, r)))
+ throw new ContentException(e.File, F("requires"), "a consequence card follows a road not taken: at least one requirement names an option that did not happen, or diverged: true");
+ var bare = e.Options.FirstOrDefault(o => o.Alternative == null);
+ if (bare != null)
+ throw new ContentException(e.File, F($"options[{bare.Id}].alternative"), "every option of a consequence card says who proposed it, or basis: design");
+ for (int i = 0; i < e.Requires.Count; i++)
+ {
+ var r = e.Requires[i];
+ var parent = byId[r.Event];
+ // R-ALT-007: the card carries the sensitive tags of every event it requires, so the no-gain rule covers it.
+ foreach (var tag in parent.Tags.Where(SensitiveTags.Contains).OrderBy(t => t, StringComparer.OrdinalIgnoreCase))
+ if (!e.Tags.Contains(tag, StringComparer.OrdinalIgnoreCase))
+ throw new ContentException(e.File, F("tags"), $"must carry '{tag}', as '{parent.Id}' does");
+ if (!IsAlternativeRoad(c, r)) continue;
+ // R-ALT-006, the Ferguson gate (Q-ALT-3 (a)): the road must be one contemporaries are recorded proposing or debating.
+ var roads = r.Diverged ? parent.Options.Where(o => !o.Historical) : parent.Options.Where(o => o.Id == r.Option);
+ var unrecorded = roads.FirstOrDefault(o => o.Alternative == null || !o.Alternative.IsConsidered);
+ if (unrecorded != null)
+ throw new ContentException(e.File, F($"requires[{i}]"), $"follows '{parent.Id}/{unrecorded.Id}', which nobody is recorded proposing ({(unrecorded.Alternative == null ? "no alternative record" : "basis: design")})");
+ }
+ if (Depth(e) > MaxConsequenceDepth)
+ throw new ContentException(e.File, F("requires"), FormattableString.Invariant($"this road runs {Depth(e)} cards deep; the most is {MaxConsequenceDepth} (Q-ALT-5)"));
+ }
+ }
+
/// <summary>R-ALT-003: the shape of an option's `alternative` record.</summary>
static void CheckAlternative(GameEvent e, EventOption o, string at)
{
diff --git a/sim/Statecraft.Sim/EventSystem.cs b/sim/Statecraft.Sim/EventSystem.cs
index 04d4767f8..42edd5d57 100644
--- a/sim/Statecraft.Sim/EventSystem.cs
+++ b/sim/Statecraft.Sim/EventSystem.cs
@@ -15,7 +15,7 @@ namespace Statecraft.Sim
/// <summary>Fires every unfired event whose `requires` (if any) is met, whose window [From, To) overlaps the turn just played,
/// [<paramref name="turnStart"/>, s.Date), or contains s.Date; <paramref name="turnStart"/> defaults to s.Date
/// (game start). Every eligible hard anchor fires; MaxSoftEventsPerTurn caps only the non-hard events per turn,
- /// which fill the slots that remain (max(0, cap - hard count)) in the usual order (From, then id). The fired
+ /// which fill the slots that remain (max(0, cap - hard count)) in the usual order (consequence cards first, R-ALT-008, then From, then id). The fired
/// events keep the usual order.
/// Late fire: an event whose window overlapped the turn just played can fire after its window has ended; its
/// conditions are evaluated at the end of the turn, and its text is filled at the last in-window day
@@ -31,7 +31,9 @@ namespace Statecraft.Sim
// A late fire can come after a dated indicator's window has ended (chapters design 3.2): a condition on it is not met.
.Where(e => e.Conditions.All(k => s.Indicators.TryGetValue(k.Indicator, out var v)
&& (!k.Min.HasValue || v >= k.Min.Value) && (!k.Max.HasValue || v <= k.Max.Value)))
- .OrderBy(e => e.From).ThenBy(e => e.Id, StringComparer.Ordinal)
+ // R-ALT-008: a road the player took is not crowded out of its window. With no consequence card eligible the first
+ // key is the same for every event, and (From, id) is a total order (ids are unique), so the order is as before.
+ .OrderBy(e => e.Kind == EventKinds.Consequence ? 0 : 1).ThenBy(e => e.From).ThenBy(e => e.Id, StringComparer.Ordinal)
.ToList();
var hardCount = eligible.Count(e => e.Anchor == "hard");
var chosen = new HashSet<string>(eligible.Where(e => e.Anchor == "hard")