Git Product home page Git Product logo
hirethissnake photo

hirethissnake Goto Github PK

repos: 2.0 gists: 0.0

Name: hirethissnake

Type: Organization

Bio: A collection of BattleSnake related projects, designed and built by the hirethissnake team.

Location: Victoria, BC

hirethissnake 2018

codecov Build Status

A Battlesnake AI based heavily on graphing algorithms. Written in Python 3.7 by Daniel Frankcom, Eric Showers, Kyle Thorpe, and Phil Denhoff, with contributions from Alex Welsh-Piedrahita.

Installation

Docker - Windows / Linux / Mac

You'll have to install Docker yourself, however once that is done installation and execution is relatively simple. The basic concept is that you install a Docker container which has all the required environment to run this project without installing a different version of Python, plus all the required packages.

For now, you'll have to build the docker image on your local machine - soon you'll (hopefully) be able to download a pre-built image.

First, git clone this repository to your local machine (using command line or a GUI). In command line, traverse to the the directory. Then build the docker image using this command

docker build -t hirethissnake .

docker initiates the docker program, build is the instruction to create an image, -t designates the name of the image, and we use '.' to say 'look for a Dockerfile in the current folder'.

Go to Running to see how to use the program.

Script - Linux Only

An installer file is provided to run the download the repo and all neccessary packages and programs to run the server. Currently only Linux is supported.

Download the install.sh file to your local server, where you'd like to the hirethissnake folder. Add execution permissions to the script and execute it. It will ask for your password to sudo-install some packages, and will request your github credentials to access the repo if it's private. Please feel free to expect the installer if you aren't comfortable with that, or do those steps yourself.

chmod +x ./install.sh
./install.sh

Running

Docker

Following the successful completion of docker build, we will need to actually run the container with our current code. One of the issues is that we want a constant environment (Python with required packages) but constantly changing source code. We manage this by mounting a volume in docker. Run this command:

Linux / Mac

docker run --rm -it -p 8080:8080 -v $(pwd)/app:/data/app -v $(pwd)/static:/data/static hirethissnake python "-mapp.main"

Windows - Command Prompt

docker run --rm -it -p 8080:8080 -v %cd%/app:/data/app -v $(pwd)/static:/data/static hirethissnake python "-mapp.main"

Windows - Power Shell

docker run --rm -it -p 8080:8080 -v $pwd/app:/data/app -v $(pwd)/static:/data/static hirethissnake python "-mapp.main"

Oh boy, there is a lot to unpack here. What are all these things? Why do Windows and Linux / Mac have different commands?

In a list:

  • docker : Runs docker on CLI
  • run : Execute an image (either start it and keep it started, or execute command in that environment)
  • --rm : Deletes the container when it closes (to keep your comptuter clean)
  • -it : Make the container interactive, so we can see what's going on!
  • -p 4000:8080 : Pass all data from port 8080 on the host computer into the docker image on port 8080, and vice-versa. 8080 can be changed on the CLI, but 8080 is the port that main.py executes on.
  • -v $(pwd)/app:/data/app : (Linux) The command is roughly the same on Windows. $(pwd) == %cd%, and returns the current location of the terminal. -v tells Docker to mount the folder before the colon (":") from the host computer to the folder after the colon on the Docker image. In this way, files located at %cd%/app are available inside the image at /data/app everytime you run the command, instead of having to re-build the image.
  • hirethissnake : The name of the image. This can be changed, and if you have many images, should be changed.
  • python "-mapp.main" : This command tells the docker image that we would like to use the python executable, and that we would like to run the file in the 'app' module called 'main'. This file is then executed inside its environment, running the server.

You can now make any changes you'd like to the local files in ./app and then run the docker run command above, and see those changes represented.

Manually

To run the server, execute

python app/main.py

and then test the client in your browser: http://localhost:8080

Docker Compose

For advanced users, we have included a docker-compose.yml file which is currently set up to pit 3 of our snakes against each other.

The primary usecase for this is currently using the included batch game server found at utilities/batchserver/. The docker-compose.yml file can easily be modified to run 1 snake, or for that matter any number of snakes providing the user has a basic understanding of the Docker Compose syntax. Additionally, it is not directly tied to the batch server in any way, and simply makes the various snake URLs available for access however you see fit.

In order to run the snake in this manner, Docker Compose must be installed.

First, build the snake image as instructed in the Installation section.

Then run the following command to start the snakes

docker-compose up

Questions?

Please email any questions you have to [email protected] and he'll make sure they get to the right person.

hirethissnake's Projects

2017 icon 2017

A Python AI for competition in the BattleSnake 2017 competition. We're gonna crush those other snakey fools!

2018 icon 2018

A Python AI for competition in the BattleSnake 2018 competition. You can hire this snake's developers!

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.