This project contains an AI for battlesnake https://play.battlesnake.com/. What sets the AI which we've developed apart is that we incorporate a time dimension into the A* algorithm. Instead of generating paths on a 2d grid, the A* algorithm instead traverses through a third dimension 'time'. This enables the snake to know where itself and friendly snakes are going to be at each specific point in time, and allows the snake to plan a path through time. This is all possible due to the turn-based nature of the game.
This project uses TypeScript, Node.js, and Express. It also comes with an optional Dockerfile to help with deployment.
Install dependencies using npm
npm install
Start your Battlesnake
npm run start
You should see the following output once it is running
Running Battlesnake at http://0.0.0.0:8000
Open localhost:8000 in your browser and you should see
{"apiversion":"1","author":"","color":"#888888","head":"default","tail":"default"}
Install the Battlesnake CLI
- You can download compiled binaries here
- or install as a go package (requires Go 1.18 or higher)
Command to run a local game
battlesnake play -W 11 -H 11 --name 'TypeScript Starter Project' --url http://localhost:8000 -g solo --browser
Or run as team with
npm run start
npm rum start1
battlesnake play -W 20 -H 20 --browser --name Luuk --url http://localhost:8000 --name Adrian --url http://localhost:8000 --name Noob1 --url http://localhost:8001 --name Noob2 --url http://localhost:8001
Continue with the Battlesnake Quickstart Guide to customize and improve your Battlesnake's behavior.
Note: To play games on play.battlesnake.com you'll need to deploy your Battlesnake to a live web server OR use a port forwarding tool like ngrok to access your server locally.