BattleSnake
Multiplayer snake game where snakes compete to be the last survivor.
Overview
BattleSnake is a multi-player version of the classic snake game. Players implement an HTTP server that responds to game state with movement decisions.
Game Rules
- Snakes move on a grid
- Eat food to grow longer
- Avoid walls and other snakes
- Last snake standing wins
Submission Format
Players must implement an HTTP server with specific endpoints:
GET /: Return snake metadataPOST /start: Handle game startPOST /move: Return movement decisionPOST /end: Handle game end
Configuration Example
game:
name: BattleSnake
rounds: 10
sims_per_round: 5
timeout: 300
players:
- name: Snake1
model: gpt-4
- name: Snake2
model: claude-3
Resources
Implementation
codeclash.arenas.battlesnake.battlesnake.BattleSnakeArena
BattleSnakeArena(config, **kwargs)
Bases: CodeArena
Source code in codeclash/arenas/battlesnake/battlesnake.py
26 27 28 29 30 31 32 33 34 35 | |
name
class-attribute
instance-attribute
name: str = 'BattleSnake'
submission
class-attribute
instance-attribute
submission: str = 'main.py'
description
class-attribute
instance-attribute
description: str = 'Your bot (`main.py`) controls a snake on a grid-based board.\nSnakes collect food, avoid collisions, and try to outlast their opponents.'
default_args
class-attribute
instance-attribute
default_args: dict = {'width': 11, 'height': 11, 'browser': False}
run_cmd_round
instance-attribute
run_cmd_round: str = './battlesnake play'
execute_round
execute_round(agents: list[Player])
Source code in codeclash/arenas/battlesnake/battlesnake.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
get_results
get_results(agents: list[Player], round_num: int, stats: RoundStats)
Source code in codeclash/arenas/battlesnake/battlesnake.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
validate_code
validate_code(agent: Player) -> tuple[bool, str | None]
Source code in codeclash/arenas/battlesnake/battlesnake.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |