Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Latest commit

 

History

History
43 lines (29 loc) · 1.15 KB

README.md

File metadata and controls

43 lines (29 loc) · 1.15 KB

genetic-snake-rs

Teaching a bot to play Snake, without telling it anything about the rules, using a genetic algorithm.

The bot that the genetic algorithm tries to train is based on heuristic values: at each step it computes a set of values for each move. Then, it computes a weighted sum for each action and executes the one with the highest value.

I choose "good weights" as default values for the HeuristicBot, which serves as a reference. Then, the genetic algorithm tries to learn weights which beat my good weights.

To see/tune the genetic algorithm parameters and methods, go to src/learning.rs.

To see what are the heuristic values and how they are computed, go to src/heuristic_bot.rs.

asciicast

Usage

To run genetic-snake-rs, a recent stable Rust should work.

The easiest way to get Rust is via rustup.

Then, simply run:

cargo run --release

License & Contributing

This repository is licensed under the permissive MIT license, meaning that you can and are encouraged to hack this code!

Any PR is welcomed! 🐍