Trails and territory
When the bot's center enters a tile, the first matching rule applies:
- One of the last 3 tiles of the bot's own trail: nothing happens, so a bot can reverse up to 2 tiles along its trail.
- An older tile of the bot's own trail: the trail is canceled with
HIT_OWN_TRAIL. - A tile of the opponent's trail: the opponent's trail is canceled with
SMUDGED, and the rules below apply to the tile. - The bot's own territory: the bot's trail, if it has one, completes.
- An unowned tile or the opponent's territory: the tile joins the bot's trail and costs 1 paint. With no paint left, the bot is sent home with
OUT_OF_PAINT, with or without a trail.
Completing a trail
#
When a trail completes, three steps run in order:
- Claim: every trail tile becomes the bot's territory, and so does every tile that the bot's territory now cuts off from the map edge, the opponent's territory included.
- Release: the opponent loses every tile of its territory that has no path to its base through its own territory, moving up, down, left or right. Those tiles become unowned. If the opponent loses any, it gets a
TERRITORY_DISCONNECTEDinterrupt. - Hole fill: the bot fills its holes, described below.
In the claim:
- A path to the edge can cross any tile the bot does not own, walls included, so walls never help enclose an area.
- Only tiles that this completion newly cuts off are claimed. The opponent's territory inside an area the bot had already enclosed stays the opponent's.
- A base never changes owner, and a claimed tile under the opponent's trail keeps that trail.
A hole is an unowned tile, other than a wall, that has no path to the map edge except through the bot's territory. A hole becomes the bot's territory when it connects to the bot's base, moving up, down, left or right, through the bot's territory and other holes. A hole that walls cut off from the territory stays unowned.

In this figure, red already owns the area around blue's base. Red's trail cuts two blue tiles off from blue's base, so blue loses them. They are then holes in red's territory, and red fills them.
LAST_CLAIMED_TILES then reads the tiles the completion gained: the trail, the enclosed tiles and the filled holes. In the figure it reads 4: the 2 trail tiles and the 2 filled holes.
Cancellation
#
When a cancellation sends the bot home:
- It loses its trail, if it has one. The trail's tiles keep their owners, and the paint spent on them is gone.
- It returns to the center of its base with velocity 0, keeping its heading.
TRAIL_CANCELLEDis raised, andLAST_TRAIL_CANCEL_REASONreads the latest reason.
| Code | Name | Cause |
|---|---|---|
| 0 | NONE |
No cancellation yet |
| 1 | OUT_OF_PAINT |
The bot entered a tile that needed paint with none left |
| 2 | HIT_OWN_TRAIL |
The bot drove into its own trail behind the last 3 tiles |
| 3 | SMUDGED |
The opponent drove through the trail |
| 4 | COLLISION |
The bots collided while this bot had a trail |
| 5 | FILLED_OVER |
The opponent's claim took or cut off the tile the trail started from or, for a bot without a trail, the tile it stands on |