This project is a Rust-based implementation of the classic Snake game with an additional feature: an AI player. It employs ggez
for rendering the game environment and tch-rs
for interfacing with the Torch library, enabling the neural network to learn and adapt to the gameplay.
- AI Learning: Employs a neural network to learn the Snake game mechanics and improve over time.
- Classic Snake Mechanics: Includes all the traditional gameplay elements such as eating food to grow longer and avoiding collisions.
- Graphics Rendering: Utilizes the
ggez
crate for rendering graphics, providing a visually appealing gaming experience. - Adjustable Settings: Allows for customization of grid size, tile size, update rate, and more.
Before you begin, ensure that Rust and Cargo are installed on your machine. Refer to the Rust Installation Guide for instructions.
To get started with this project:
-
Clone the repository:
git clone https://nikita-voronoy/education.git cd education
-
Build the project using Cargo:
cargo build --release
-
Run the game:
cargo run
- Use
W
,A
,S
,D
or arrow keys for snake movement. - Grow your snake by eating food, and increase your score with each item consumed.
- Avoid hitting the walls or the snake's own body.
The game initiates with an AI-controlled snake by default. The AI decides the snake's moves based on the neural network's predictions.
If you're interested in contributing to the development of this Snake game or wish to customize it further:
- The AI logic can be tweaked within the
ai
module. - Game settings can be modified in the
Game
struct.
Feel free to fork this project and submit pull requests with your improvements!
This project is licensed under the MIT License - see the LICENSE.md file for details.