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: standing orders, fortify and hold (GDD Phase 5 PR 7, R-ORDER-001 to R-ORDER-003, fixes #746) (#1071)

Beri1d050133121f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 93d18ac07..adc23c3f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,12 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [Unreleased]
### Added
+- Standing orders (GDD Phase 5 PR 7): `UnitOrder(unit, fortify / hold)` gives one of the player's military units a
+ standing order that stays until the player changes it. Fortify is free, is set by the end of the turn it is given and
+ is lost when the unit leaves its hex (Q-HOLD-1); hold acts on the unit's own hex only and intercepts nothing (Q-HOLD-2).
+ `Orders.DefencePercent` gives combat (PR 8) the defence: fortify 125% (owner-decided, 19 Oct 2026) and hold 100% of strength (design
+ values; the balance pass #813 may tune both). Orders are free (D-A6). No golden moves: nothing gives an order yet
+ (R-ORDER-001 to R-ORDER-003; fixes #746, refs #385).
- The ministers reach the GDD systems (D-H3's first slice, refs #808): the Labour minister's office scales housing and
industry construction, the Agriculture minister's office pioneer and field work, and the Immigration minister's
office refugee absorption, each at the cabinet multiplier (competence x budget share) on the turn's date. Prices and
diff --git a/content/rules.yaml b/content/rules.yaml
index 72d3b82c4..467908968 100644
--- a/content/rules.yaml
+++ b/content/rules.yaml
@@ -17,6 +17,7 @@ attention_cost:
cancel_training: 0.5 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6)
pioneer_work: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free)
stop_work: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free)
+ unit_order: 0 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6: unit orders are free; R-ORDER-001, #746)
start_project: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6, D-C5, Q-PROJ-5: the map action's cost)
cancel_project: 0.5 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6, D-C5, Q-PROJ-5: cancel_training's cost)
buy_arms: 1 # DESIGN VALUE: owner-set balance, not a historical figure (D-A6, D-G6, #781: one order, whatever the quantity)
@@ -113,6 +114,12 @@ mvp:
# is a historical figure; the Phase 7 balance pass (PR 12) sets the final ceiling.
defeat_turns: 3 # DESIGN VALUE: owner-set balance, not a historical figure (D-B5, Q-DEF-2: turn ends in a row with Money and Food exhausted)
debt_ceiling: 250 # DESIGN VALUE: owner-set balance, not a historical figure (D-B5, Q-DEF-1: IL millions of debt at which Money is exhausted)
+ # Standing orders (R-ORDER-002, R-ORDER-003; Q-HOLD-1 "(a) 1 turn, free, lost on move" and Q-HOLD-2 "(a) Own hex, no
+ # interception", owner, 15 October 2026, #375). A unit's defence in percent of its strength. Proposed in Phase 5 PR 7
+ # (#746): fortify 125 was decided by the owner on 19 October 2026 (PR #1071, https://github.com/eyalgolan/statecraft-israel/pull/1071#issuecomment-6259021297); hold stays at 100
+ # (it adds nothing, it keeps the position). Not play-tested (combat is PR 8); the balance pass (#813) may tune both.
+ fortify_defence_percent: 125 # DESIGN VALUE: owner-set balance, not a historical figure (D-G4, Q-HOLD-1: a fortified unit's defence, percent; owner-decided 19 Oct 2026, #1071)
+ hold_defence_percent: 100 # DESIGN VALUE: owner-set balance, not a historical figure (D-G4, Q-HOLD-2: a holding unit's defence, percent)
# Delegation and loyalty (R-EVT-003; #107, owner, 18 October 2026: "Yes: minister loyalty changes a delegated event's
# outcome, with labelled values in the PR"). A minister below the floor still picks as competence says, but carries the
# decision out half-heartedly: only the share of each numeric effect lands. The floor is 5 because people.yaml rates
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 7852527d6..c470fb928 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -142,6 +142,16 @@ R-UNIT-001: A military unit is a group at formation scale, one token per formati
R-UNIT-002: A unit's side, strength, order and order target are written into the state hash only when they are not at their default ("" or 0), after its service (R-LOOP-002's rule), so a halutz unit's hash text, and every golden, is unchanged.
+## Standing orders
+
+Phase 5 PR 7 (#746). Q-HOLD-1, "(a) 1 turn, free, lost on move", and Q-HOLD-2, "(a) Own hex, no interception" (owner, 15 October 2026, #375). The two percents are design values this PR proposes from avlco's option 1 on #746; the owner may override them.
+
+R-ORDER-001: `UnitOrder(unit, order)` gives one of the player's military units the standing order `fortify` or `hold`, replacing the one it had. The unit keeps its order, turn after turn, until the player gives another; moving clears fortify (Q-HOLD-1): in the resolver after combat (step 2), in id order, a unit no longer on the hex its fortify names (`OrderTarget`, "q,r") loses the order. The order is refused with the state unchanged and a reason for an unknown order or unit, a unit with no side (a halutz), a unit of another side, or the order the unit already has (fortify on the hex it fortifies). It costs `attention_cost.unit_order` (0, D-A6) and is refused in the legacy loop.
+
+R-ORDER-002: Fortify takes one turn to set and costs no Arms or Money (Q-HOLD-1). Given, it reads `fortifying` and names the unit's hex; in the same resolver step it becomes `fortify`, so the combat of the turn it is given sees no bonus. A fortified unit on its hex defends at `mvp.fortify_defence_percent` of its strength (`Orders.DefencePercent`; real value 125), and from the moment it leaves the hex at 100.
+
+R-ORDER-003: Hold acts on the unit's own hex only and does not intercept or stop any enemy move, past or next to it (Q-HOLD-2). It names no hex and stays when the unit moves. A holding unit defends at `mvp.hold_defence_percent` of its strength (real value 100: hold keeps the position and adds nothing); a unit with no order defends at 100.
+
## Objectives
R-OBJ-001: An objective (`objectives.yaml`) names its condition, `completes_when: { site_built: <site> }` (R-OBJ-004's `absorbed` has no site, so the site rules here apply only to `site_built`), a designated site of kind yishuv whose `founded` date must equal the objective's `reference_date`. In the last step of each GDD turn (spec §2.3, step 11; D-A6), in id order, an objective whose site is built and that is not yet recorded is recorded once, with the turn's end date (the site's `BuiltOn`). Recording it again, or in the legacy loop, changes nothing; a stopped build completes nothing.
diff --git a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs b/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
index 7c42d9bee..6a36cc651 100644
--- a/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
+++ b/sim/Statecraft.Sim.Tests/CommandGuardTests.cs
@@ -23,6 +23,7 @@ public class CommandGuardTests
[typeof(CancelTraining)] = new CancelTraining(1),
[typeof(PioneerWork)] = new PioneerWork(1, "build_yishuv", "mefalsim"),
[typeof(StopWork)] = new StopWork(1),
+ [typeof(UnitOrder)] = new UnitOrder(1, "fortify"),
[typeof(StartProject)] = new StartProject("housing", "tel_aviv", 1, 0),
[typeof(CancelProject)] = new CancelProject(1),
[typeof(BuyArms)] = new BuyArms(0), // refused (fewer than one unit), as GovernmentTests.ARefusedGddOrderRefundsItsAttention needs
diff --git a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
index 636d44c8e..cec5cf1f6 100644
--- a/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
+++ b/sim/Statecraft.Sim.Tests/DesignValuesTests.cs
@@ -53,6 +53,9 @@ public class DesignValuesTests
("rules.yaml", "mvp.overflow_condition_loss"),
("rules.yaml", "mvp.defeat_turns"),
("rules.yaml", "mvp.debt_ceiling"),
+ ("rules.yaml", "mvp.fortify_defence_percent"), // R-ORDER-002, #746 (Q-HOLD-1)
+ ("rules.yaml", "mvp.hold_defence_percent"), // R-ORDER-003, #746 (Q-HOLD-2)
+ ("rules.yaml", "attention_cost.unit_order"), // R-ORDER-001, #746 (D-A6)
("rules.yaml", "mvp.delegation_loyalty_floor"), // R-EVT-003, #107
("rules.yaml", "mvp.disloyal_effect_share"),
// Q-START-1 (owner, 15 October 2026, #375): no city has a sourced housing stock or job count, so every city's
diff --git a/sim/Statecraft.Sim.Tests/Fixture.cs b/sim/Statecraft.Sim.Tests/Fixture.cs
index ccc847968..044a0a46b 100644
--- a/sim/Statecraft.Sim.Tests/Fixture.cs
+++ b/sim/Statecraft.Sim.Tests/Fixture.cs
@@ -240,7 +240,7 @@ series:
}
/// <summary>The fixture's attention_cost line with the GDD command kinds added (replaces "map_action: 1 }").</summary>
- public const string GddCosts = "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1, pioneer_work: 0, stop_work: 0, start_project: 1, cancel_project: 0.5, buy_arms: 1 }";
+ public const string GddCosts = "map_action: 1, assign_workers: 1, train: 1, cancel_training: 1, pioneer_work: 0, stop_work: 0, unit_order: 0, start_project: 1, cancel_project: 0.5, buy_arms: 1 }";
public const string GddRules = @"
mvp:
@@ -277,6 +277,8 @@ mvp:
overflow_condition_loss: 0.2
defeat_turns: 3
debt_ceiling: 10
+ fortify_defence_percent: 150
+ hold_defence_percent: 120
delegation_loyalty_floor: 5
disloyal_effect_share: 0.5
";
diff --git a/sim/Statecraft.Sim.Tests/OrdersTests.cs b/sim/Statecraft.Sim.Tests/OrdersTests.cs
new file mode 100644
index 000000000..3486dc823
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/OrdersTests.cs
@@ -0,0 +1,162 @@
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Sim;
+
+/// <summary>Standing orders (GDD Phase 5 PR 7, #746): UnitOrder(unit, fortify / hold). Q-HOLD-1 is the owner's "(a) 1 turn,
+/// free, lost on move" and Q-HOLD-2 his "(a) Own hex, no interception" (15 October 2026, #375). The fixture's defence
+/// percents are fixture values (fortify 150, hold 120), chosen apart from 100 so a test sees which one applied.</summary>
+public class OrdersTests
+{
+ /// <summary>An Israeli soldier, an Egyptian unit (an enemy side) and the fixture's halutz types.</summary>
+ const string Types = Fixture.GddUnitTypes
+ + " - { id: soldier, kind: unit, side: israel, class: infantry }\n"
+ + " - { id: enemy, kind: unit, side: egypt, class: infantry }\n";
+
+ static Content Load() =>
+ ContentLoader.Load(Fixture.Write(Fixture.Gdd(new Dictionary<string, string> { ["unit_types.yaml"] = Types })));
+
+ static GameState With(Content c, params Unit[] units)
+ {
+ var s = Simulation.NewGame(c, 1, Mode.Historical);
+ foreach (var u in units) s.Units.Add(u.Id, u);
+ return s;
+ }
+
+ static Unit Soldier(int id, int q, int r) => new Unit(id, "soldier", q, r, side: "israel");
+ static Unit Enemy(int id, int q, int r) => new Unit(id, "enemy", q, r, side: "egypt");
+
+ static int Defence(Content c, GameState s, int id) => Orders.DefencePercent(c.RulesAt(s.Date).Mvp!, s.Units[id]);
+
+ // R-ORDER-001: an order stands, turn after turn, until the player gives another.
+ [Fact]
+ public void AnOrderStandsUntilChanged()
+ {
+ var c = Load();
+ var s = With(c, Soldier(1, 2, 1));
+ var r = Simulation.Step(c, s, new Command[] { new UnitOrder(1, Orders.Hold) });
+ Assert.Empty(r.Rejected);
+ for (int i = 0; i < 3; i++) r = Simulation.Step(c, r.State, new Command[0]);
+ Assert.Equal((Orders.Hold, ""), (r.State.Units[1].Order, r.State.Units[1].OrderTarget));
+ r = Simulation.Step(c, r.State, new Command[] { new UnitOrder(1, Orders.Fortify) });
+ Assert.Empty(r.Rejected);
+ for (int i = 0; i < 3; i++) r = Simulation.Step(c, r.State, new Command[0]);
+ Assert.Equal((Orders.Fortify, "2,1"), (r.State.Units[1].Order, r.State.Units[1].OrderTarget));
+ r = Simulation.Step(c, r.State, new Command[] { new UnitOrder(1, Orders.Hold) });
+ Assert.Equal((Orders.Hold, ""), (r.State.Units[1].Order, r.State.Units[1].OrderTarget));
+ }
+
+ // R-ORDER-002: fortify is not set during the turn it is given (combat, resolver step 2, sees no bonus), is set by the end
+ // of that turn, and costs nothing: no Attention, no Money, nothing else in the state but the unit's order.
+ [Fact]
+ public void FortifyTakesOneTurnAndCostsNothing()
+ {
+ var c = Load();
+ var s = With(c, Soldier(1, 2, 1));
+ var given = s.Clone();
+ Assert.Null(Orders.Give(given, 1, Orders.Fortify, new List<Cause>()));
+ Assert.Equal(Orders.Fortifying, given.Units[1].Order);
+ Assert.Equal(100, Defence(c, given, 1)); // the turn it is given
+
+ var with = Simulation.Step(c, s, new Command[] { new UnitOrder(1, Orders.Fortify) });
+ var without = Simulation.Step(c, s, new Command[0]);
+ Assert.Empty(with.Rejected);
+ Assert.Equal(150, Defence(c, with.State, 1)); // from the next turn: the fixture's fortify percent
+ Assert.Equal(without.State.Attention, with.State.Attention);
+ Assert.Equal(without.State.Describe().Replace("1:soldier@2,1|side=israel", "1:soldier@2,1|side=israel|order=fortify|target=2,1"),
+ with.State.Describe());
+ }
+
+ // R-ORDER-001, R-ORDER-002: a fortified unit that leaves its hex loses fortify by the end of the turn, and has no bonus
+ // from the moment it has left. This is the Settle backstop for a changed unit record that still carries its old order.
+ [Fact]
+ public void MovingClearsFortify()
+ {
+ var c = Load();
+ var s = Simulation.Step(c, With(c, Soldier(1, 2, 1)), new Command[] { new UnitOrder(1, Orders.Fortify) }).State;
+ var u = s.Units[1];
+ s.Units[1] = new Unit(u.Id, u.Type, 3, 1, u.Service, u.Side, u.Strength, u.Order, u.OrderTarget); // a changed record still carrying its old order
+ Assert.Equal(100, Defence(c, s, 1));
+ var r = Simulation.Step(c, s, new Command[0]);
+ Assert.Equal(("", ""), (r.State.Units[1].Order, r.State.Units[1].OrderTarget));
+ Assert.Contains(r.Why, x => x.System == "map" && x.Message == "Unit 1 left hex 2,1 and is no longer fortified");
+
+ // Fortify given and then left in the same turn is never set.
+ var moved = s.Clone();
+ moved.Units[1] = new Unit(1, "soldier", 3, 1, side: "israel", order: Orders.Fortifying, orderTarget: "2,1");
+ var left = Simulation.Step(c, moved, new Command[0]).State.Units[1];
+ Assert.Equal(("", ""), (left.Order, left.OrderTarget));
+ }
+
+ // R-ORDER-003: hold acts on the unit itself and nothing around it: an enemy unit next to it and one past it keep their
+ // hexes through the turn, and neither they nor a player unit beside it change their defence. Enemy moves come with the
+ // enemy AI (Phase 5 PR 10); nothing in hold stops one.
+ [Fact]
+ public void HoldNeverIntercepts()
+ {
+ var c = Load();
+ var s = With(c, Soldier(1, 2, 1), Soldier(2, 3, 1), Enemy(3, 1, 1), Enemy(4, 0, 1));
+ var r = Simulation.Step(c, s, new Command[] { new UnitOrder(1, Orders.Hold) });
+ Assert.Empty(r.Rejected);
+ Assert.Equal(120, Defence(c, r.State, 1)); // the fixture's hold percent, on its own hex
+ foreach (var id in new[] { 2, 3, 4 })
+ {
+ Assert.Equal(100, Defence(c, r.State, id));
+ Assert.Equal((s.Units[id].Q, s.Units[id].R, ""), (r.State.Units[id].Q, r.State.Units[id].R, r.State.Units[id].Order));
+ }
+ }
+
+ // R-ORDER-001: refusals leave the state as it was.
+ [Theory]
+ [InlineData(9, "fortify", "There is no such unit")]
+ [InlineData(1, "attack", "That order is not known")]
+ [InlineData(5, "hold", "Only a military unit takes that order")]
+ [InlineData(3, "hold", "That unit is not yours")]
+ [InlineData(2, "hold", "That unit already has that order")]
+ public void BadOrdersAreRefused(int unit, string order, string reason)
+ {
+ var c = Load();
+ var s = With(c, Soldier(1, 2, 1), new Unit(2, "soldier", 3, 1, side: "israel", order: Orders.Hold), Enemy(3, 0, 1), new Unit(5, "halutz", 4, 1));
+ var r = Simulation.Step(c, s, new Command[] { new UnitOrder(unit, order) });
+ Assert.Equal(reason, Assert.Single(r.Rejected).Reason);
+ Assert.Equal(Simulation.Step(c, s, new Command[0]).State.Describe(), r.State.Describe());
+ }
+
+ // R-ORDER-001: fortify again on the hex it is fortifying is refused; the legacy loop refuses the order before charging.
+ [Fact]
+ public void FortifyTwiceIsRefusedAndTheLegacyLoopRefusesTheOrder()
+ {
+ var c = Load();
+ var s = Simulation.Step(c, With(c, Soldier(1, 2, 1)), new Command[] { new UnitOrder(1, Orders.Fortify) }).State;
+ Assert.Equal("That unit already has that order", Assert.Single(Simulation.Step(c, s, new Command[] { new UnitOrder(1, Orders.Fortify) }).Rejected).Reason);
+
+ var legacy = ContentLoader.Load(Fixture.Write());
+ var g = Simulation.NewGame(legacy, 1, Mode.Historical);
+ Assert.Equal("That order is not available in this game", Assert.Single(Simulation.Step(legacy, g, new Command[] { new UnitOrder(1, Orders.Hold) }).Rejected).Reason);
+ }
+
+ // R-ORDER-002, R-ORDER-003: the real game's values, design values; fortify 125 is owner-decided (19 Oct 2026, #1071), hold 100 is
+ // this PR's proposal: fortify a quarter more in defence, hold nothing; the order is free (D-A6).
+ [Fact]
+ public void TheRealGameSetsFortifyAtOneQuarterMoreAndHoldNothing()
+ {
+ var c = ContentLoader.Load(RealContentTests.ContentRoot());
+ var m = c.Rules.Mvp!;
+ Assert.Equal((125, 100), (m.FortifyDefencePercent, m.HoldDefencePercent));
+ Assert.Equal(0, c.Rules.AttentionCost[Orders.Kind]);
+ }
+
+ // R-ORDER-002: both percents are required in the GDD loop and at least 1.
+ [Theory]
+ [InlineData(" fortify_defence_percent: 150\n", "", "mvp.fortify_defence_percent", "required when eras.yaml systems.loop is gdd")]
+ [InlineData(" hold_defence_percent: 120\n", "", "mvp.hold_defence_percent", "required when eras.yaml systems.loop is gdd")]
+ [InlineData(" hold_defence_percent: 120\n", " hold_defence_percent: 0\n", "mvp.hold_defence_percent", "must be >= 1")]
+ [InlineData(" fortify_defence_percent: 150\n", " fortify_defence_percent: 0\n", "mvp.fortify_defence_percent", "must be >= 1")]
+ public void ThePercentsAreRequired(string from, string to, string field, string message)
+ {
+ var files = Fixture.Gdd(new Dictionary<string, string> { ["unit_types.yaml"] = Types });
+ files["rules.yaml"] = files["rules.yaml"].Replace(from, to);
+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(files)));
+ Assert.Equal(field, ex.Field);
+ Assert.Contains(message, ex.Message);
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
index e690f507b..286056fad 100644
--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs
+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs
@@ -27,7 +27,7 @@ public class SaveGameTests
new Command[] { new AllocateBudget(new Dictionary<string, double> { ["finance_minister"] = 0.75, ["defense_minister"] = 0.25 }) },
new Command[] { new Appoint("finance_minister", "pm_one"), new MapAction("housing", 2, 0) },
new Command[] { new SetPolicy("odd id with spaces%", 0.5), new MapAction("transit_camp", 4, 0) },
- new Command[] { new AssignWorkers("town_a", "job", 1) }, // a GDD order: the legacy fixture refuses it
+ new Command[] { new AssignWorkers("town_a", "job", 1), new UnitOrder(1, "hold") }, // GDD orders: the legacy fixture refuses them
new Command[] { new Train("town_a", "halutz", 1), new CancelTraining(1) }, // GDD orders too
new Command[] { new PioneerWork(1, "build_yishuv", "site_a"), new StopWork(1), new StartProject("housing", "town_a", 1, 1), new CancelProject(1), new BuyArms(2) },
new Command[] { new SecurityOrder(1) }, new Command[0],
diff --git a/sim/Statecraft.Sim/AttentionSystem.cs b/sim/Statecraft.Sim/AttentionSystem.cs
index 5fad4662e..ecc4bbac0 100644
--- a/sim/Statecraft.Sim/AttentionSystem.cs
+++ b/sim/Statecraft.Sim/AttentionSystem.cs
@@ -8,11 +8,11 @@ namespace Statecraft.Sim
public static class AttentionSystem
{
static readonly HashSet<string> Kinds = new HashSet<string>
- { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms" };
+ { "set_policy", "allocate_budget", "choose_event_option", "set_mobilization", "security_order", "appoint", "map_action", "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "unit_order" };
/// <summary>The kinds only the GDD v0.1 loop runs. Rules price them only when systems.loop is gdd, and the legacy loop
/// refuses them before charging Attention.</summary>
- static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms" };
+ static readonly HashSet<string> GddKinds = new HashSet<string> { "assign_workers", "train", "cancel_training", "pioneer_work", "stop_work", "start_project", "cancel_project", "buy_arms", "unit_order" };
public static IReadOnlyCollection<string> CommandKinds => Kinds;
diff --git a/sim/Statecraft.Sim/Commands.cs b/sim/Statecraft.Sim/Commands.cs
index 1451c2d15..c164429c1 100644
--- a/sim/Statecraft.Sim/Commands.cs
+++ b/sim/Statecraft.Sim/Commands.cs
@@ -103,6 +103,15 @@ namespace Statecraft.Sim
public StopWork(int unit) { Unit = unit; }
}
+ /// <summary>Gives unit <see cref="Unit"/> the standing order <see cref="Order"/>, fortify or hold (Orders.Give, R-ORDER-001
+ /// to R-ORDER-003). GDD v0.1 loop only.</summary>
+ public sealed class UnitOrder : Command
+ {
+ public override string Kind => Orders.Kind;
+ public int Unit { get; } public string Order { get; }
+ public UnitOrder(int unit, string order) { Unit = unit; Order = order; }
+ }
+
/// <summary>Starts city project <see cref="ProjectKind"/> (a projects.yaml id) for <see cref="City"/> on hex (<see cref="Q"/>,
/// <see cref="R"/>) (Projects.StartCity, R-PROJ-001). GDD v0.1 loop only.</summary>
public sealed class StartProject : Command
@@ -162,6 +171,7 @@ namespace Statecraft.Sim
case CancelTraining _: break;
case PioneerWork p: Text(p.Action, "Action"); Text(p.Site, "Site"); break;
case StopWork _: break;
+ case UnitOrder o: Text(o.Order, "Order"); break;
case StartProject p: Text(p.ProjectKind, "ProjectKind"); Text(p.City, "City"); break;
case CancelProject _: break;
case BuyArms _: break;
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index 116087d3a..a36f350fa 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -585,6 +585,12 @@ namespace Statecraft.Sim
/// <summary>The debt, in IL millions, at or above which Money is exhausted (R-END-001; D-B5, Q-DEF-1). Required in the
/// GDD loop, a finite number >= 0.</summary>
public double? DebtCeiling { get; set; }
+ /// <summary>A fortified unit's defence, in percent of its strength (R-ORDER-002; D-G4, Q-HOLD-1). Required in the GDD
+ /// loop, at least 1. Combat (Phase 5 PR 8) reads it through Orders.DefencePercent.</summary>
+ public int? FortifyDefencePercent { get; set; }
+ /// <summary>A holding unit's defence, in percent of its strength (R-ORDER-003; D-G4, Q-HOLD-2). Required in the GDD
+ /// loop, at least 1.</summary>
+ public int? HoldDefencePercent { get; set; }
/// <summary>A minister whose loyalty is below this carries a delegated decision out half-heartedly (R-EVT-003; #107,
/// owner, 18 October 2026). Required in the GDD loop, 0 to 10 (0: nobody is below it).</summary>
public int? DelegationLoyaltyFloor { get; set; }
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index cb28fdc4d..d18dfe7cc 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -1178,6 +1178,11 @@ namespace Statecraft.Sim
if (m.DefeatTurns < 1) throw new ContentException(file, "mvp.defeat_turns", "must be >= 1");
if (m.DebtCeiling == null) throw new ContentException(file, "mvp.debt_ceiling", "required when eras.yaml systems.loop is gdd");
if (!(m.DebtCeiling >= 0 && IsFinite(m.DebtCeiling.Value))) throw new ContentException(file, "mvp.debt_ceiling", "must be a finite number >= 0");
+ // R-ORDER-002, R-ORDER-003 (#746): required, so a missing key is never read as 0 (a unit with no defence).
+ if (m.FortifyDefencePercent == null) throw new ContentException(file, "mvp.fortify_defence_percent", "required when eras.yaml systems.loop is gdd");
+ if (m.FortifyDefencePercent < 1) throw new ContentException(file, "mvp.fortify_defence_percent", "must be >= 1");
+ if (m.HoldDefencePercent == null) throw new ContentException(file, "mvp.hold_defence_percent", "required when eras.yaml systems.loop is gdd");
+ if (m.HoldDefencePercent < 1) throw new ContentException(file, "mvp.hold_defence_percent", "must be >= 1");
// R-EVT-003 (#107): required, so a missing key is never read as 0 (no floor, or a disloyal minister who does nothing).
if (m.DelegationLoyaltyFloor == null) throw new ContentException(file, "mvp.delegation_loyalty_floor", "required when eras.yaml systems.loop is gdd");
if (m.DelegationLoyaltyFloor < 0 || m.DelegationLoyaltyFloor > 10) throw new ContentException(file, "mvp.delegation_loyalty_floor", "must be 0-10");
diff --git a/sim/Statecraft.Sim/Orders.cs b/sim/Statecraft.Sim/Orders.cs
new file mode 100644
index 000000000..9caf31e73
--- /dev/null
+++ b/sim/Statecraft.Sim/Orders.cs
@@ -0,0 +1,75 @@
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+
+namespace Statecraft.Sim
+{
+ /// <summary>Standing orders in the GDD v0.1 loop (Phase 5 PR 7; docs/rules/mvp.md R-ORDER-001 to R-ORDER-003). A unit's
+ /// order is fortify or hold. Fortify takes a turn to set, is free and is lost when the unit leaves its hex (Q-HOLD-1); hold
+ /// acts on the unit's own hex only and intercepts nothing (Q-HOLD-2). The order is free (D-A6).</summary>
+ public static class Orders
+ {
+ public const string Kind = "unit_order";
+ public const string Fortify = "fortify";
+ public const string Hold = "hold";
+
+ /// <summary>Fortify given this turn: the unit's Order until the turn's Settle step sets it (R-ORDER-002). Combat
+ /// (resolver step 2) runs before that step, so it never sees a fortify given the same turn.</summary>
+ public const string Fortifying = "fortifying";
+
+ /// <summary>The player's side (units_1948.yaml's id). Only the player's military units take orders.</summary>
+ const string PlayerSide = "israel";
+
+ /// <summary>The hex a fortify order names, as Unit.OrderTarget holds it: "q,r".</summary>
+ static string Hex(Unit u) => string.Format(CultureInfo.InvariantCulture, "{0},{1}", u.Q, u.R);
+
+ static Unit With(Unit u, string order, string target) =>
+ new Unit(u.Id, u.Type, u.Q, u.R, u.Service, u.Side, u.Strength, order, target);
+
+ /// <summary>R-ORDER-001: gives the unit its standing order, replacing any other. Fortify names the unit's hex and starts
+ /// as Fortifying; hold names nothing, as it acts where the unit is. Refused, state untouched, for an unknown order or
+ /// unit, a unit with no side (a halutz), an enemy unit, or the order it already has.</summary>
+ internal static string? Give(GameState s, int unitId, string order, List<Cause> why)
+ {
+ if (order != Fortify && order != Hold) return "That order is not known";
+ if (!s.Units.TryGetValue(unitId, out var u)) return "There is no such unit";
+ if (u.Side == "") return "Only a military unit takes that order";
+ if (u.Side != PlayerSide) return "That unit is not yours";
+ var here = Hex(u);
+ var already = order == Hold ? u.Order == Hold : (u.Order == Fortify || u.Order == Fortifying) && u.OrderTarget == here;
+ if (already) return "That unit already has that order";
+ s.Units[unitId] = order == Fortify ? With(u, Fortifying, here) : With(u, Hold, "");
+ why.Add(new Cause("map", unitId.ToString(CultureInfo.InvariantCulture), 0, order == Fortify
+ ? $"Unit {unitId} is fortifying hex {here}; it is fortified from the end of the turn"
+ : $"Unit {unitId} holds hex {here}"));
+ return null;
+ }
+
+ /// <summary>R-ORDER-001, R-ORDER-002, in the resolver after combat: in id order, a unit no longer on the hex its fortify
+ /// names loses the order (moving clears fortify), and a fortify given this turn on the unit's hex is set.</summary>
+ public static void Settle(GameState s, List<Cause> why)
+ {
+ foreach (var u in s.Units.Values.ToList()) // Units is a SortedList: ascending id
+ {
+ if (u.Order != Fortify && u.Order != Fortifying) continue;
+ if (u.OrderTarget != Hex(u))
+ {
+ s.Units[u.Id] = With(u, "", "");
+ if (u.Order == Fortify)
+ why.Add(new Cause("map", u.Id.ToString(CultureInfo.InvariantCulture), 0,
+ $"Unit {u.Id} left hex {u.OrderTarget} and is no longer fortified"));
+ }
+ else if (u.Order == Fortifying) s.Units[u.Id] = With(u, Fortify, u.OrderTarget);
+ }
+ }
+
+ /// <summary>R-ORDER-002, R-ORDER-003: the unit's defence in percent of its strength, for combat (Phase 5 PR 8): the
+ /// fortify percent while it is fortified on the hex its order names, the hold percent while it holds, else 100.</summary>
+ public static int DefencePercent(MvpRules r, Unit u)
+ {
+ if (u.Order == Fortify && u.OrderTarget == Hex(u)) return r.FortifyDefencePercent!.Value;
+ if (u.Order == Hold) return r.HoldDefencePercent!.Value;
+ return 100;
+ }
+ }
+}
diff --git a/sim/Statecraft.Sim/SaveGame.cs b/sim/Statecraft.Sim/SaveGame.cs
index 93a1e191b..5b64cd1b5 100644
--- a/sim/Statecraft.Sim/SaveGame.cs
+++ b/sim/Statecraft.Sim/SaveGame.cs
@@ -123,6 +123,7 @@ namespace Statecraft.Sim
CancelTraining t => $"untrain {Int(t.Cohort)}",
PioneerWork p => $"pioneer {Int(p.Unit)} {Esc(p.Action)} {Esc(p.Site)}",
StopWork w => $"stop {Int(w.Unit)}",
+ UnitOrder o => $"order {Int(o.Unit)} {Esc(o.Order)}",
StartProject p => $"project {Esc(p.ProjectKind)} {Esc(p.City)} {Int(p.Q)} {Int(p.R)}",
CancelProject p => $"unproject {Int(p.Project)}",
BuyArms a => $"arms {Int(a.Count)}",
@@ -219,6 +220,7 @@ namespace Statecraft.Sim
case "untrain": Arity(2); return new CancelTraining(I(f[1]));
case "pioneer": Arity(4); return new PioneerWork(I(f[1]), Str(f[2]), Str(f[3]));
case "stop": Arity(2); return new StopWork(I(f[1]));
+ case "order": Arity(3); return new UnitOrder(I(f[1]), Str(f[2]));
case "project": Arity(5); return new StartProject(Str(f[1]), Str(f[2]), I(f[3]), I(f[4]));
case "unproject": Arity(2); return new CancelProject(I(f[1]));
case "arms": Arity(2); return new BuyArms(I(f[1]));
diff --git a/sim/Statecraft.Sim/Scenario.cs b/sim/Statecraft.Sim/Scenario.cs
index c1690dffa..c445c34de 100644
--- a/sim/Statecraft.Sim/Scenario.cs
+++ b/sim/Statecraft.Sim/Scenario.cs
@@ -22,7 +22,7 @@ namespace Statecraft.Sim
/// Kinds: set_policy (policy, level), allocate_budget (shares: {office: share}), choose_event_option (event, option),
/// set_mobilization (level), security_order (delta), appoint (office, person), map_action (action, q, r), assign_workers
/// (city, role, count), train (city, track, count), cancel_training (cohort), pioneer_work (unit, action, site), stop_work
- /// (unit; GDD content only). A turn with no
+ /// (unit), unit_order (unit, order; GDD content only). A turn with no
/// scripted command passes; events nobody answered are delegated, as in the game. A command the sim rejects fails the run.</summary>
public sealed class Scenario
{
@@ -65,6 +65,7 @@ namespace Statecraft.Sim
["map_action"] = new[] { "action", "q", "r" }, ["assign_workers"] = new[] { "city", "role", "count" },
["train"] = new[] { "city", "track", "count" }, ["cancel_training"] = new[] { "cohort" },
["pioneer_work"] = new[] { "unit", "action", "site" }, ["stop_work"] = new[] { "unit" },
+ ["unit_order"] = new[] { "unit", "order" },
["start_project"] = new[] { "project", "city", "q", "r" }, ["cancel_project"] = new[] { "project" },
["buy_arms"] = new[] { "count" },
};
@@ -96,6 +97,7 @@ namespace Statecraft.Sim
case "cancel_training": return new CancelTraining(Whole(c, "cohort"));
case "pioneer_work": return new PioneerWork(Whole(c, "unit"), Str(c, "action"), Str(c, "site"));
case "stop_work": return new StopWork(Whole(c, "unit"));
+ case "unit_order": return new UnitOrder(Whole(c, "unit"), Str(c, "order"));
case "start_project": return new StartProject(Str(c, "project"), Str(c, "city"), Whole(c, "q"), Whole(c, "r"));
case "cancel_project": return new CancelProject(Whole(c, "project"));
case "buy_arms": return new BuyArms(Whole(c, "count"));
@@ -138,6 +140,7 @@ namespace Statecraft.Sim
SecurityOrder o => o.Delta.ToString(CultureInfo.InvariantCulture), Appoint a => $"{a.Office} {a.Person}", MapAction m => $"{m.Action} {m.Q},{m.R}",
AssignWorkers w => $"{w.City} {w.Role} {w.Count}", Train t => $"{t.City} {t.Track} {t.Count}", CancelTraining t => t.Cohort.ToString(CultureInfo.InvariantCulture),
PioneerWork p => FormattableString.Invariant($"{p.Unit} {p.Action} {p.Site}"), StopWork w => w.Unit.ToString(CultureInfo.InvariantCulture),
+ UnitOrder o => FormattableString.Invariant($"{o.Unit} {o.Order}"),
StartProject p => FormattableString.Invariant($"{p.ProjectKind} {p.City} {p.Q},{p.R}"), CancelProject p => p.Project.ToString(CultureInfo.InvariantCulture),
BuyArms a => a.Count.ToString(CultureInfo.InvariantCulture),
_ => c.Kind,
diff --git a/sim/Statecraft.Sim/Simulation.cs b/sim/Statecraft.Sim/Simulation.cs
index 8624944e2..b9d377f0b 100644
--- a/sim/Statecraft.Sim/Simulation.cs
+++ b/sim/Statecraft.Sim/Simulation.cs
@@ -172,6 +172,8 @@ namespace Statecraft.Sim
return Projects.Start(c, s, p.Unit, p.Action, p.Site, why);
case StopWork w:
return Projects.Stop(c, s, w.Unit, why);
+ case UnitOrder o:
+ return Orders.Give(s, o.Unit, o.Order, why);
case StartProject p:
return Projects.StartCity(c, s, p.ProjectKind, p.City, p.Q, p.R, why);
case CancelProject p:
diff --git a/sim/Statecraft.Sim/TurnResolver.cs b/sim/Statecraft.Sim/TurnResolver.cs
index 6a71fbf92..d8124d567 100644
--- a/sim/Statecraft.Sim/TurnResolver.cs
+++ b/sim/Statecraft.Sim/TurnResolver.cs
@@ -15,6 +15,7 @@ namespace Statecraft.Sim
if (!c.IsGdd) return;
var r = c.RulesAt(s.Date).Mvp!; // the loader requires it in the GDD loop
// 1-3. Enemy orders, combat, capture: Phase 5.
+ Orders.Settle(s, why); // 3b. after combat: fortify given this turn is set, and lost where a unit left its hex (R-ORDER-002)
Training.Progress(c, s, why); // 4. training
Projects.Advance(c, s, next, why); // 5. construction
Projects.AdvanceCity(c, s, next, why); // and the city projects (R-PROJ-003)
diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.cs
index ae9eb76fb..a95145814 100644
--- a/unity/Assets/Scripts/UI/SimBridge.cs
+++ b/unity/Assets/Scripts/UI/SimBridge.cs
@@ -59,6 +59,7 @@ namespace Statecraft.Game.UI
CancelTraining x => FormattableString.Invariant($"untrain:{x.Cohort}"),
PioneerWork w => FormattableString.Invariant($"unit:{w.Unit}"),
StopWork w => FormattableString.Invariant($"unit:{w.Unit}"),
+ UnitOrder o => FormattableString.Invariant($"order:{o.Unit}"),
StartProject p => FormattableString.Invariant($"project:{p.Q},{p.R}"),
CancelProject x => FormattableString.Invariant($"unproject:{x.Project}"),
_ => c.Kind,
@@ -127,6 +128,8 @@ namespace Statecraft.Game.UI
return Unknown("unit", w.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)))
?? Unknown("pioneer_work", w.Action, new[] { Projects.BuildYishuv }) ?? Unknown("site", w.Site, Content.Sites.Select(x => x.Id));
case StopWork w: return Unknown("unit", w.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)));
+ // Standing orders (#746): the unit id only; the sim refuses an unknown order, a halutz or an enemy unit itself.
+ case UnitOrder o: return Unknown("unit", o.Unit.ToString(System.Globalization.CultureInfo.InvariantCulture), State.Units.Keys.Select(k => k.ToString(System.Globalization.CultureInfo.InvariantCulture)));
// City projects (#735): ids only; the sim refuses a far or taken hex, the policy gate and the turn's limit itself.
case StartProject p:
return Unknown("city_project", p.ProjectKind, Content.ProjectKinds.Select(x => x.Id)) ?? Unknown("city", p.City, Content.Cities.Select(x => x.Id));
diff --git a/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs b/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs
index 894b829bd..4c643750e 100644
--- a/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs
+++ b/unity/Assets/Tests/EditMode/SimBridgeGuardTests.cs
@@ -31,6 +31,7 @@ public class SimBridgeGuardTests
[typeof(CancelTraining)] = new CancelTraining(1),
[typeof(PioneerWork)] = new PioneerWork(1, "build_yishuv", "mefalsim"),
[typeof(StopWork)] = new StopWork(1),
+ [typeof(UnitOrder)] = new UnitOrder(1, "fortify"),
[typeof(StartProject)] = new StartProject("housing", "tel_aviv", 1, 0),
[typeof(CancelProject)] = new CancelProject(1),
[typeof(BuyArms)] = new BuyArms(0),