How bots think
Levels, how many a room runs, team roles, routes, jukes, cut-offs and powerups.
Bots run the same code on our servers and, for the Sandbox, in your browser. They always show a robot badge with their level and never count as players. In public games the only bots stand in for someone who left (Find a game).
How it works now
- Four levels, Rookie, Regular, Elite and Expert, on the same code in game rooms and in your browser.
- Where they think: on Cloud, in a BotBrain object next to the room; on Dedicated, in the room, handing off to a bot brain while the server is busy; offline and in hosted games, with the game (Where bots think).
- How many: a room's bots play up to Expert with 1 to 8 bots and up to Elite with 9 or more (switch BOT_POLICY_LIVE). 8 Experts' worst 250 ms of thinking is 12.8 ms of the 13.3 allowed.
- Thinking less when far away: a bot that isn't carrying, with no enemy within 12 tiles, no carrier within 15 and no flag within 10, thinks every 6 ticks (switch EFFORT, on since 16 Nov 2026): 50.7% ± 4.5 against the live bots over 480 ladder games, the feel gate clean.
- Public games are people only: a bot only stands in for someone who left.
Last checked: 16 Nov 2026.
Key decisions
| Decision | Why | Rejected | Date |
| Public games are people only; bots only stand in for leavers | The owner's call: no bots in human games; a stand-in means a team never loses a player mid-play | Bots in every empty seat of a new room (Find a game did that until then) | 16 Nov 2026 |
| Cloud rooms' bots think in their own object | In Node with 8 Expert bots the room's step went from 0.76 to 0.38 ms at p50; brain-thought Expert scored 48.8% ± 8.9 against room-thought | A strict per-room work budget for bots (won 40% ± 12 of 60 ladder games) | 16 Nov 2026 |
| Bot level by bot count: 1 to 8 Expert, 9 or more Elite | The bots' worst 250 ms, times 3 for Cloudflare, stays under the 40 ms where a room's clock falls in all 12 test games | The table before bounded searches: 1 Expert, 2 or more Elite | 16 Nov 2026 |
| Expert's heaviest searches bounded per think, counted in work | A game plays out the same every time | Half the juke's move groups a think (46.3% ± 5.1 on the ladder, against 49.4% ± 4.4 without) | 16 Nov 2026 |
| A change ships only when it beats the frozen previous version by a clear margin | The low end of its 95% interval above 50%, over hundreds of games | Judging changes on small runs (two runs of the same code differ by up to 10 points at 256 games) | 15 Nov 2026 |
| A far bot thinks every 6 ticks | Passed the ladder and the feel gate | Every bot deciding every 4 ticks and staggered decisions (switches THINKK and STAGGER, off until they pass) | 16 Nov 2026 |
| A bot change ships only on identical keys or a clear ladder win, also with the brain's live delay | The owner's rule: bots must never get worse, and a brain answers a tick or more late live | Shipping on a feel check | 18 Nov 2026 |
| The brain in Rust presses exactly the TypeScript bots' keys, proven on recorded games | No one has to judge a new bot: the same keys are the same bots | A Rust bot tuned on its own | 19 Nov 2026 |
| The Rust brain is compared with today's TypeScript bots replayed, not with the old recordings | 379 of 567 older bot recordings no longer match the current bots, which changed since | Re-recording every bot game first | 19 Nov 2026 |
Changes that mattered
Known limits and next
- Bots still add hitches on Cloud with the bot brain in use; the cause is not known yet. The open bug
- On Backup rooms a bot brain plays only capture the flag and neutral flag maps on one layer with no gravity; elsewhere the room thinks for its bots (switch BRAIN_MODES_LIVE off). A Rust room has no bot code, so its bots always think in a brain.
- With more than 6 bots due to think on one tick, the brain can defer a different bot from the one the room would, a tick late (found 19 Nov 2026, not fixed yet).
- What the far-bot rule saves on its own: Not known. Measured together with THINKK and STAGGER, counted work went from 56.6 to 27.2 units a bot a tick.
- Built, off: THINKK and STAGGER; half the juke's move groups a think (jukestep); the juke simulation in Rust compiled to WebAssembly (switch RUST), off until it measures cheaper per bot tick.
The bot brain in Rust (in progress, switched off)
Today a bot brain is the TypeScript bot code in its own place: an object beside a Backup room, or a Node process beside a Rust room. The room sends each tick's state, the brain answers with the bots' keys, and the room plays them like a person's (Bots in their own object). The plan is the same brain written in Rust, thinking inside the Rust room's own process, so the servers run no Node at all.
- The rule: the Rust brain must press exactly the keys the TypeScript bots press on the same states. Bots change only on identical keys or a clear ladder win, so the port changes nothing a player can feel.
- How it's proven: each piece of the TypeScript bot code logs its calls on recorded games, and the Rust piece must give the same answer to every one; then the whole brain answers every state of every recorded game and its keys are compared bot-tick by bot-tick.
- The full comparison, 19 Nov 2026: capture the flag and neutral flag, one floor, top-down: 424 of 424 recorded games and 23,455,210 of 23,455,210 bot-ticks identical to today's TypeScript bots, with no crashes. The 7 games that parted late in an earlier count that day came from the random draws made when a game's rules are set. Here the brain answers recorded states; next comes the closed loop, the Rust room playing whole games with the Rust brain answering, and then what it costs per bot.
- Pieces, each at zero differences on its own: map kernels (456,805 checks), route plans, pad shots and route cuts, team jobs and powerups, targets (4.81 million calls), plays (963,656 calls), snipes and the bomb trap.
- Other modes, in the code but not wired into rooms: the bots of Eggball (304,770 calls in 86 games), Frisbee, Rally, Infection, Race, Reach the goal, Light trails and Hangout (467,401 calls for those seven), each identical to the TypeScript bots. Knockout's bots are ready (24 of 24 games, 1,400,288 bot-ticks identical) and not landed yet.
- Size: the capture core is about 13,000 lines of TypeScript. Everything else the brain plays (scope 2: Eggball, Boostball, Knockout, the other modes, host rules, gravity, multi-layer maps and about 40 mini-games) is estimated at about 115 worker-hours (80 to 160), about 30 of them for the public lines.
- Off: a server setting turns it on per process. It stays off until the closed loop and its cost are measured, and the TypeScript brain keeps thinking.
Where bots think
| Game | Bots think | If that stops |
| Cloud | In a bot brain, an object of their own next to the game's room | The room thinks for them. If the room is falling behind as well, they leave with "Bots left: server busy" and come back with the brain. |
| Dedicated | In the room. A Dedicated server can be set to use a bot brain on Cloudflare always, or only while it is busy. | The same, with the server's load as the line. |
| In your browser | In your tab, with the game | |
| On a player's computer | On the host's computer, with the game | |
- A bot brain plays capture the flag and neutral flag maps on one layer with no gravity. On other maps the room thinks for its bots.
- Its keys reach the room a tick after the moment they were thought for, the same as when the room thinks.
- A bot that joins mid-game, such as one taking over someone's ball, stands still for a moment (at most half a second) until its first keys come.
Levels
Every level sees the whole field as it is. What differs is how often they decide, how well they aim and what they know. Times are at 60 ticks a second.
How many bots, at which level
In games on our servers, a room's bots play at their own level or the level its bot count allows, whichever is lower.
| Bots in the room | Strongest level |
| 1 to 8 | Expert |
| 9 or more | Elite |
The table comes from the bots' worst 250 ms of thinking over 12 different games in a fresh process, as after a deploy, on two of the heaviest rotation maps. Times 3 for Cloudflare, it has to stay under the 40 ms where a room's clock falls in every one of those games: 8 Experts reach 12.8 ms of the 13.3 allowed, 10 go over. That fits because Expert's heaviest searches are bounded per think, counted in work so a game plays out the same every time: one snipe lineup a think, and three of a grapple's eight aims. Room heal steps down on top (When the clock keeps falling). The Sandbox, champion challenges, mini-games (Elite already) and the Bot League keep their own levels. The switch is BOT_POLICY_LIVE. The numbers: How many Expert bots a room can take.
Bots in their own object
On for rooms on Cloudflare since 16 Nov 2026 (BOT_BRAIN_LIVE); a Dedicated server thinks in the room unless its BOT_BRAIN setting sends its bots to a brain too (Where bots think). A room on Cloudflare with bots on a capture or neutral flag map sends its state (about 360 bytes for 8 balls) to a BotBrain Durable Object at the end of each tick. The brain puts every ball where the room has it, lets the bots think with their own code, and answers with their keys before the next tick: one tick behind the state, as when the room thinks. The room plays those keys like a person's and stays the game. A bot whose keys are over 4 ticks old, or a socket that's down, and the room thinks for it as before, trying the brain again 120 ticks later. Measured in Node with 8 Expert bots: the room's step 0.76 to 0.38 ms at p50; on the ladder, brain-thought Expert 48.8% ± 8.9 against room-thought. A room where a leaver's ball can go to a bot keeps its brain socket open from the countdown, and the brain warms the bot code on the map, so a takeover no longer hitches the room. More: Bots in a separate Durable Object.
Team roles
Elite and Expert bots play as a team. The team replans its roles three times a second, and right after a grab, drop or pop (Expert reacts in 50 ms).
- Defenders: half the team. One more when protecting a lead late in the game, one fewer when behind. A change has to hold for 3 seconds.
- Our flag is home: one defender marks each attacker, and the first guards the flag. Expert markers go onto an attacker's way in as soon as it turns for our flag, and onto the run-up or exit of a boost pad it lines up. The guard leaves the stand when the team needs it more.
- They have our flag: 1 chaser for teams of 2, 2 up to 5, 3 up to 7, 4 above. One more when the carrier is near its cap, has been chased 7 seconds, or is getting away. Chasers are picked by who gets there first: the first runs the carrier down, the rest cut in on its way home. An Expert chaser runs it down only when it can touch the carrier before its cap or a boost pad; otherwise it cuts in ahead or sets up the regrab. Someone always stays back; only Expert goes all in when the carrier is about to cap.
- Neutral flag, we have it: the guards don't park. They wait on the way an enemy who tagged our carrier would run into our zone, 5 and 9 tiles on from the carrier, and move with it.
- We have their flag: the attacker nearest their flag stand waits to regrab, the rest escort.
Routes and danger
- Routes are the shortest path over the tiles in 8 directions, with portals as shortcuts. Gravity maps use a graph of walks, drops and jumps.
- Danger costs extra: enemies near a carrier, an enemy TagBall, enemies holding bombs, live bombs, and gates with an enemy by their button. A hazard is avoided if it will be dangerous when the bot gets there.
- Expert never waits in, or heads for a spot in, a gate an enemy could shut on it: the spot moves to the nearest open cell outside the gate.
- Elite and Expert drive a racing line with room off the walls, look 0.4 s ahead for walls and spikes, and line up boosts to throw themselves home.
- Expert bots count their own sideways speed on the last straight run to a ball or a flag, so they roll through the spot instead of past it. Bots press the same eight directions a player does.
Jukes
An Elite or Expert carrier tries 8 or 24 directions, plays each one 0.4 s ahead with wall bounces, and picks the one that gets home while staying out of every nearby enemy's reach. Lower levels just lean away.
Cutting off the carrier
The first chaser doesn't follow the carrier: it goes to the first point on the carrier's way home that it can reach first. Expert looks further along the route and needs a smaller head start than Elite. In neutral flag, bots play the carrier's next second forward, walls and pads included, and see a sudden change of speed a few ticks late (5 for Expert, 9 for Elite).
Elite and Expert defenders read the carrier's way home with the carrier's own route planner (portals, boost pads, the defenders it keeps away from), planned again about every 8 ticks, and time their own run to each point as a ball gains speed. The second chaser goes to the first point on that way it reaches first, the third waits further along it. Nothing is seen through a cloak, and the read is no faster than the level's reaction time.
Tested against the bots before
Every change to the Expert bots is played against the frozen previous version: 4 v 4, 4-minute games on the current rotation and six gate maps, each map from both sides, hundreds of games, on the game's own physics engine. A change ships only when it wins by a clear margin (the low end of its 95% interval above 50%), or fixes a visible mistake without losing. The results, version by version, are in the repo's docs/bench/bots/ladder.json. Checked on planck.js and on Box2D v3: the same bots score the same on both within the margin (Expert against Elite, 384 games each: 78% and 80%).
Powerups
- Rookie: none.
- Regular: the simple uses. Dash or Blink away from a chaser, Mines and Oil behind a carrier, a Rolling Bomb only when it knocks someone into a spike.
- Elite and Expert: every powerup, and Freeze, Shock and Slow-mo on anyone in range.
- Expert also picks powerups by its job and waits by one that is about to appear.
Moves
- Top speed: Elite and Expert hold the key on the way they're going, as you do, instead of letting go a little under top speed. Zig-zagging between diagonals gains nothing on a straight in this physics; we measured it.
- Caps: an Elite or Expert carrier near its stand works out exactly when it gets there and the soonest any enemy could touch it on the way. If the cap comes first, it goes straight in.
- Jukes: an Expert carrier plays two-key moves forward tick by tick against everywhere each enemy could be, and takes the one that gets furthest home while staying out of reach. Walls, pads, spikes and gates count.
- Pad shots: Expert lines up a boost at speed, on a curve, instead of stopping behind the pad.
- Snipes: an Expert chaser takes a pad shot that meets the carrier on its way home, and waits by the pad when it's early.
- Bombs: a carrier holding a Rolling Bomb, Freeze Bomb or Shock knows it saves them from one tag and runs home. A chaser sets off a map bomb that throws the carrier into a spike or back the way it came.
See also: Bots and the Bot League.