A Battlesnake starter written in Python 3 and Flask.
Visit https://github.com/battlesnakeio/community/blob/master/starter-snakes.md for API documentation and instructions for running your AI.
This AI client uses Flask to serve requests and the gunicorn web server to run on Heroku. Dependencies are listed in requirements.txt.
- a Python 3.7 development environment
- pip to install Python dependencies
- virtualenv to contain the dependencies
- experience deploying Python apps to Heroku
Write your snake code in src/snake.py
-
Clone repo to your development environment:
git clone [email protected]:<your github username>/battlesnake-python3-starter.git
- Set up a virtual environment using virtualenv
# Use the default Python on your path:
virtualenv venv
# Or use a specific path:
virtualenv -p /path/to/python3 venv
- Activate the virtual environment (you have to do this every time you open a new shell)
# Linux, macOS
source venv/bin/activate
# Windows
venv/Scripts/activate.bat
- Install dependencies using pip:
pip install -r requirements.txt
- Run local server:
cd src
python app.py
- Test your snake by sending a curl to the running snake
curl -XPOST -H 'Content-Type: application/json' -d '{ "hello": "world"}' http://localhost:5000/start
- Create a new Heroku app:
heroku create [APP_NAME]
- Deploy code to Heroku servers:
git push heroku master
- Open Heroku app in browser:
heroku open
or visit https://APP_NAME.herokuapp.com.
- View server logs with the
heroku logs
command:
heroku logs --tail
This code is licensed under the MIT License. See LICENSE.
Written by Jon Pavelich and Tyler Harnadek for BattleSnake 2019. This README file is based on the battlesnakeio/starter-snake-python README.