Skip to main content

Python SDK for running bots on Game AI Arena

Project description

Game AI Arena SDK

Python SDK for running bots on Game AI Arena.

Installation

pip install game-ai-arena-sdk

Server URLs

Get these from your admin:

  • API Server: http://<SERVER>:9000 (or https://<SERVER> if tunneled)
  • Matchmaker WebSocket: ws://<SERVER>:9000/matchmaking/ws (or wss:// if tunneled)

For local development, use localhost as the server.

Getting Your Credentials

Option A: Swagger UI

  1. Open http://<SERVER>:9000/docs in your browser
  2. Use /ibba/auth/signup to create an account
  3. Click Authorize and enter your access token
  4. Use /ibba/bots/ POST to create a bot (save the bot_api_key - shown once!)
  5. Use /ibba/bots/ GET to find your bot's id

Option B: curl

# Set your server URL (get this from your admin)
SERVER="http://<SERVER_ADDRESS>:9000"

# 1. Create account
curl -X POST $SERVER/ibba/auth/signup \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "username": "yourname", "password": "SecurePass123"}'

# Response: {"access_token": "eyJhbG...", ...}
TOKEN="paste_your_access_token_here"

# 2. Create a bot
curl -X POST $SERVER/ibba/bots/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"bot_name": "MyBot", "game_type": "flipflop_3x3"}'

# Response: {"message": "Bot created successfully", "bot_api_key": "..."}
# Save the bot_api_key - it's only shown once!

# 3. Get your bot ID
curl -X GET $SERVER/ibba/bots/ \
  -H "Authorization: Bearer $TOKEN"

# Find your bot in the list, copy its "id" field

Quick Start

import random
from game_ai_arena_sdk import Bot, start, GameType, Move, GameStateLoop

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

bot = MyBot(bot_id="YOUR_BOT_ID", api_key="YOUR_API_KEY")
start(bot, GameType.FLIPFLOP_3X3, matchmaker_url="ws://<SERVER>:9000/matchmaking/ws")

GameStateLoop

Received in on_move:

Field Description
board Board string representation
my_side Your side ("white" / "black")
current_turn Whose turn it is
legal_moves List of PieceMovesInfo you can move

Each PieceMovesInfo has name, pos, and valid_moves.

Hooks

All optional except on_move:

async def on_move(self, state: GameStateLoop) -> Move  # Required
async def on_ready(self) -> None
async def on_match_found(self, match_id: str) -> None
async def on_game_start(self, state: GameStateLoop) -> None
async def on_game_end(self, winner: str | None, state: GameStateEnd) -> None

Multiple Bots

import asyncio
from game_ai_arena_sdk import run

async def main():
    await asyncio.gather(
        run(MyBot("id1", "key1"), GameType.FLIPFLOP_3X3),
        run(MyBot("id2", "key2"), GameType.FLIPFLOP_3X3),
    )

asyncio.run(main())

Game Types

FLIPFLOP_3X3, FLIPFLOP_5X5

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

game_ai_arena_sdk-0.2.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

game_ai_arena_sdk-0.2.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file game_ai_arena_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: game_ai_arena_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for game_ai_arena_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f94db71be9249a56435129a8b19eea452c15bc19bc056309522abfd5c1b69257
MD5 001a583e9bcb102d17f6d5f0ab4f7769
BLAKE2b-256 1ee3d4b6f4b3fb4b633fefa816bb3bdb5684e01fc37accebfd49769a4c9ea62f

See more details on using hashes here.

File details

Details for the file game_ai_arena_sdk-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for game_ai_arena_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b58dea0be5adb24037c8e3c4c238121cfd110bdcdfe131c100fefe3702b66d02
MD5 4a59329b66dd56dbb04c9cb22088591d
BLAKE2b-256 e486837e48ae67eaefc862d4e0453a2873186fbc885f307dd732cb7fec15eef6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page