Giter VIP home page Giter VIP logo

starter-snake-rust's Introduction

Getting started with Battlesnake and Rust

Battlesnake Logo

This is a basic implementation of the Battlesnake API in Rust. It's a great starting point for anyone wanting to program their first Battlesnake using Rust, 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 optimizes around local development for quick iteratation, you may choose to host it with Repl.it or a provider of your choice. You can find advice on other hosting providers within our Hosting Suggestions page.

Prerequisites


Customizing Your Battlesnake

Locate the get_info function inside logic.rs. Inside that function you should see a line that looks like this:

return json!({
    "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 get_move function inside logic.rs. 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 and decide where your Battlesnake should move next. 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

Because rocket requires nightly builds of rust we recommend you use rustup to get started then set the project to use the nightly builds

rustup override set nightly

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.

Running Tests

We're look for a community member to produce a very simple test suite for developers to expand! If this is something you are able to do, please feel free to make a Pull Request.

(Optional) Running your Battlesnake on Heroku

If you are interested in using Heroku to deploy your Battlesnake, you will need to specify a buildpack as Heroku does not directly supply one for Rust. You can use the Heroku Buildpack for Rust and substitue the following Heroku commands for step 2 of the Battlesnake Heroku guide. :

heroku create [YOUR-APP-NAME]
heroku buildpacks:set emk/rust
git push heroku main
heroku open

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!

starter-snake-rust's People

Contributors

bvanvugt avatar martinamps avatar aurorawalker avatar chris-bsnake avatar jfgodoy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.