/cedar

Rust Diaries III: Automatic Snake Player

Primary LanguageRust

This is part of a series of fun little programs I write to learn rust:

  • Alder: Conway's Game of Life
  • Balsa: Image to Emoji
  • Cedar: Auto snake game

Cedar

Have you ever wanted to watch your computer play snake in a somewhat clumsy fashion? Here you go!

cargo run and enjoy! 🐍

Usage

You can choose the decision algorithm the snake uses via commandline flags. The available options are:

  • --random (default): The snake chooses a random (possible) direction for every step
  • --greedy: The snake selects the (possible) direction which brings her closest to the food in the next step
  • --angle: If the food is in the same column as the snake, she goes down. Otherwise, she goes right.

Use --help for more information.