Skip to content

Commit 7acf10f

Browse files
snow-jallenclaude
andcommitted
Spring rules: marching armies spread out; every unit takes room in the cell it ends each tick in
A walker that ends a tick in a full cell is bumped to the nearest cell with room, toward where it's going, and keeps its route when its next step is still one step away. Found in a 16-Formics prod test, where armies of 20-29 soldiers marched in one cell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8fdNFMnkyDNTFoKqQyD6L
1 parent c27806b commit 7acf10f

13 files changed

Lines changed: 61 additions & 26 deletions

‎docs/bot-guide.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ plays either. Commands don't change; the new mechanics show up as extra fields,
399399

400400
| Field in the rules | Spring draft | What it does |
401401
|---|---|---|
402-
| `cellCapacity`, each unit's `occupancy` | 9; Worker 2, Soldier 1, Archer 1, Scout 2, Trebuchet 9 | Units walk through each other, but a unit standing in a cell (idle, digging, building, shooting, waiting) takes its occupancy of the cell's 9 points. First in keeps the cell; a unit that stops where there isn't room is bumped to the nearest cell that has some. When players' units arrive together and don't all fit, they take turns, one per player, starting one player further round each time that happens. New units appear in the nearest cell with room. |
402+
| `cellCapacity`, each unit's `occupancy` | 9; Worker 2, Soldier 1, Archer 1, Scout 2, Trebuchet 9 | Every unit, walking or standing, takes its occupancy of the 9 points of the cell it ends each tick in. First in keeps the cell; a unit that ends a tick where there isn't room is bumped to the nearest cell that has some (a walking one, toward where it's going), so armies spread out on the march. (A scout, which moves 2 cells a tick, can dash across a full cell without stopping in it.) When players' units arrive together and don't all fit, they take turns, one per player, starting one player further round each time that happens. New units appear in the nearest cell with room. |
403403
| `minersPerEdge` | 2 | At most 2 workers dig from one cell beside a patch or farm at once (the cell's limit, shared by every patch it touches); others there wait (`activity: "Waiting"`). A worker leaving to drop off gives up its spot at once. Workers sent to a patch pick a cell with a free spot. A worker bumped from beside its patch looks within its vision for a free spot, and goes idle (with a `CommandFailed` event) if there is none. |
404404
| `farm` (`grubs`, `replantCost`, `gatherPerTick`), building `Farm` | 300, 75, 1; Farm costs 100 | A finished farm holds `farm.grubs`, dug like a patch from the cells around it at `gatherPerTick` (+ Harvesting). Its `grubs` field in state says how many are left. Dug out, it stays standing and its workers move on (event `FarmEmpty`); **Gather** on your own empty farm replants it for `replantCost` when the worker gets there (event `FarmReplanted`). You can't dig an enemy's farm. |
405405
| GuardTower `attackCooldown`, upgrade `RapidFire` | 3 (cost 150); RapidFire 150 | Towers fire every 3 ticks; RapidFire brings it to 2. |

‎docs/proposals/spring-rules.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ patches.
9696
(`NetRts:Rules=spring-draft`) and classic becomes the opt-out.
9797
24. **No badges** (answers H): spectators just see more units, more spread out.
9898

99+
## Round 5 (2026-11-27)
100+
101+
25. **Marching armies spread out** (replaces decision 3 and 20's "walking units hold none"): every unit, walking or
102+
standing, holds its share of the cell it ends each tick in. A walker that ends a tick in a full cell is
103+
bumped to the nearest cell with room, toward where it's going, and keeps its route when it can. Found in a
104+
16-Formics prod test, where armies of 20-29 soldiers marched in one cell.
105+
99106
## Open questions (round 2)
100107

101108
Recommendations in italics.

‎docs/spring-rules/spring-rules-before-after.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h1 style="margin: 0; font-family: 'Space Grotesk', sans-serif; font-weight: 700
3434
<div style="font-weight: 600">Room in a cell</div><div style="color: #56627a">As many units as you like</div><div>9 points: Worker 2, Soldier 1, Archer 1, Scout 2, Snow Mobile 9</div>
3535
</div>
3636
<div style="display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1.5fr); column-gap: 28px; align-items: center; border-bottom: 1px solid #dfe6f1; font-size: 17px; line-height: 1.35">
37-
<div style="font-weight: 600">Stopping</div><div style="color: #56627a">Stack anywhere</div><div>First in keeps the cell; latecomers are bumped next door</div>
37+
<div style="font-weight: 600">Crowds</div><div style="color: #56627a">Stack anywhere, even on the march</div><div>First in keeps the cell; latecomers, marching armies too, are bumped next door</div>
3838
</div>
3939
<div style="display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1.5fr); column-gap: 28px; align-items: center; border-bottom: 1px solid #dfe6f1; font-size: 17px; line-height: 1.35">
4040
<div style="font-weight: 600">Digging</div><div style="color: #56627a">Any number on a patch</div><div>2 dig from each cell beside a patch; 2 more wait</div>
10.4 KB
Loading

‎docs/spring-rules/spring-rules-big-three.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1 style="margin: 0; font-family: 'Space Grotesk', sans-serif; font-weight: 700
3131
</div>
3232
<div style="display: flex; flex-direction: column; gap: 10px">
3333
<div style="font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 36px">1. A cell holds 9 points</div>
34-
<div style="font-size: 19px; line-height: 1.5">Worker 2 · Soldier 1 · Archer 1 · Scout 2 · Snow Mobile 9. Above: a full cell, 2 workers and 5 soldiers. Units walk through each other, but the first to stop keeps the cell; anyone else is bumped next door. Two workers dig from each cell beside a patch.</div>
34+
<div style="font-size: 19px; line-height: 1.5">Worker 2 · Soldier 1 · Archer 1 · Scout 2 · Snow Mobile 9. Above: a full cell, 2 workers and 5 soldiers. Walking or standing, every unit takes room: first in keeps the cell, and anyone else is bumped next door, so armies spread out on the march. Two workers dig from each cell beside a patch.</div>
3535
</div>
3636
</div>
3737

7.61 KB
Loading

‎docs/spring-rules/spring-rules-tiles.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 style="margin: 0; font-family: 'Space Grotesk', sans-serif; font-weight: 700
2626
<div style="background: #eef3fa; border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 8px">
2727
<div style="font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 34px; color: #d0661a">02</div>
2828
<div style="font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 23px">First in keeps the cell</div>
29-
<div style="font-size: 16px; line-height: 1.45">Units walk through each other. Stop where it's full and you're bumped to the nearest cell with room.</div>
29+
<div style="font-size: 16px; line-height: 1.45">Walking or standing, every unit takes room. Latecomers to a full cell are bumped next door, so armies spread out.</div>
3030
</div>
3131
<div style="background: #eef3fa; border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 8px">
3232
<div style="font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 34px; color: #d0661a">03</div>
4.81 KB
Loading

‎src/NetRts.Engine/GameRules.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ private static RuleSet MakeSpringDraft()
385385
siegeNote => "Siege units (ShotTicks > 0) lob shells at a tile: they land ShotTicks later and hit every enemy on that tile then, and every enemy on the 8 tiles around it for shellSplashPercent of the damage (before armor). They can't fire inside MinRange.",
386386
TickLimitNote => "At the tick limit the highest total score wins; equal totals go to whoever gathered more grubs (economy), and only then is it a draw.",
387387
ScoreNote => "Score: destruction (value of enemy assets destroyed) + survival (value of your living units and finished buildings) + bank (grubs you hold now). Economy (grubs ever gathered) is still reported, but only breaks ties.",
388-
SharedTilesNote => "Units walk through each other, but a cell holds cellCapacity points: a unit standing in it (for any reason) takes its occupancy. First in keeps the cell; a unit that stops where there isn't room is bumped to the nearest cell that has it. Ties between players take turns, starting one player further round each time. Buildings, resource deposits and rock block movement.",
388+
SharedTilesNote => "A cell holds cellCapacity points, and every unit, walking or standing, takes its occupancy of the cell it ends each tick in. A unit that stays put keeps its place; one that ends a tick where there isn't room is bumped to the nearest cell that has some (a walking one, toward where it's going), so armies spread out on the march. Ties between players take turns, starting one player further round each time. Buildings, resource deposits and rock block movement.",
389389
_ => n,
390390
}),
391391
"Digging: at most minersPerEdge workers dig from one cell at once, shared by every patch or farm beside it; others there wait their turn (activity Waiting). A worker leaving to drop off gives up its spot. A worker bumped away from its patch looks within its vision for a cell with a free spot, and goes idle if there is none.",

‎src/NetRts.Engine/GameSimulation.Cells.cs‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ namespace NetRts.Engine;
44

55
/// <summary>
66
/// Cell limits (<see cref="RuleSet.CellCapacity"/>) and digging spots (<see cref="RuleSet.MinersPerEdge"/>).
7-
/// Units walk through each other; a unit that stops takes its <see cref="UnitStats.Occupancy"/> of its cell
8-
/// if there is room, and is bumped to the nearest cell with room if there isn't. Nothing here runs under
9-
/// rules without a cell limit.
7+
/// Every unit, walking or standing, takes its <see cref="UnitStats.Occupancy"/> of the cell it ends each tick
8+
/// in: one that moved takes a place there if there is room, and is bumped to the nearest cell with room if
9+
/// there isn't (a walker toward where it's going), so marching armies spread out. A unit that stays where it
10+
/// is keeps its place. Nothing here runs under rules without a cell limit.
1011
/// </summary>
1112
public sealed partial class GameSimulation
1213
{
@@ -60,7 +61,7 @@ private void Place(UnitEntity unit, Point to)
6061
}
6162

6263
/// <summary>
63-
/// After everyone has moved: each unit standing still without a place takes one, or is bumped. Within a cell
64+
/// After everyone has moved: each unit without a place (it moved, or was just placed) takes one, or is bumped. Within a cell
6465
/// the lowest id goes first; when players' units don't all fit, they take turns, starting one player further
6566
/// round the table each time that happens. The bumped are placed after every cell has seated its own.
6667
/// </summary>
@@ -72,7 +73,7 @@ private void ResolveCells()
7273
}
7374

7475
var bumped = new List<UnitEntity>();
75-
var arrivals = _units.Where(u => !u.Dead && u.SettledSeq == 0 && u.Path.Count == 0)
76+
var arrivals = _units.Where(u => !u.Dead && u.SettledSeq == 0)
7677
.GroupBy(u => Index(u.Position))
7778
.OrderBy(g => g.Key);
7879
foreach (var cell in arrivals)
@@ -126,14 +127,30 @@ private List<UnitEntity> TakeTurns(List<UnitEntity> group)
126127
/// <summary>Moves a unit that found no room to the nearest cell that has some, and lets it carry on from there.</summary>
127128
private void Bump(UnitEntity unit)
128129
{
129-
if (NearestRoom(unit) is not { } cell)
130+
var walking = unit.Path.Count > 0;
131+
if (NearestRoom(unit, walking ? unit.Path[^1] : null) is not { } cell)
130132
{
131133
return; // nowhere near: it stays put without a place and tries again next tick
132134
}
133135

134136
Place(unit, cell);
135-
unit.ClearPath();
136137
Settle(unit);
138+
if (walking)
139+
{
140+
// Sidestepped: keep the route if its next step is still one step away (or this is it), else plan again.
141+
if (unit.Path[0] == cell)
142+
{
143+
unit.Path.RemoveAt(0);
144+
}
145+
else if (unit.Path[0].Chebyshev(cell) > 1)
146+
{
147+
unit.ClearPath();
148+
}
149+
150+
return;
151+
}
152+
153+
unit.ClearPath();
137154
if (unit.Order == OrderKind.Gather && unit.Carrying < Rules.WorkerCarryCapacity)
138155
{
139156
FindPlaceToDig(unit);
@@ -142,9 +159,10 @@ private void Bump(UnitEntity unit)
142159

143160
/// <summary>
144161
/// The nearest cell (by steps over open ground, in a fixed order) with room for the unit; among the nearest,
145-
/// one where it can get on with its order (dig, build, shoot its target) if there is one.
162+
/// for a walker the one nearest <paramref name="toward"/> (where it's going), for anyone else one where it
163+
/// can get on with its order (dig, build, shoot its target) if there is one.
146164
/// </summary>
147-
private Point? NearestRoom(UnitEntity unit, int maxSteps = 8)
165+
private Point? NearestRoom(UnitEntity unit, Point? toward, int maxSteps = 8)
148166
{
149167
var seen = new HashSet<Point> { unit.Position };
150168
var ring = new List<Point> { unit.Position };
@@ -169,7 +187,9 @@ private void Bump(UnitEntity unit)
169187
var open = next.Where(p => Room(p) >= unit.Stats.Occupancy).ToList();
170188
if (open.Count > 0)
171189
{
172-
return open.FirstOrDefault(p => CanWorkFrom(unit, p), open[0]);
190+
return toward is { } goal
191+
? open.MinBy(p => (p.Chebyshev(goal), p.DistanceSquared(goal)))
192+
: open.FirstOrDefault(p => CanWorkFrom(unit, p), open[0]);
173193
}
174194

175195
ring = next;

0 commit comments

Comments
 (0)