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
Multi Account Generator Minecraft/NordVPN/Hulu/Origin And ...

Multi Account Generator Minecraft/NordVPN/Hulu/Origin And ...

76 Jan 01, 2023
⭐️ Pyro String Generator ⭐️ Genrate String Session Using this bot.Made by TeamUltronX 🔥

⭐️ Pyro String Generator ⭐️ Genrate String Session Using this bot.Made by TeamUltronX 🔥 Configs: API_HASH Get from Here. API_ID Get from Here. API_KE

TheUltronX 2 Dec 16, 2022
A Python wrapper for the Yelp API v2

python-yelp-v2 A Python wrapper for the Yelp API v2. The structure for this was inspired by the python-twitter library, and some internal methods are

Matthew Conlen 12 Oct 24, 2017
dex.guru python sdk

dexguru-sdk.py dexguru-sdk.py allows you to access dex.guru public methods from your async python scripts. Installation To install latest version, jus

DexGuru 17 Dec 06, 2022
fhempy is a FHEM binding to write modules in Python language

fhempy (BETA) fhempy allows the usage of Python 3 (NOT 2!) language to write FHEM modules. Python 3.7 or higher is required, therefore I recommend usi

Dominik 27 Dec 14, 2022
A simple use library for bot discord.py developers

Discord Bot Template It's a simple use library for bot discord.py developers. Ob

Tir Omar 0 Oct 16, 2022
Best badge generator API to count visitors of your Repository / Account 🥇

github visitors badge A badge generator service to count visitors of your markdown file. Hello every one! In this post, I will tell you the story of m

Sᴇɴᴜ Gᴀᴍᴇʀ Bᴏʏ 〽 3 Dec 11, 2021
Wakatime Response In javascript and python

Project Title Wakatime Response In javascript and python Description just for refrence Getting Started Dependencies For Python: requests json For Java

Gjenius20 1 Dec 31, 2021
Algofi Python SDK is useful for developers who want to programatically interact with the Algofi lending protocol

algofi-py-sdk Algofi Python SDK Documentation https://algofi-py-sdk.readthedocs.

Algofi 41 Dec 15, 2022
Discord CTF helper bot for CyberErudites

Eruditus - CTF helper bot Eruditus - CTF helper bot About Eruditus is a Discord CTF helper bot built with Python, it was initially designed to be used

Hafidh 34 Dec 30, 2022
A python library for creating Slack slash commands using AWS Lambda Functions

slashbot Slashbot makes it easy to create slash commands using AWS Lambda functions. These can be handy for creating a secure way to execute automated

Eric Brassell 17 Oct 21, 2022
Use GitHub Actions to create a serverless service.

ActionServerless - Use GitHub Actions to create a serverless service ActionServerless is an action to do some computing and then generate a string/JSO

107 Oct 28, 2022
Script for downloading Coursera.org videos and naming them.

Coursera Downloader Coursera Downloader Introduction Features Disclaimer Installation instructions Recommended installation method for all Operating S

Coursera Downloader 9k Jan 02, 2023
Unofficial GoPro API Library for Python - connect to GoPro via WiFi.

GoPro API for Python Unofficial GoPro API Library for Python - connect to GoPro cameras via WiFi. Compatibility: HERO3 HERO3+ HERO4 (including HERO Se

Konrad Iturbe 1.3k Jan 01, 2023
🐲 Powerfull Discord Token Stealer made in python

🐲 Follow me here 🐲 Discord | YouTube | Github ☕ Usage 💻 Downloading git clone https://github.com/KanekiWeb/Powerfull-Token-Stealer

Kaneki 61 Dec 19, 2022
A telegram bot which can show you the status of telegram bot

BotStatus-Ts-Bot An open source telegram Bot Status bot For demo you can check here The status is updated in every 1 hour About Bot This is a Bot stat

Ts_Bots 8 Nov 17, 2022
Support for Competitive Coding badges to add in Github readme or portfolio websites.

Support for Competitive Coding badges to add in Github readme or portfolio websites.

Akshat Aggarwal 2 Feb 14, 2022
A python script fetches all your starred repositories from your GitHub account and clones them to your server so you will never lose important resources

A python script fetches all your starred repositories from your GitHub account and clones them to your server so you will never lose important resources

Ringo Hoffmann 27 Oct 01, 2022
Name says it all/Instructions are in README file.

Discord-Webhook-Spammer Name says it all/Instructions are in README file. Setup 1. pip install discord-webhook ( In console, terminal or whatever you

Catto 1 Mar 21, 2022
Github-Checker - Simple Tool To Check If Github User Available Or Not

Github Checker Simple Tool To Check If Github User Available Or Not Socials: Lan

ميخائيل 7 Jan 30, 2022