Skip to content

bitcloud2/battlesnake-mojo

Repository files navigation

Battlesnake Mojo Starter Project

A Battlesnake written in Mojo. Get started at play.battlesnake.com.

This project is a great starting point for anyone wanting to program their first Battlesnake in Mojo. It can be run locally or easily deployed to a cloud provider of your choosing. See the Battlesnake API Docs for more detail.

Technologies Used

This project uses Python 3, Mojo, and Lightbug. It also comes with an optional Dockerfile to help with deployment.

Run Your Battlesnake

Note: Tested with Mojo 24.5.0 and lightbug_http v0.1.3. Dockerfile has not yet been update to utilize Mojo 24.5 and Magic.

  1. Install Mojo. Learn how on the Modular website.

  2. Clone this repo.

  3. Run magic install in the battlesnake-mojo directory.

  4. Start your Battlesnake

    mojo main.mojo

You should see the following output once it is running

🔥🐝 Lightbug is listening on http://0.0.0.0:8000
Ready to accept connections...

Open localhost:8000 in your browser and you should see

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

Play a Game Locally (untested/probably won't work)

Install the Battlesnake CLI

Command to run a local game

battlesnake play -W 11 -H 11 --name 'Python Starter Project' --url http://localhost:8000 -g solo --browser

Next Steps

Continue with the Battlesnake Quickstart Guide to customize and improve your Battlesnake's behavior.

Note: To play games on play.battlesnake.com you'll need to deploy your Battlesnake to a live web server OR use a port forwarding tool like ngrok to access your server locally.

About

Creating a battlesnake using the Mojo programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published