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.

Civ movement S1b: with full points a unit can always move one hex (Refs #1398) (#1445)

Eyal Golaneddd66e65c63
diff --git a/changelog.d/1398-2a.md b/changelog.d/1398-2a.md
new file mode 100644
index 000000000..c53f45976
--- /dev/null
+++ b/changelog.d/1398-2a.md
@@ -0,0 +1,2 @@
+- A unit that has not moved this turn can always move one hex, even into a hex that costs more than all its movement
+ points; that move spends them all (R-MOVE-001; the owner's ruling "No, strict like Civ VI", #1398).
diff --git a/docs/rules/mvp.md b/docs/rules/mvp.md
index 5aaf20f0f..f0d700846 100644
--- a/docs/rules/mvp.md
+++ b/docs/rules/mvp.md
@@ -186,7 +186,7 @@ R-COR-003: A corridor is complete when every one of its segments is built, in an
Phase 5 PR 5 (#744). The numbers are design values this PR proposed (Q-MOVE-1, Q-MOVE-3; owner, 15 October 2026, #375: "Take all recommendations") and the owner accepted them on 19 October 2026 (https://github.com/eyalgolan/statecraft-israel/pull/1073#issuecomment-6259021508).
-R-MOVE-001: Each unit type that moves has an integer `movement_points` a turn (`unit_types.yaml`; required, at least 1, on a military type; refused on a population type), and each land biome of `map/hexes.json` an integer cost to enter (`rules.yaml` `mvp.move_cost`, at least 1; the loader refuses a land biome with no cost and a cost for a water biome, so lake and sea are impassable). A path's cost is the sum of the costs of the hexes it enters. A unit's Moves in one turn share its points: a second Move has what the first left, and the next turn has them all again. The points left are the type's points less those the unit spent this turn (`Movement.PointsLeft`). A type with no movement points (the halutz types) cannot move. Real values: recruit 3 (owner, 19 October 2026, https://github.com/eyalgolan/statecraft-israel/pull/1130#issuecomment-6269103829), veteran soldier 3, artillery 2, armoured car 5; coastal plain, valley and lowland 1, hills and desert 2, mountains 3.
+R-MOVE-001: Each unit type that moves has an integer `movement_points` a turn (`unit_types.yaml`; required, at least 1, on a military type; refused on a population type), and each land biome of `map/hexes.json` an integer cost to enter (`rules.yaml` `mvp.move_cost`, at least 1; the loader refuses a land biome with no cost and a cost for a water biome, so lake and sea are impassable). A path's cost is the sum of the costs of the hexes it enters. A unit's Moves in one turn share its points: a second Move has what the first left, and the next turn has them all again. The points left are the type's points less those the unit spent this turn (`Movement.PointsLeft`). A unit needs the full cost of the next hex, with one exception: a unit that has not moved this turn may enter one neighbouring land hex whatever it costs, and that move spends all its points (the owner, 23 October 2026, OQ-3: "No, strict like Civ VI", "with full points it can always move one hex"). A type with no movement points (the halutz types) cannot move. Real values: recruit 3 (owner, 19 October 2026, https://github.com/eyalgolan/statecraft-israel/pull/1130#issuecomment-6269103829), veteran soldier 3, artillery 2, armoured car 5; coastal plain, valley and lowland 1, hills and desert 2, mountains 3.
R-MOVE-002: `Move(unit, q, r)` takes the cheapest path, at command time (spec §2.3). Hexes leave the search in (cost, q, r) ordinal order, neighbours are tried in `tools/hexgrid.py`'s `NEIGHBOURS` order, and a hex reached again at the same cost keeps the hex it was first entered from, so of two equal paths the one through the hex first in that order wins, and the path is the same every run. `Movement.Reachable(c, s, unit, spent)` and `Movement.Path(c, s, unit, q, r, spent)` search with the points left; without `spent`, with all of them. `Movement.Reachable` lists the hexes a Move can end on this turn with their costs, and `Movement.Path` the hexes a path enters; both come from the same search Move uses (spec §2.6).
diff --git a/sim/Statecraft.Sim.Tests/MovementTests.cs b/sim/Statecraft.Sim.Tests/MovementTests.cs
index c6c314bfc..9c2166a9b 100644
--- a/sim/Statecraft.Sim.Tests/MovementTests.cs
+++ b/sim/Statecraft.Sim.Tests/MovementTests.cs
@@ -18,6 +18,7 @@ public class MovementTests
/// <summary>A 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, movement_points: 3 }\n"
+ + " - { id: gun, kind: unit, side: israel, class: infantry, movement_points: 2 }\n"
+ " - { id: enemy, kind: unit, side: egypt, class: infantry, movement_points: 3 }\n";
/// <summary>A 6 x 3 board of coastal plain, q 0 to 5 and r 0 to 2, with <paramref name="biomes"/> replacing hexes (a
@@ -77,6 +78,42 @@ public class MovementTests
Assert.Equal(cost, Movement.Reachable(c, s, 1)[(3, 1)]);
}
+ // R-MOVE-001 (owner, 23 October 2026, OQ-3: "No, strict like Civ VI": a unit needs the full cost of the next hex, "with
+ // full points it can always move one hex"): a unit that has not moved may enter one neighbour whatever it costs, and
+ // that spends all its points.
+ [Fact]
+ public void WithFullPointsAUnitCanAlwaysMoveOneHex()
+ {
+ var c = Load(Board((3, 1, "desert")));
+ var s = With(c, new Unit(1, "gun", 2, 1, side: "israel"));
+ Assert.Equal(2, Movement.Reachable(c, s, 1)[(3, 1)]); // all of its two points
+ var now = Simulation.Preview(c, s, new Command[] { new Move(1, 3, 1), new Move(1, 4, 1) });
+ Assert.Equal((3, 1), (now.State.Units[1].Q, now.State.Units[1].R));
+ Assert.Equal("That hex is out of reach this turn", now.Rejected.Single().Reason); // no points left
+ }
+
+ // R-MOVE-001: only with full points: after a move the strict rule holds.
+ [Fact]
+ public void AfterAMoveTheNextHexNeedsItsFullCost()
+ {
+ var c = Load(Board((4, 1, "desert")));
+ var s = With(c, new Unit(1, "gun", 2, 1, side: "israel"));
+ var now = Simulation.Preview(c, s, new Command[] { new Move(1, 3, 1) });
+ Assert.False(Movement.Reachable(c, now.State, 1, now.Spent).ContainsKey((4, 1)));
+ Assert.Equal("That hex is out of reach this turn", Simulation.Preview(c, s, new Command[] { new Move(1, 3, 1), new Move(1, 4, 1) }).Rejected.Single().Reason);
+ }
+
+ // R-MOVE-001: the exception reaches one hex only, never a hex beyond it, and never gives a type with no movement points
+ // (a halutz) a move.
+ [Fact]
+ public void TheExceptionIsOneHexOnly()
+ {
+ var c = Load(Board((3, 1, "desert")));
+ var s = With(c, new Unit(1, "gun", 2, 1, side: "israel"), new Unit(2, "halutz", 1, 2));
+ Assert.False(Movement.Reachable(c, s, 1).ContainsKey((4, 1)));
+ Assert.Empty(Movement.Reachable(c, s, 2));
+ }
+
// R-MOVE-001: the real game's numbers, design values this PR proposes (Q-MOVE-1): one cost per land biome of hexes.json,
// none for lake and sea, and the movement points of the four military types.
[Fact]
diff --git a/sim/Statecraft.Sim/Movement.cs b/sim/Statecraft.Sim/Movement.cs
index d6ebd048e..0249e0c92 100644
--- a/sim/Statecraft.Sim/Movement.cs
+++ b/sim/Statecraft.Sim/Movement.cs
@@ -38,8 +38,10 @@ namespace Statecraft.Sim
{
var result = new SortedDictionary<(int Q, int R), int>();
if (!s.Units.TryGetValue(unitId, out var u) || IsEnemy(u)) return result;
+ var points = Points(c, u);
+ if (points == 0) return result;
spent.TryGetValue(unitId, out var used);
- var (dist, _) = Search(c, s, u, Points(c, u) - used);
+ var (dist, _) = Search(c, s, u, points - used, fresh: used == 0);
foreach (var kv in dist)
if (kv.Key != (u.Q, u.R) && Full(c, s, u, kv.Key.Q, kv.Key.R) == null) result[kv.Key] = kv.Value;
return result;
@@ -57,7 +59,7 @@ namespace Statecraft.Sim
if (!Reachable(c, s, unitId, spent).ContainsKey((q, r))) return Array.Empty<(int, int)>();
var u = s.Units[unitId];
spent.TryGetValue(unitId, out var used);
- var (_, prev) = Search(c, s, u, Points(c, u) - used);
+ var (_, prev) = Search(c, s, u, Points(c, u) - used, fresh: used == 0);
var path = new List<(int Q, int R)>();
for (var h = (q, r); h != (u.Q, u.R); h = prev[h]) path.Add(h);
path.Reverse();
@@ -97,7 +99,7 @@ namespace Statecraft.Sim
if (Closed(c, s, enemy).Contains((q, r))) return "Units may not enter an enemy-held locality before its capture is possible";
if (Full(c, s, u, q, r) is string full) return full;
spent.TryGetValue(unitId, out var used);
- var (dist, _) = Search(c, s, u, points - used);
+ var (dist, _) = Search(c, s, u, points - used, fresh: used == 0);
if (!dist.TryGetValue((q, r), out var cost)) return "That hex is out of reach this turn";
// Moving clears fortify at once (Q-HOLD-1, "lost on move"; the standing orders' "fortify", or "fortifying" the turn it
// is given, with the hex it names), so a unit that goes out and comes back the same turn is not fortified; hold moves with
@@ -175,8 +177,10 @@ namespace Statecraft.Sim
/// never an enemy unit's hex or a closed enemy-held locality's (<see cref="Closed"/>); passing next to either costs nothing extra (no zone of
/// control, Q-MOVE-4). Hexes leave the frontier in (cost, q, r) order and neighbours are tried in the fixed
/// <see cref="Neighbours"/> order, so a hex reached at the same cost twice keeps the first, and the path is the same
- /// every run. Stacking limits only where a move ends, so it is not checked here.</summary>
- static (Dictionary<(int Q, int R), int> Dist, Dictionary<(int Q, int R), (int Q, int R)> Prev) Search(Content c, GameState s, Unit u, int budget)
+ /// every run. With <paramref name="fresh"/>, one neighbouring hex whose cost exceeds the budget costs the whole budget
+ /// (R-MOVE-001, OQ-3). Stacking limits only where a move ends, so it is not checked here.</summary>
+ static (Dictionary<(int Q, int R), int> Dist, Dictionary<(int Q, int R), (int Q, int R)> Prev) Search(
+ Content c, GameState s, Unit u, int budget, bool fresh = false)
{
var costs = c.RulesAt(s.Date).Mvp!.MoveCost; // the loader requires a cost for every land biome in the GDD loop
var blocked = Closed(c, s, IsEnemy(u));
@@ -197,6 +201,7 @@ namespace Statecraft.Sim
foreach (var (hexes, kindCost) in built)
if (kindCost < step && hexes.Contains((q, r)) && hexes.Contains(next)) step = kindCost;
var total = cost + step;
+ if (fresh && cost == 0 && total > budget) total = budget; // R-MOVE-001: with full points a unit can always move one hex (OQ-3)
if (total > budget || (dist.TryGetValue(next, out var known) && known <= total)) continue;
if (dist.ContainsKey(next)) frontier.Remove((known, next.Item1, next.Item2));
dist[next] = total;