Skip to content

masddffee/Machine-Learning-Snake

Repository files navigation

AI-Powered Snake Game

License: MIT

An AI agent that learns to play the classic Snake game using Deep Q-learning (DQN) with PyTorch and Pygame.


✨ Features

  • AI Training: Implemented with the Deep Q-Network (DQN) algorithm.
  • Live Visualization: Real-time gameplay screen to observe the AI's learning progress.
  • Performance Tracking: Plots scores and mean scores to track learning progress.

🛠️ Tech Stack

  • Language: Python
  • Libraries: PyTorch, Pygame, NumPy

🚀 Getting Started

1. Clone the repository:

git clone https://github.com/masddffee/Machine-Learning-Snake.git
cd Machine-Learning-Snake

2. Install dependencies:

# It is recommended to use a virtual environment
python -m venv env
source env/bin/activate # On Windows use `env\Scripts\activate`

pip install torch pygame numpy matplotlib

3. Run the training script:

python agent.py

4. Run the game with a pre-trained model:

python play_snake.py # Make sure a model.pth file exists

About

An AI agent that learns to play the classic Snake game using Deep Q-learning (DQN) with PyTorch and Pygame.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages