Skip to content

Bring your own bot

You can write your own bot for a game, seat it in any seat of the portal’s Playtest, and compare it with the platform’s search bot. A bot sees exactly what a player in its seat would, never the hidden state, so it can’t cheat even by accident.

A bot is a plain JavaScript file (not a module) that sets self.bot to an object with a choose method. This one plays the first legal move it’s offered:

self.bot = {
choose: async (view) => (await view.turnMoves(1))[0] ?? null,
};

choose(view, budget, signal) is called each time the bot’s seat must move. It returns a move, or a promise of one, or null if the seat has no move to make.

  • view is the seat’s view of the game (below).
  • budget says how long the bot may think: thinkTimeMs, and iterations when the host sets them.
  • signal is an AbortSignal that fires when the host wants the move now.

A move is an action and its choices, in order: { action: "place", choices: [{ step: "cell", value: "a1" }] }.

Method Returns
view.seat The seat the bot plays
view.projection() The seat’s view of the state: what a player in the seat sees
view.turnActions() The names of the actions the seat may take now
view.choices(move) The next choice step of a move being built, or null when the move is complete
view.turnMoves(limit) The seat’s complete legal moves in the engine’s order, up to limit (256 if left out)
view.sample(seed) A full state that matches everything the seat can see, with the hidden parts dealt at random

A sample is how a bot plans ahead in a game with hidden information. It has turnActions(seat), choices(seat, move), apply(seat, move) (which gives the sample after the move, or null if the rules refuse it), project(seat), outcome() (null while the game goes on) and release(). The same seed gives the same sample. Samples left at the end of a turn are released for you, and a bot may hold at most 10,000 in a turn.

Every method returns a promise, because the engine runs in another worker.

The search bot is there to build on: self.arbitas.searchBot({ seed, iterations }) makes one, with the same choose method, for your bot to fall back on or wrap.

  1. Open the game’s Playtest, then its Bots page.
  2. Under Your bot file, choose your .js file. It’s loaded in your browser only, never uploaded or kept by Arbitas: load it again after a reload.
  3. Under Who plays each seat, choose for each seat: you, the search bot, or your bot.
  4. Play a game. Your bot moves when its seat is to move.
  • The file must set self.bot within 5 seconds of loading.
  • Each move has 5 seconds of thinking time. A bot still thinking a second after that is stopped.
  • The bot runs in a Web Worker of its own. It can’t reach the page or the real game state: only its seat’s view and its samples.

Under Compare with the search bot, choose how many matches to play, from 1 to 20, and start. Your bot plays the search bot over seeded matches, and the table shows each match’s seed, your bot’s seat, the result and the number of moves. The results are for you only; they never count toward ratings.

You can also turn a seat’s moves in a saved playtest into a bot file that replays them, which is a quick way to set up a position to test against.