Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

A turn

Every player chooses its actions from its own observation before the turn resolves. You see an opponent’s move, and can react to it, only in the next observation.

The replays on this page are short scripted matches on a six-by-eight board, played through the cartridge the ladder runs. Each opens one turn before the moment it shows, so one press of the right arrow plays it. The viewer draws a death as a hollow ring on the square the ant died on with a line from every enemy that killed it (two ants that kill each other draw two lines that meet halfway), and a razed hill as a dashed square.

The six steps, in order

StepResolutionConsequence
1. MoveApply moves, then remove collisionsFriendly ants can kill each other
2. BattleEvaluate combat among survivorsAn ant that dies on a hill razes nothing
3. RazeSurviving enemies destroy occupied hillsA destroyed hill cannot spawn
4. SpawnStored food creates ants on free hillsAn occupied hill blocks growth
5. GatherNearby food enters the hiveThis food cannot spawn until a later turn
6. New foodPlace fresh foodAnts can gather it on later turns

After these steps the engine folds each colony’s vision into what it knows, advances the turn count and checks the ending conditions.

Moving and collisions

An ant moves one square north, east, south or west, or stays. The engine treats a move into water or onto food as staying: both refuse the destination and leave the ant where it was. An ant with no order also stays. Movement wraps at both edges; see The world.

The engine checks collisions at each ant’s final destination. If two or more ants arrive on one square, all of them die, whoever owns them. Moving onto a friendly ant that stays is a collision. Two adjacent ants that swap places do not collide, since their destinations differ; combat still follows at their new positions.

A collision is between your own ants. Two enemies that could arrive on one square stood at most two squares apart the turn before, squared distance 4 at the furthest, so they were already in each other’s attack range, and two enemies in range can never both survive a battle. The one exception is an ant that appeared after that battle, since spawning runs later in the turn than the fighting.

The order array is positional, in mine order: row-major by square, whatever order your ants appeared in. Entry 0 is the ant in your topmost occupied row, leftmost of any tie, and that can be a different ant each turn.

Red gathers the food below its hill, steps east, and a new ant appears on the hill behind it, so on turn 2 red’s two ants stand side by side with the hill ant as entry 0. Press the right arrow: turn 3 sends entry 0 east onto the square the other ant holds. Both ants die there, two rings on one square, and neither death has a killer. Blue never moves. With no red ant left, the engine credits blue with red’s hill and ends the match.

Combat

An enemy is in attack range when the wrapped squared distance is at most 5. After collisions, the engine counts the enemies in range of each ant; that count is the ant’s focus. Friendly ants add nothing to it.

An ant dies if any enemy in range has focus less than or equal to its own. An ant survives only if every enemy it faces has a higher focus, and an ant with no enemy in range survives combat.

The engine computes every focus before it removes any ant, so a dying ant still counts in that turn’s comparisons and deaths do not cascade.

Position after movementFocus valuesResult
One ant against one, in rangeBoth 1Both die
Two allies each in range of one enemy, no other enemiesAllies 1 each; enemy 2Allies survive; enemy dies
Two against two, all in mutual rangeAll 2All die
Four adjacent cells in a row: A A B BOuter ants 1; inner ants 2Inner ants die; outer ants survive

The last two cases have the same number of ants and different outcomes. Your model has to weigh position and support as well as the size of each army.

Two ants that close to within attack range with no support on either side have equal focus, and both die. You never see one ant facing another in range, because the fight resolves on the turn the gap closes.

Turn 1 has each ant one step off its hill and the two four columns apart, squared distance 17, outside the range of 5. Press the right arrow: on turn 2 red steps east and blue steps west, the distance becomes 5, and each ant kills the other: a line in each colour runs from its ring and the two meet halfway. The match ends there with no ants on the board.

Support changes the outcome, and you can see it. Two ants that come into range of a lone enemy on the same turn each face one enemy while it faces two: its focus is 2 and theirs is 1, so it dies and both of them live. Arriving a turn apart would be the case above, twice.

Red gathers the food beside its hill and spawns a second ant, while blue walks west from its own hill. Turn 2 has red’s two ants in a column and blue two squares from the nearer one. Press the right arrow: on turn 3 red steps south and blue steps west, which puts blue in range of both red ants at once. Two lines run into blue’s ring and none into red’s: blue faced two and died, each red ant faced one and lived. Blue has no ant left, so the engine credits red with blue’s hill (the dashed square) and ends the match 3–0.

Razing a hill

A surviving enemy on a standing hill destroys it, earning +2 and costing its owner 1 point. An attacker killed during collisions or battle razes nothing. Your own ant cannot raze your hill.

That last rule is what makes hills hard to take. An ant on its own hill covers every square within squared distance 5 of it, two squares out in a line, so a lone attacker stepping into that ring dies with the defender and razes nothing. To take a defended hill you need support, or a defender that has left. The replay below shows the second case: the script walks blue’s ant away from its hill first, so red razes the hill without a fight.

Blue’s ant walked three squares north on the first three turns and holds there, out of range of its own hill. Red walked three south and is walking east along blue’s row. Turn 6 has it one square from the hill. Press the right arrow: on turn 7 red stands on the hill, the hill is drawn as a dashed square because it is gone, and the score goes from 1–1 to 3–0, +2 to the razer and −1 to the owner. With no enemy hill left standing, the finishing order can no longer change, so the engine ends the match rank_stabilized. Red’s own hill is untouched and can still spawn.

Food and new ants

Each stored food unit spawns one ant on an unoccupied friendly hill. With several hills free, the one that has gone longest without being touched goes first, where a hill is touched when it spawns and when one of its own ants stands on it. A tie goes to the hill listed first in the map file, and the map file lists hills so that every seat’s first hill is the same hill of the board, moved by its shift. Each hill can spawn at most one ant per turn, because the new ant then occupies it. Food waits in the hive while no hill is free.

Gathering uses squared radius 1: the food square and its four orthogonal neighbours. If one colony alone has surviving ants in range, it collects the food; with none in range, the food stays. The engine also destroys food that several colonies contest. That case cannot arise under the current attack and gathering radii, because opposing ants cannot both survive in gathering range of the same food.

Food gathered this turn can spawn next turn at the earliest, so a useful growth pattern is to step off a hill while another ant gathers nearby.

Spawning also runs after the fighting, which works for the defender: a colony whose defender dies on its own hill can replace it in the same turn from food already in the hive. A hill stops producing defenders once the hive behind it is empty.

On turn 1 red gathers the food beside its hill: the food is gone from that frame and no ant has appeared. Press the right arrow: turn 2 steps the gatherer off the hill, and the new ant stands on it. Food gathered on one turn becomes an ant on the next, and never sooner. Blue shows the other half of the rule. It gathered the food beside its hill on turn 1 as well and never spawns, because its own ant stands on the only square where its new ant could appear.

Sending nothing

The game leaves an ant with no order where it is. A failed model call is a different matter: the platform counts a missing or failed answer as a strike, substitutes no movement, and forfeits the seat at the strike limit. Make the call succeed every turn: your adapters must evaluate, and your graph must return its declared head, inside the deadline. A policy that holds every ant still answers, by scoring - highest for each one. See actions.