What is Battlesnake?
A Battlesnake is a programmed web server that implements the Battlesnake HTTP API to play the game snake against other Battlesnakes. When a game is running, the Battlesnake Game Engine will make HTTP requests to your server, sending you game information and asking for your next move.
Step 1 - Build Your Snake
Select a technology you want to use to program your snake. Anything that can process a web request and be deployed to the internet will work. There are several Starter Snakes that can be used as a base if you don't want to start from scratch. Each is built with a popular programming language and web application framework.
Your Battlesnake must support 4 endpoints that will be called by the Game Engine:
The engine is asking your snake if it is alive
Notifies your snake that it is participating in a new game
Updates your snake with the current state of the game board and asks for a move
Notifies your snake that the game is over.
Each endpoint will be sent a JSON data blob by the Game Engine and your server must respond with a 200 status code and an appropriate JSON response. The protocol for these requests and responses are defined in detail in the Battlesnake API docs.
Snake Wisdom - Concurrent Games
Your Battlesnake is a live web service and could be playing multiple games at the same time. The /start, /move and /end requests will all contain a Game ID that uniquely identifies which game the request is for. You should develop your snake to handle requests from different games at the same time.
Step 2 - Deploy Your Snake
Before your snake can do battle, it must be deployed to a publicly accessible server. This can be done using a cloud hosting provider such as Heroku or Amazon Web Services. Many of these services provide a free tier for deploying web servers.
Many of the Starter Snakes have instructions on how to deploy the snakes to a public Heroku instance so you can get started quickly.
Snake Wisdom - Don’t Take Too Long
The Game Engine gives snakes 500 ms to respond to a /move request, including any network time. If your snake does not respond in time, the engine will reuse the move from the previous turn.
Step 3 - Register Your Snake
Once your snake is operational, it needs to be registered on the Battlesnake website. Click on the button below to setup a new snake.
Snake Wisdom - Names
Be creative with your snake's name and description! Names like test or snake1 are boring and fail to tell people about the character of your snake. That said, creativity has limits and make sure not to violate the Battlesnake Code of Conduct.
Step 4 - Battle With Your Snake
You are now ready to test your snake against others in live games.
- Go to your snake's profile page on the Battlesnake website
- Click on the Play Game button. You will see a form with your snake preselected.
- Use the Add a Random Snake button to add a challenger
- Click on Create Game button to start the game
You will be rewarded with a view of the board that includes your snake and the challenger. Click on the Play button at the bottom of the board to start the match and see who wins!