This project is a 3D implementation of the classic Snake game, designed to showcase the capabilities of reinforcement learning in a more complex spatial environment.
The game is built using Python and integrates with the OpenAI Gym library to provide a standardized environment for training reinforcement learning agents.
You can play the game, train a RL model (DQN,...) or use a pretrained-model to see how well AI is playing.
tbd (probably GPU necessary)
We recommend python >= 3.11 (not tested with earlier versions):
- Clone the repository:
git clone https://github.com/straeter/Snake3D.git cd Snake3D - Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the required Python packages:
pip install -r requirements.txt
In this 3D version of Snake, the game takes place within a 10x10x10 grid with periodic boundaries (left in, right out etc.). The rules are adapted to suit a three-dimensional gameplay:
- Movement: The snake moves forward automatically every time step t. Players can alter the snake's trajectory left, right, up, or down relative to its current direction, but it cannot reverse.
- Objective: The objective is to eat apples that randomly appear in the grid, each of which makes the snake longer.
- End of game: The game ends if the snake collides with itself or if it fills the whole grid
- Reward (default values): +1 for eating an apple, -10 for colliding (dying)
To run the game, use the following command after installation:
python main.pyThis command starts the game environment and the reinforcement learning agent begins its training. You can view the progress in the terminal or modify the render method to create a visual representation.
tbd
This project is open-sourced under the MIT License. Feel free to use, modify, and distribute the code as you see fit. See LICENSE file for more details.