An implementation of the classic Snake game where an agent learns to play autonomously using Reinforcement Learning techniques.
This project demonstrates how an agent can learn optimal strategies through interaction with the environment, progressively improving its performance without being explicitly programmed.
The agent’s goal is to maximize the score by eating as much food as possible while avoiding collisions.
- Python 🐍
- NumPy
- PyGame (for simulation)
- PyTorch
- Reinforcement Learning (Deep Q-Learning)
The agent uses a neural network to approximate the Q-function:
- State: representation of the environment (snake position, food location, direction, dangers)
- Actions: [left, right, straight]
- Reward:
- +1 → eats food 🍎
- -1 → collision 💀
- 0 → normal movement
- Deep Q-Network (DQN)
- Experience Replay
- Epsilon-Greedy Strategy (exploration vs exploitation)
- Double DQN
- Dueling Networks
- Prioritized Experience Replay
- Hyperparameter tuning
- Advanced reward shaping
- Reinforcement Learning
- Markov Decision Process (MDP)
- Q-Learning
- Deep Neural Networks
Pull requests and suggestions are welcome!