Skip to main content

Game Arena Python SDK

Build Python bots for Game Arena. Implement on_move(); the SDK handles authentication, matchmaking, game connections, and the turn protocol.

Requires Python 3.11+. Game rules and board formats live in the Bot Docs page of the Game Arena web app.

Install and prepare

pip install --upgrade game-arena-sdk

Create a bot in the web app and save its Bot ID and API key. The key may only be shown once.

Your first bot

This complete FlipFlop bot chooses a random legal move:

import random

from game_arena_sdk import Bot, GameStateLoop, Move, start_continuous


class MyBot(Bot):
    async def on_move(self, state: GameStateLoop) -> Move:
        piece = random.choice(state.legal_moves)
        destination = random.choice(piece.valid_moves)
        return Move(from_pos=piece.pos, to_pos=destination)


bot = MyBot(bot_id="YOUR_BOT_ID", api_key="YOUR_API_KEY")

if __name__ == "__main__":
    start_continuous(bot)
python my_bot.py

start_continuous() verifies and displays the bot's registered game and arena before joining ranked matchmaking, then asks for confirmation. Its compact live display shows the runner state, opponent, Bot Run record, and last committed result without flooding the terminal. Its commands are pause, resume, status, stop, help, display compact, and display verbose. Commands remain editable while games update the display. Stop and Ctrl-C finish any active game before disconnecting.

Adapt it for your game

Always choose from state.legal_moves, then preserve the fields required by that game:

Game GameType Returned Move
FlipFlop 3×3 GameType.FLIPFLOP_3X3 Move(from_pos=piece.pos, to_pos=destination)
FlipFlop 5×5 GameType.FLIPFLOP_5X5 Move(from_pos=piece.pos, to_pos=destination)
FlipFour GameType.FLIPFOUR Also pass side for a piece in "HAND"
Amoeba GameType.AMOEBA Also pass the legal move's splitting value
# FlipFour
side = piece.name if piece.pos == "HAND" else None
return Move(from_pos=piece.pos, to_pos=destination, side=side)

# Amoeba
return Move(
    from_pos=piece.pos,
    to_pos=destination,
    splitting=piece.splitting,
)

Missing these fields is a common cause of INVALID_MOVE.

Build a better bot

The random bot only proves the connection works. A stronger bot should:

  1. Parse state.board using its game's documented format.
  2. Evaluate every legal action from state.my_side using heuristics, search, or a model.
  3. Return the best action with its game-specific fields intact.
  4. Run in Practice Mode before entering ranked play.

Keeping this logic in choose_move(state) -> Move separates bot strategy from SDK lifecycle code.

Execution modes

start*() functions block and suit ordinary scripts. run*() functions are coroutines for code that already uses asyncio.

Need API
Interactive continuous ranked play (recommended) start_continuous(bot, display="compact")
Headless continuous ranked play await run_continuous(bot, game_type)
One ranked game start(bot, game_type) / await run(bot, game_type)
One practice game start_practice(...) / await run_practice(...)
Custom continuous controls ContinuousRunner

start_continuous() detects the registered game and adds terminal controls. Compact display is the default; pass display="verbose" or switch modes while running. Redirected input or output automatically uses plain verbose output. Headless run_continuous() requires an explicit GameType and returns the final immutable RunnerStatus, including safe failure details when the runner fails.

Practice Mode connects directly to a room from the web app and does not affect rating:

from game_arena_sdk import start_practice

start_practice(
    bot,
    room_id="ROOM_ID_FROM_PRACTICE_ARENA",
)

For custom operation, ContinuousRunner provides pause(), resume(), status(), stop(), and wait().

If phase visibility changes while the bot is queued, the continuous runner rejoins automatically on the same Bot Run and preserves whether it was paused. A switch to Blind removes an earlier rating from public status and the compact display even when the bot is already playing.

Core data

Type Important fields
GameStateLoop board, my_side, current_turn, legal_moves, room_id, previous_move, move_number
PieceMovesInfo name, pos, valid_moves, optional splitting
Move from_pos, to_pos, optional side, optional splitting
MatchFinishedResult result, end_reason, opponent, run, finished_at, optional rating
RunnerStatus state, run, opponent, last_result, safe failure fields

board is game-specific. legal_moves is the server-provided set of allowed actions. room_id identifies the room the game is being played in. previous_move is the accepted Move that produced the current board, and move_number is its number; at game start previous_move is None and move_number is 0. MatchFinishedResult is immutable and arrives after a continuous ranked result is committed; its rating is absent during phases that hide it.

Lifecycle hooks

Override only what you need. on_move() is the only required hook.

Hook Called when
on_move(state) -> Move Your turn requires a move
on_ready() The SDK connects
on_queue_entry() The bot joins matchmaking
on_queue_exit() The bot leaves the queue or finds a match
on_match_found(game_id) A game is assigned
on_room_joined(room_id) The game room is joined
on_game_start(state) Gameplay starts
on_game_end(winner, state) Gameplay ends
on_match_finished(result) The ranked result is committed in continuous play
on_disconnect(reason) Reserved for disconnect notifications

There is no on_error hook. Handle decision errors inside on_move() and SDK failures around the chosen entry point.

Errors and troubleshooting

Game-server protocol failures raise GameArenaProtocolError with code, message, and optional details. Continuous play fails closed after an uncertain failure instead of silently joining another game.

Problem Check
Authentication rejected Bot ID and API key
INVALID_MOVE Use legal_moves; preserve side or splitting
Cannot connect Bot ID, API key, and network access
Two test bots never match Bots owned by the same user cannot match
Continuous play stops Read the display or RunnerStatus.failure_code and failure_message; unsafe requeueing is prevented

For game rules, coordinates, strategy, arena configuration, and deeper troubleshooting, open Bot Docs in the Game Arena web app.

Metadata

Release files for game-arena-sdk 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for game-arena-sdk 1.1.0
File Size Uploaded Provenance Actions
game_arena_sdk-1.1.0.tar.gz 42.6 kB Without provenance Details for game_arena_sdk-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for game-arena-sdk 1.1.0
File Interpreter ABI Platform Actions
game_arena_sdk-1.1.0-py3-none-any.whl Python 3 none any Details for game_arena_sdk-1.1.0-py3-none-any.whl

Total release size: 71.7 kB

Release files / game_arena_sdk-1.1.0.tar.gz

Download URL game_arena_sdk-1.1.0.tar.gz
Size 42.6 kB
Tags Source
SHA-256 checksum
How to use checksums
74c663e791a1b88522e44decaf90f88e75202bc99ad7ea811cf379a942a6b378
BLAKE2b-256 checksum
How to use checksums
ef85d1d7c27dc3b8c47291197f9a043bd7ead30aee96cb169455ad3050bd9fd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / game_arena_sdk-1.1.0-py3-none-any.whl

Download URL game_arena_sdk-1.1.0-py3-none-any.whl
Size 29.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
708294abedb9ba239001aa4ea7581f8a72624307a1de86f6ccc1b4a4acac81d5
BLAKE2b-256 checksum
How to use checksums
13c5e8c47491f70c0a88ce26997940a665c4e539e5db26205cd4597354afca5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for game-arena-sdk 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page