snake-ai  by linyiLYi

AI agent for playing the game "Snake"

Created 2 years ago
1,751 stars

Top 24.5% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

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

  • Install: Create a conda environment (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).
  • Prerequisites: Python 3.8.16, Anaconda, PyTorch (GPU recommended for training), Pygame, OpenAI Gym, Stable-Baselines3.
  • Running the Game: cd main && python .\snake_game.py
  • Testing Agents: cd main && python test_cnn.py or python test_mlp.py
  • Training: cd main && python train_cnn.py or python train_mlp.py
  • Viewing Curves: cd main && tensorboard --logdir=logs/
  • Docs: README

Highlighted Details

  • Offers both CNN and MLP based RL agents for Snake.
  • Includes scripts for training, testing, and visualizing training progress via Tensorboard.
  • Provides utility scripts for checking GPU status and compressing code for LLM interaction.
  • Trained models for different stages are available in 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.

Health Check
Last Commit

1 year ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
5 stars in the last 30 days

Explore Similar Projects

Starred by Jiayi Pan Jiayi Pan(Author of SWE-Gym; MTS at xAI) and Jianwei Yang Jianwei Yang(Research Scientist at Meta Superintelligence Lab).

allenact by allenai

0%
369
Open-source framework for embodied AI research
Created 5 years ago
Updated 3 weeks ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Mckay Wrigley Mckay Wrigley(Founder of Takeoff AI), and
1 more.

street-fighter-ai by linyiLYi

0.1%
6k
AI agent for Street Fighter II using deep reinforcement learning
Created 2 years ago
Updated 1 year ago
Feedback? Help us improve.