No description
Find a file
2021-01-19 15:33:05 -08:00
.github Update CI to Go 1.15 2021-01-19 15:07:25 -08:00
cli Invert the Y-Axis to match modern gameplay. 2021-01-19 15:33:05 -08:00
.gitignore Update build path and docs. 2020-12-10 15:02:29 -08:00
.goreleaser.yml Working goreleaser. 2020-12-10 21:08:08 -08:00
constrictor.go Rename 'maze' -> 'constrictor', remove use of food 2021-01-19 14:55:49 -08:00
constrictor_test.go Invert the Y-Axis to match modern gameplay. 2021-01-19 15:33:05 -08:00
go.mod Bump to Go 1.15 2021-01-19 14:42:36 -08:00
go.sum go mod tidy 2021-01-19 14:55:07 -08:00
LICENSE Add standard LICENSE 2020-01-01 17:40:37 -08:00
README.md Update CI to Go 1.15 2021-01-19 15:07:25 -08:00
royale.go Rename "EliminatedByStarvation" > "EliminatedByOutOfHealth" 2020-09-10 12:00:56 -07:00
royale_test.go Invert the Y-Axis to match modern gameplay. 2021-01-19 15:33:05 -08:00
ruleset.go Add RulesetError test case. 2020-12-11 10:05:19 -08:00
ruleset_test.go Add RulesetError test case. 2020-12-11 10:05:19 -08:00
solo.go Add solo gameplay ruleset. 2020-05-17 14:29:30 -07:00
solo_test.go Fix function name and interface tests. 2020-05-17 14:38:39 -07:00
squad.go Rename TeamRuleset -> SquadRuleset 2020-07-21 14:58:56 -07:00
squad_test.go Invert the Y-Axis to match modern gameplay. 2021-01-19 15:33:05 -08:00
standard.go Invert the Y-Axis to match modern gameplay. 2021-01-19 15:33:05 -08:00
standard_test.go Invert the Y-Axis to match modern gameplay. 2021-01-19 15:33:05 -08:00

BattlesnakeOfficial/rules

codecov

Battlesnake rules and game logic, implemented as a Go module. This code is used in production at play.battlesnake.com. Issues and contributions welcome!

CLI for Running Battlesnake Games Locally

This repo provides a simple CLI tool to run games locally against your dev environment.

Installation

Download precompiled binaries here:
https://github.com/BattlesnakeOfficial/rules/releases

Install as a Go package. Requires Go 1.15 or higher. [Download]

go get github.com/BattlesnakeOfficial/rules/cli/battlesnake

Compile from source. Also requires Go 1.15 or higher.

git clone git@github.com:BattlesnakeOfficial/rules.git
cd rules
go build -o battlesnake ./cli/battlesnake/main.go

Usage

Example command to run a game locally:

battlesnake play -W 11 -H 11 --name <SNAKE_NAME> --url <SNAKE_URL> -g solo -v

For more details, see the CLI README.

FAQ

How is this different from the old Battlesnake engine?

The old game engine was re-written in early 2020 to handle a higher volume of concurrent games. As part of that rebuild we moved the game logic into a separate Go module that gets compiled into the production engine.

This provides two benefits: it makes it much simpler/easier to build new game modes, and it allows the community to get more involved in game development (without the maintenance overhead of the entire game engine).

Can I run games locally?

Yes! See the included CLI.

The Y-Axis appears to be implemented incorrectly!?!?

This is because the game rules implement an inverted Y-Axis. Older versions of the Battlesnake API operated this way, and several highly competitive Battlesnakes still rely on this behaviour. The current game engine accounts for this by translating the Y-Axis (or not) based on which version of the API each Battlesnake implements. More info here and here.

In the future we might switch this to make the rules easier to develop? But until we drop support for the older API version it doesn't make sense to make that change.