GithubHelp home page GithubHelp logo

alexeyza / battlesnake-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from poiriermike/battlesnake-go

0.0 2.0 1.0 7.39 MB

My first attempt at the BattleSnake AI competition

Home Page: http://battlesnake.io

Go 100.00%

battlesnake-go's Introduction

BattleSnake-go

This is my first attempt at the BattleSnake programming competition which I attended in 2017. I chose to write my BattleSnake in Go.

The game server API documentation can be found at https://stembolthq.github.io/battle_snake/.

Battlesnake game example

Running the BattleSnake locally

  1. Fork this repo.

  2. Clone repo to your development environment:

git clone [email protected]:USERNAME/battlesnake-go.git $GOPATH/github.com/USERNAME/battlesnake-go
cd $GOPATH/github.com/USERNAME/battlesnake-go
  1. Compile the battlesnake-go server.
go build

This will create a battlesnake-go executable.

  1. Run the server.
./battlesnake-go
  1. Test the client in your browser: http://127.0.0.1:9000. I recommend using Postman or Insomnia.

Example start game request:

{
  "width": 20,
  "height": 20,
  "game_id": "b1dadee8-a112-4e0e-afa2-2845cd1f21aa"
}
:ok

Example move request:

{
  "you": "2c4d4d70-8cca-48e0-ac9d-03ecafca0c98",
  "width": 2,
  "turn": 0,
  "snakes": [
    {
      "taunt": "git gud",
      "name": "my-snake",
      "id": "2c4d4d70-8cca-48e0-ac9d-03ecafca0c98",
      "health_points": 93,
      "coords": [
        [
          0,
          0
        ],
        [
          0,
          0
        ],
        [
          0,
          0
        ]
      ]
    },
    {
      "taunt": "gotta go fast",
      "name": "other-snake",
      "id": "c35dcf26-7f48-492c-b7b5-94ae78fbc713",
      "health_points": 50,
      "coords": [
        [
          1,
          0
        ],
        [
          1,
          0
        ],
        [
          1,
          0
        ]
      ]
    }
  ],
  "height": 2,
  "game_id": "a2facef2-b031-44ba-a36c-0859c389ef96",
  "food": [
    [
      1,
      1
    ]
  ],
  "dead_snakes": [
    {
      "taunt": "gotta go fast",
      "name": "other-snake",
      "id": "83fdf2b9-c8d0-44f4-acb2-0c506139079e",
      "health_points": 50,
      "coords": [
        [
          5,
          0
        ],
        [
          5,
          0
        ],
        [
          5,
          0
        ]
      ]
    }
  ]
}
:ok

Deploying to Heroku

  1. Create a new Go Heroku app using Go buildpack.
heroku create [APP_NAME]
  1. Add a buildpack for Go.
heroku buildpacks:set heroku/go
  1. Push code to Heroku servers. Make sure you have a vendor/vendor.json, otherwise Heroku will fail building.
git push heroku master
  1. Open Heroku app in browser.
heroku open

Or go directly via http://APP_NAME.herokuapp.com

  1. View/stream server logs.
heroku logs --tail

Running Your Own Game Server (With Docker)

  1. Install Docker. For Ubuntu follow the instructions described here: https://docs.docker.com/engine/installation/linux/ubuntu/#install-docker/

  2. Install the game server (this should also run the game server for you).

docker run -it -p 4000:4000 stembolt/battle_snake

To stop/start the game server use:

docker start vibrant_kowalevski

docker stop vibrant_kowalevski

Where vibrant_kowalevski is the name of my local game server.

  1. Visit http://localhost:4000 NOTE: Docker runs on a virtual LAN so when you add a snake to the game you cannot use http://localhost:9000, use your internal IP instead (also remove trailing /).

Acknowledgments

My code was forked from the starter code provided by SendWithUs. SendWithUs and Stembolt have put much effort and created an awesome game server for the competition.

battlesnake-go's People

Contributors

alexeyza avatar andreirtaylor avatar bvanvugt avatar dlsteuer avatar robbles avatar

Watchers

 avatar  avatar

Forkers

omazhary

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.