Skip to content

CarletonComputerScienceSociety/battlesnake-hackathon-starter

 
 

Repository files navigation

Battlesnake Hackathon Starter Project

This is the starting template for the Carleton Computer Science Society's 2025 Battlesnake Hackathon.

image

Getting Started

1. Create Your Replit

Click the button below to create a Replit project from this template:

Run on Replit

You will NEED to have a Replit account in order to "remix" the project template.

NOTE: Make sure you are logged into Replit first as you may hit an error if you are not logged in when you click "Remix This App".


2. Get Your Public Replit URL

Once you open your project in Replit, use the Network Manager to retrieve your Replit URL.

Start by clicking the + (new tab) icon:

image

Then search for the "Networking":

image

On the Network Manager, copy your Replit URL:

image

3. Configure Your .env File

Once you have your Replit URL, add it to your .env file.

Start by opening the file explorer by clicking the icon in the top right:

image

Click on the .env file in the file explorer and paste your Replit URL as shown:

NOTE: Make sure to hit CTRL+S to save this change. If you do not save this change, your setup will not work.

image

4. Test Your Snake

Once you've configured your Replit URL, you're ready to test your snake.

Start by opening a new tab and opening the Workflow Manager:

image

Then Click the ▶️ symbol to the left of "Run Your Snake Webserver", and optionally click Run 3 Test Snake Webservers if you'd like to see your snake compete against the test snakes in ./examples:

image

To see your snakes battle, click the ▶️ to the left of "Test Your Snake" to get begin the match:

image

NOTE: It may take a moment for the board to pop up in your browser.

If everything is setup correctly, a window should promptly open in your browser with a visualization of your snake.

Screenshot 2025-08-31 at 4 41 22 PM

NOTE: Your browser may try to block the pop up. To allow popups from Replit, click the icons as shown below (Chrome):

Other browsers should have an equivalent.

image

If you want to run another match, you need to stop then start the "Test Your Snake" workflow:

image

While your snake is running, you can see the console output of your snake and the 3 test snakes in ./examples in the console tab:

image

Coding Your Snake

To start coding your snake, open the main.py file (this is where your snakes' logic lives):

image

The most important function is move(game_state).

Battlesnake calls this every turn and sends you a JSON payload (game_state) describing the current board and your snake (an example of that request is shown in the Battlesnake docs.

Your job is to read that data and return one of: "up", "down", "left", or "right".

For example, this code would result in your snake going down every turn.

def move(game_state: typing.Dict) -> typing.Dict:
   return {"move": "down"}

When you modify main.py, make sure you ALWAYS stop, then start your Snake Webserver via the workflow page:

image

Collaborating with Teammates

To code with your teammates, have one member of your group send the others a Private Invite Link as shown in the below screenshot:

This will allow you and your teammates to collaboriate on the project alike to how you would in Google Docs.

image

Being Ready For The Tournament

To be ready for the tournament, make sure your snake has no syntax errors and is left running as shown below:

image

Environment Health Check

Having trouble getting your snake running?

Click the arrow next to the Run button, then select Run Environment Health Check.

image

This will run a script that scans your environment and reports anything that might be missing or misconfigured:

image

About

Project template for our 2025 Battlesnake hackathon

Resources

License

Stars

Watchers

Forks

Languages

  • Shell 83.7%
  • Python 15.8%
  • Nix 0.5%