A comprehensive implementation of Deep Q-Network (DQN) and Double DQN algorithms for training an AI agent to play FlappyBird .
- 3xter666, github profile: https://github.com/3xter666
- duyhoclaptrinh7, github profile: https://github.com/duyhoclaptrinh7
This project implements and compares two reinforcement learning algorithms:
- Deep Q-Network (DQN): The foundational deep reinforcement learning algorithm
- Double DQN: An improved version that addresses the overestimation bias of standard DQN
The agent learns to play FlappyBird through trial and error, using experience replay and target networks to stabilize training.
- Complete DQN Implementation: Built from scratch using PyTorch
- Double DQN Support: Toggle between standard DQN and Double DQN
- Experience Replay: Efficient memory buffer for stable learning
- Configurable Hyperparameters: Easy experimentation via YAML configuration
- Training Visualization: Real-time plots of rewards and epsilon decay
- Model Persistence: Save and resume training sessions
- Comprehensive Logging: Detailed training logs with timestamps
- Clone the repository
git clone https://github.com/3xter666/dqn-flappybird.git
cd dqn-flappybird- Create a virtual environment
conda create -n dqnenv python=3.9
conda activate dqnenv- Install dependencies
pip install torch gymnasium matplotlib numpy pyyaml
pip install flappy-bird-gymnasiumStandard DQN:
python agent.py flappybird_dqn1 --trainDouble DQN:
python agent.py flappybird_ddqn1 --trainpython agent.py flappybird_dqn1 --train --resumepython agent.py flappybird_dqn1Edit hyperparameters.yaml to customize training: