engine

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2018 License: AGPL-3.0

README

Battlesnake Engine

Build Status Maintainability Test Coverage

API and game logic for Battlesnake.


Install and setup

  1. Install Golang if you haven't already here

  2. Set your GOPATH, here

  3. Add Go's bin folder to your paths. More on that here, or you can use: export PATH="$PATH:$GOPATH/bin"

  4. 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

  1. 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"
        }
    ]
}
  1. Start the engine (refer above)

  2. 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"
  1. 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

Directories

Path Synopsis
cmd
Package controller provides an API available to workers to write games.
Package controller provides an API available to workers to write games.
pb
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.
Package version exports a version variable.
Package version exports a version variable.
Package worker provides the actual running of games.
Package worker provides the actual running of games.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL