AI agent for playing the game "Snake"
Top 25.1% on sourcepulse
This project provides an AI agent capable of playing the classic Snake game, trained using deep reinforcement learning. It offers two agent implementations: a Multi-Layer Perceptron (MLP) and a Convolutional Neural Network (CNN), with the CNN version achieving higher scores. The project is suitable for researchers and developers interested in applying RL to game environments.
How It Works
The AI agents are trained using the Stable-Baselines3 library, a popular framework for deep reinforcement learning. The CNN agent utilizes a convolutional neural network architecture, inspired by the approach in the Nature paper "Human-level control through deep reinforcement learning," to process the game state. The MLP agent uses a simpler feedforward neural network. Both agents learn to play Snake by interacting with the game environment, which is built using the Pygame library and compatible with OpenAI Gym.
Quick Start & Requirements
conda create -n SnakeAI python=3.8.16
), activate it (conda activate SnakeAI
), install PyTorch with CUDA support if using GPU (conda install pytorch=2.0.0 torchvision pytorch-cuda=11.8 -c pytorch -c nvidia
), and install dependencies (pip install -r requirements.txt
).cd main && python .\snake_game.py
cd main && python test_cnn.py
or python test_mlp.py
cd main && python train_cnn.py
or python train_mlp.py
cd main && tensorboard --logdir=logs/
Highlighted Details
trained_models_cnn/
and trained_models_mlp/
.Maintenance & Community
The project appears to be a personal project with no explicit mention of maintainers, community channels, or a roadmap.
Licensing & Compatibility
The README does not explicitly state a license.
Limitations & Caveats
The project is primarily tested on Windows 11, and compatibility with other operating systems is not guaranteed. The README does not specify the license, which could impact commercial use or integration into closed-source projects.
1 year ago
1 week