Skip to content

noveb/battlesnake

Repository files navigation

Battlesnake

This is my snake for the AI competition Battlesnake and pretty successful. It reached rank 39 and in the Global Arena versus ~550 opponents on Saturday 2/19/2022.

Battlesnake Global Arena ranking

Battlesnake - about the game

Battlesnake is an autonomous survival game. Each Battlesnake is controlled autonomously by a live web server and moves independently attempting to find food, avoid other Battlesnakes, and stay alive as long as possible.

from Battlesnake docs

alt alt alt


Prerequisites

Installation and start

  1. Clone the repo

    git clone https://github.com/noveb/battlesnake.git
  2. Install development dependencies

    Most things can be done in/with Docker but it is still useful to install the dependencies and needed for the git hooks.

    npm install
  3. Build Docker image for development

    docker-compose build
  4. Run the Docker container for development

    docker-compose up

Usage

There are various options and docker-compose files to run this for different purposes:

  1. TDD with live games

    The default d-c file docker-compose.yml starts the server and restarts on file changes. Use this to make changes and verify in live games.

    docker-compose up [--build]
  2. TDD with unit / integration tests

    The d-c file docker-compose.test.yml does not start the server but runs jest --watch for test driven development. Useful when writing algorithms and strategies.

    docker-compose --file docker-compose.test.yml up [--build]
  3. Production & beta

    The d-c file docker-compose.production.yml and docker-compose.beta-test.yml are almost equal but use different ports. The image and container are optimized for production (no dev dependencies & tools, proper tsc build, ...). Beta can be used to test updates and verify that they are better or experiment with new game modes without risk for the ranking of your main snake.

    docker-compose --file docker-compose.production.yml up [--build]
    
    docker-compose --file docker-compose.production.yml up [--build]

Database and save games

In the d-c stack is MongoDB and mongo-express included. The API will save every game and game step for later debugging. A game step can be replayed with Postman or curl. The database is not needed to play games.

Acknowledgments

Special thanks to Xueqiao (Joe) Xu and his PathFinding.js package. It is used to find shortest paths to food and other targets.

Useful tools and resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published