The Ruleset
Game rules
01 — The board
The game is played on a rectangular grid of four tile types:
- Plains — empty passable tiles you spread onto. Moving onto a neutral plain simply makes it yours.
- Mountains — impassable and permanent. Moves into a mountain are invalid.
- Castles — player-built structures (see Building castles). A standing castle produces army for its owner like a general and can be captured in combat. Maps start with no castles — every castle on the board was built by someone. (Type
3in the bot observation.) - Generals — each player's home base. Lose yours and the game is over.
Map generation
Every match is played on a freshly generated map with these parameters:
| Parameter | Value |
|---|---|
| Board size | rectangular — each side drawn independently in 18–21 per game |
| Mountains | about 20–24% of the board (66–105 tiles) |
| Castles | none at the start — castles are built by the players |
| Generals | at least 17 BFS steps apart over plain tiles |
| Connectivity | a passable path between the generals is guaranteed |
Maps are random per game — seeds are not reused, so bots can't be tuned to known layouts.
Reading the engine source? mountain_density_range = (0.24, 0.26) is sampled before generation carves 9–11 mountain tiles into castle sites (removed again under this ruleset) — what's left on the board is the 66–105 above.
02 — Turns & moves
- Every turn, each player issues one action: move, build a castle (below), or pass.
- A move pushes army from one of your cells into one of its four adjacent cells (up, down, left, or right). You send either half the cell's army or all but one — you always leave at least one unit behind.
- Moving between your own cells merges the armies — no combat.
- Invalid moves don't crash anything — they are treated as a silent pass. (Moving from a cell you don't own, into a mountain, off the board, or with nothing to send.)
- Each turn, both players' moves and any fights are resolved first; army growth is applied afterward.
Corner cases
Both moves happen on the same turn, but one resolves fully before the other. Priority, highest first — a tie on one rule falls through to the next:
- Chasing — your move targets the cell the opponent's move starts from. You catch them before they leave.
- Reinforcing — your move lands on a cell you own. E.g. they move to capture your general while you move a unit back into it: the reinforcement lands first and the defense holds.
- Smaller army — otherwise, the move from the smaller cell resolves first.
- Both generals captured on the same turn → the match is a draw.
Note: a recent generals.io update resolves simultaneous general captures by swapping the two players' land and armies. This competition keeps the older rule — it's a draw.
03 — Building castles
There are no neutral castles to capture — you build your own. A build is a full action (it replaces your move that turn) and permanently turns one of your plain cells into a castle.
- Where: any plain cell you own — not a mountain, not a general, not an existing castle.
- Cost: paid from the army standing on that cell. Base price 35, plus a crowding surcharge for each structure you already own (your general and every castle of yours) near the target: max(0, 14 − 2 × distance), Manhattan. Structures 7+ tiles away add nothing.
- The remainder stays: build on 50 army at price 47 and the new castle keeps 3. Build with the exact price and the castle sits at 0 army.
- Production starts immediately: a built castle generates one army every other turn, like your general.
- Invalid builds are a silent pass, exactly like invalid moves — wrong cell, not enough army, not your land.
| Distance to your nearest structure | Surcharge | Price |
|---|---|---|
| adjacent | +12 | 47 |
| 2 | +10 | 45 |
| 3 | +8 | 43 |
| 4 | +6 | 41 |
| 5 | +4 | 39 |
| 6 | +2 | 37 |
| 7 or more | +0 | 35 |
Surcharges stack: squeezing a castle between your general and another castle, both at distance 2, costs 35 + 10 + 10 = 55. Prices are live — every castle you gain, built or captured, raises your own prices near it. Enemy structures never affect what you pay.
Corner cases
- Builds resolve before either player's move each turn.
- You can only build on your own cells, and prices depend only on your own structures — the two players' builds can never conflict.
- A castle captured from the enemy is yours from then on: it produces for you and counts toward your build prices.
- Castles are permanent — they never revert to plains, they only change owners.
The extended action space
An action is still one line of five integers, <pass> <row> <col> <dir> <split> — the first field now has three values:
0 r c d s— move from (r, c) in direction d, exactly as before.1 0 0 0 0— pass.2 r c 0 0— build a castle at (r, c). The last two fields are ignored.
04 — Army growth
- Every other turn, your general and every castle you own (built or captured) each generate one army.
- Every 50 turns, every cell you own gains one army.
05 — Combat & capture
Moving onto a cell an opponent owns starts a combat: the two armies subtract, and the attacker takes the cell only with strictly more army, keeping the difference. On an exact tie the defender keeps the cell.
Castles defend like any owned cell — there are no neutral garrisons. Capture an enemy castle and it produces for you.
Capturing the enemy general wins instantly.
06 — Visibility
The competition is played with fog of war — exactly like the original generals.io. Each bot sees only the cells next to tiles it owns; the rest of the board is hidden. Tiles you've scouted fade back into fog once you move away, and you can't see an enemy's army or moves outside your vision. Scouting, remembering the map, and inferring where the enemy is are part of the game.
07 — How a game ends
- Win — capture the opponent's general.
- Deathtouch, from turn 800 — any move that executes onto the enemy general's tile wins instantly, no matter how large the defending army is. One unit is lethal. The defense is a chase: capture the attack's source cell from a third tile that same turn and the touch never executes. Counter-attacking from the general itself is a head-on clash — the attacker wins it.
- Draw — neither general falls within 1200 turns. The cap is a hard draw regardless of territory or army counts, so passive play earns half points at best.
08 — Match constraints
Matches run on our infrastructure under these limits:
- Time per move: 150 ms. The very first move gets a 10 s grace period so bots that load models or warm up a runtime aren't penalized.
- Fault budget: a late, missing, or malformed reply is replaced with a pass and adds one fault. The game continues; reaching 50 faults in one game forfeits it. A bot process that crashes or exits forfeits immediately. Invalid but correctly formatted game actions are simply silent passes and do not add a runner fault.
- Hardware: your bot gets one dedicated CPU core and a hard 2 GB memory cap, enforced per bot — an opponent can never starve you of compute or memory, and a bot that exceeds its own 2 GB crashes and forfeits. The engine runs on its own core beside the bots. No GPU at match time — if you train an RL agent, run inference on CPU.
- Network: disabled. Bots can't make outbound calls during matches.
- Build step: compiled artifacts (binaries, weights) are produced once before the games via your
build.sh. The build has no network access, so anything your bot needs must live in the zip or already be installed in the competition environment.
For the bot interface, starter agents, and how to submit, see Get started.