A basic implementation of the Battlesnake API in Python

Overview

Getting started with Battlesnake and Python

Battlesnake Logo

This is a basic implementation of the Battlesnake API in Python. It's a great starting point for anyone wanting to program their first Battlesnake using Python, and comes ready to deploy with Replit and Heroku, or you can use any other cloud provider you'd like.

Technologies Used

Quickstart

The Quick Start Coding Guide provides the full set of instructions to customize, register, and create your first games with your Battlesnake! While the guide uses Repl.it as an example host, the instructions can be modified to work with any hosting provider. You can also find advice on other hosting providers on our Hosting Suggestions page.

Prerequisites


Customizing Your Battlesnake

Locate the handle_info function inside server.py. At the end of that function you should see a line that looks like this:

return {
    "apiversion": "1",
    "author": "",
    "color": "#888888",
    "head": "default",
    "tail": "default",
}

This function is called by the game engine periodically to make sure your Battlesnake is healthy, responding correctly, and to determine how your Battlesnake will appear on the game board. See Battlesnake Personalization for how to customize your Battlesnake's appearance using these values.

Whenever you update these values, go to the page for your Battlesnake and select 'Refresh Metadata' from the option menu. This will update your Battlesnake to use your latest configuration and those changes should be reflected in the UI as well as any new games created.

Changing Behavior

On every turn of each game your Battlesnake receives information about the game board and must decide its next move.

Locate the handle_move function inside server.py. Possible moves are "up", "down", "left", or "right". To start your Battlesnake will choose a move randomly. Your goal as a developer is to read information sent to you about the board (available in the data variable) and decide where your Battlesnake should move next. Your Battlesnakes move logic lives in server_logic.py. This is the code you will want to edit.

See the Battlesnake Game Rules for more information on playing the game, moving around the board, and improving your algorithm.

(Optional) Running Your Battlesnake Locally

Eventually you might want to run your Battlesnake server locally for faster testing and debugging. You can do this by installing Python 3.8 and running:

python server.py

Note: You cannot create games on play.battlesnake.com using a locally running Battlesnake unless you install and use a port forwarding tool like ngrok. See Hosting Suggestions.

Running Tests

This Starter Project comes with a very simple test suite for you to expand! Located in tests.py you can run them using the following command: python tests.py -v


Playing Battlesnake

Completing Challenges

If you're looking for the Single Player Mode of Battlesnake, or something to practice with between events, check out Challenges.

Joining a Battlesnake Arena

Once you've made your Battlesnake behave and survive on its own, you can enter it into the Global Battlesnake Arena to see how it performs against other Battlesnakes worldwide.

Arenas will regularly create new games and rank Battlesnakes based on their results. They're a good way to get regular feedback on how well your Battlesnake is performing, and a fun way to track your progress as you develop your algorithm.

Joining a Battlesnake League

Want to get out there to compete and win prizes? Check out the Quick Start League Guide for information on the how and when of our competitive seasons.


Resources

All documentation is available at docs.battlesnake.com, including detailed Guides, API References, and Tips.

You can also join the Battlesnake Developer Community on Discord. We have a growing community of Battlesnake developers of all skill levels wanting to help everyone succeed and have fun with Battlesnake :)

Check out live Battlesnake events on Twitch and see what is happening when on the Calendar.

Want to contribute to Battlesnake? We have a number of open-source codebases and would love for you to get involved! Check out our page on Contributing.

Feedback

Do you have an issue or suggestions for this repository? Head over to our Feedback Repository today and let us know!

Owner
Gaurav Batra
Hi, I am a final year computer science undergraduate at IIIT, Hyderabad where I am pursuing my research at the Machine Learning Lab.
Gaurav Batra
Soundcloud Music Downloader

Soundcloud Music Downloader Description This script is able to download music from SoundCloud and set id3tag to the downloaded music. Compatible with

Ronan 2.6k Jan 01, 2023
This library is for simplified work with the sms-man.com API

SMSMAN Public API Python This is a lightweight library that works as a connector to Sms-Man public API Installation pip install smsman Documentation h

13 Nov 19, 2022
Best DDoS Attack Script Python3, Cyber Attack With 40 Methods

MXDDoS - DDoS Attack Script With 40 Methods (Code Lang - Python 3) Please Don't Attack '.gov' and '.ir' Websites :) Features And Methods πŸ’£ Layer7 GET

7 Mar 07, 2022
The Dolby.io Developer Days Getting Started with Media APIs Workshop repo.

Dolby.io Developer Days Media APIs Getting Started Application About this Workshop and Application This example is designed to get participants workin

Dolby.io Samples 2 Nov 03, 2022
To send an Instagram message using Python

To send an Instagram message using Python, you must have an Instagram account and install the Instabot library in your Python virtual environment.

Coding Taggers 1 Dec 18, 2021
The programm for collecting data from Tinkoff API and building Excel table.

tinkproject The program for portfolio analysis via Tinkoff API Hello! This is my first project, please, don't judge me. This project was developed for

214 Dec 02, 2022
An async-ready Python wrapper around FerrisChat's API.

FerrisWheel An async-ready Python wrapper around FerrisChat's API. Installation Instructions Linux: $ python3.9 -m pip install -U ferriswheel Python 3

FerrisChat 8 Feb 08, 2022
This is a discord token generator(requests) which works and makes 200 tokens per minute

Discord Email verified token generator Creates email verified discord accounts (unlocked) Report Bug Β· Discord server Features Profile pictures and na

131 Dec 10, 2022
Python script to extract all Humble Bundle keys and redeem them on Steam automagically.

humble-steam-key-redeemer Python script to extract all Humble keys and redeem them on Steam automagically. This is primarily designed to be a set-it-a

74 Jan 08, 2023
An anime themed telegram bot that can convert telegram media.

ShoukoKomiRobot β€’ π•Žπ•£π•šπ•₯π•₯π•–π•Ÿ π•€π•Ÿ Python3 β€’ π•ƒπ•šπ•“π•£π•’π•£π•ͺ π•Œπ•€π•–π•• Pyrogram β€’ π•Šπ• π•—π•₯𝕨𝕒𝕣𝕖 π•Œπ•€π•–π•• Ebook-convert Deploy π”½π• π•£π•œ π•₯π•™π•šπ•€ 𝕣

25 Aug 14, 2022
GroupMenter : New Telegram Group Manager BotπŸ”ΈFast πŸ”ΈPythonπŸ”ΈPyrogram πŸ”Έ

GroupMenter An PowerFull Group Manager Bot. Written In Pytelethon. Info β€’ A modular Telegram Python bot running on python3. β€’ Can be found on telegram

Group Menter 24 Jun 28, 2022
Image-Bot-Discord - This Is a discord bot that shows the specific image you search from Google

Advanced Discord.py Image Bot CREDITS Made by RLX and Mathiscool README by Milrato Installation Guide in .env Adjust the TOKEN python main.py to start

RLX 3 Jan 16, 2022
Python client for the Datadog API

datadog-api-client-python This repository contains a Python API client for the Datadog API. The code is generated using openapi-generator and apigento

Datadog, Inc. 58 Dec 16, 2022
quote is a python wrapper for the Goodreads Quote API, powered by gazpacho.

About quote is a python wrapper for the Goodreads Quote API, powered by gazpacho.

Max Humber 11 Nov 10, 2022
A cut down version of QUANT containing just the model in Python (QUANTPy)

A cut down version of QUANT containing just the model in Python (QUANTPy)

2 Apr 15, 2022
Fetch information about a public Google document.

xeuledoc Fetch information about any public Google document. It's working on : Google Docs Google Spreadsheets Google Slides Google Drawning Google My

Malfrats Industries 655 Jan 03, 2023
A telegram bot script for generating session string using pyrogram and telethon on Telegram bot

String-session-Bot Telegram Bot to generate Pyrogram and Telethon String Session. A star ⭐ from you means a lot to us! Usage Deploy to Heroku Tap on a

Wahyusaputra 8 Oct 28, 2022
β†’ Comando BΓ‘sico para Python Discord

Discord.py Β· CΓ³digo @client.event async def on_ready(): print('He iniciado sessiΓ³n en: {0.user}'.format(client)) @client.event async def on_messa

Panda.xyz 4 Mar 12, 2022
Cedric Owens 16 Sep 27, 2022
A small discord bot to interface with python-discord's snekbox.

A small discord bot to interface with python-discord's snekbox.

Hassan Abouelela 0 Oct 05, 2021