You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wait — Receive lobby_joined confirmation, then lobby_update messages as other players arrive
Match assigned — When the tournament starts, receive match_assigned with your player_id, opponent, and room_id
Ready up — Send {"action": "ready"} to signal you're ready to play
Game loop — Receive state messages every tick with the full board state. Send {"action": "move", "direction": "up|down|left|right"} to control your snake
Game over — Receive gameover with the result. Send {"action": "ready"} to start the next game in the match
Match complete — Receive match_complete. If you won, wait for the next match_assigned (next round). If you lost, the connection closes
Tournament complete — Receive competition_complete with the champion. Disconnect
All communication happens over a single WebSocket connection — lobby, game, and tournament messages share the same socket.
WebSocket Endpoints
/ws/join — Join the lobby (primary endpoint for all players and bots)
/ws/observe — Observe active games (spectator mode)
HTTP Endpoints (Public)
Method
Path
Description
GET
/
Server info ({"name": "CopperHead Server", "status": "running"})
GET
/status
Server status: rooms, player counts, grid size, speed, points_to_win, competition state, fruits
GET
/settings
Raw server settings file (admin_token stripped). Returns {} if no settings file is loaded
grid: Board dimensions. (0, 0) is the top-left corner; y increases downward.
snakes: Keyed by player ID ("1" or "2"):
body: Array of [x, y] coordinates (head is the first element)
direction: Current movement direction
alive: Is this snake still alive?
buff: Current active buff (e.g. "default", "speed", "shield")
foods: Array of food items with x, y, type, and lifetime (ticks until expiry, or null)
Spawning Bots
Use the /lobby/add_bot admin endpoint to spawn CopperBot opponents:
# Spawn a bot with random difficulty (requires admin token)
curl -X POST "http://localhost:8765/lobby/add_bot?admin_token=YOUR_TOKEN"# Spawn a bot with specific difficulty
curl -X POST "http://localhost:8765/lobby/add_bot?difficulty=7&admin_token=YOUR_TOKEN"