parthmshah1302 / snake-ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implementing a Reinforcement Learning based Snake AI Agent using PyTorch and PyGame

Training a model using negative or positive rewards is termed as Reinforcement Learning and extending it using neural networks is known as Deep Q-Learning. Using these two methodologies and libraries like PyGame, PyTorch, etc., this project report focuses on explaining how an agent can be trained to play the snake game and score as high as possible.

Installation

Creating a virtual environment

pip3 install virtualenv
virtualenv venv
source venv/bin/activate

Use the package manager pip to install the dependencies.

pip3 install -r requirements.txt
pip3 install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu

Usage

python3 agent.py

Results

Training animation

Plot

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About


Languages

Language:Python 100.0%