A collection of high-performance intelligent agents built for the Battlesnake arena, featuring Monte Carlo Tree Search (MCTS), Reinforcement Learning (RL), and Advanced Heuristics.
Want to watch the AI battle it out locally? We've made it incredibly simple using the included runner scripts. These scripts will automatically start your Python server and use the Battlesnake CLI to initiate a local game.
First, ensure you have Python installed, then install the required packages:
pip install -r requirements.txtDepending on your operating system, use one of the following scripts:
.\run.batchmod +x run.sh
./run.shThese scripts use the pre-compiled Battlesnake CLI binary included in the root folder to start a game against your local
server.py.
This repository includes multiple AI implementations inside the main/ directory:
-
mcts_agent-final.pyHighly tuned Monte Carlo Tree Search agent simulating thousands of future states. -
mcts_agent-variation.pyExperimental MCTS version for A/B testing. -
rl_agent.pyReinforcement Learning-based agent trained for survival and trapping. -
heuristic_agent.pyFast rule-based agent using weighted evaluations. -
vanilla_mcts.pyBaseline MCTS implementation for benchmarking.
Additional tools:
tournammentrunner.py→ Automated tournamentsmcts_tuner.py→ Hyperparameter tuning using Optuna
📦 Battlesnake-AI
┣ 📂 main
┃ ┣ 📜 graphs.py
┃ ┣ 📜 heuristic_agent.py
┃ ┣ 📜 logger.py
┃ ┣ 📜 mcts_agent-final.py
┃ ┣ 📜 mcts_agent-variation.py
┃ ┣ 📜 mcts_tuner.py
┃ ┣ 📜 rl_agent.py
┃ ┣ 📜 run_game.py
┃ ┣ 📜 server.py
┃ ┣ 📜 tournammentrunner.py
┃ ┗ 📜 vanilla_mcts.py
┣ 📂 optuna-mcts-final
┣ 📂 RL_Agent
┣ 📂 tourny
┣ 📜 Assignment_Description_MGAI_2.pdf
┣ 📜 run.sh
┣ 📜 run.bat
┣ 📜 run.txt
┣ 📜 battlesnake
┣ 📜 requirements.txt
┣ 📜 .gitignore
┗ 📜 README.md
You can manually run games using the included CLI:
./battlesnake play -W 11 -H 11 --name "My_AI_Snake" --url http://localhost:8000 -g solo -vDownload latest binaries or install via Go:
go install github.com/BattlesnakeOfficial/rules/cli/battlesnake@latestYes — use run.sh or run.bat for automated local matches.
- Open an issue in this repository
- Or use the official Battlesnake feedback channels