Battlesnake Engine
API and game logic for Battlesnake.
Install and setup
-
Install Golang if you haven't already here
-
Set your GOPATH, here
-
Add Go's bin folder to your paths. More on that here, or you can use:
export PATH="$PATH:$GOPATH/bin"
-
Git clone the project into $GOPATH/src/github.com/battlesnakeio/engine
. Note, the docs for GOPATH and project directory layouts can be found here.
Running the engine
Build an excutable via make install
and then run engine server
to run a local version of the server.
Better command: make run
Note: if you use the Makefile, you'll want JQ installed, here
Running a game with the CLI
- Setup a
snake-config.json
, by default the engine looks in the HOME directory (see make run-game in the Makefile)
Here's an example:
{
"width": 20,
"height": 20,
"food": 10,
"snakes": [
{
"name": "Snake 1",
"url": "http://localhost:8080"
},
{
"name": "Snake 2",
"url": "http://localhost:3001"
}
]
}
-
Start the engine (refer above)
-
Start a game with make run-game
Example Output:
⇒ make run-game
go install github.com/battlesnakeio/engine/cmd/engine
engine-cli run -g "d151fe9d-8c15-4d31-a932-e7b4248d5586"
- To replay a game, run:
engine replay -g <game id>
For more information about the engine:
engine --help
engine [command] --help
Backend configuration
Storage options:
inmem
- This is the default. All game data is erased when the engine restarts.
file
- Stores one file per game. Games can be resumed or replayed after restart.
Examples:
Save games as files in ~/battlesnake/
engine all --backend file --backend-args ~/battlesnake
API
Refer to the docs repository, specifically the snake api here which can viewed with Swagger's editor