Welcome to the DQN-Breakout repository! This project implements a Deep Q-Network (DQN) to play the classic Breakout game using reinforcement learning. The DQN learns to navigate the game environment, maximizing its cumulative rewards over time.
- Introduction
- Getting Started
- Usage
- Project Structure
- Training Process
- Results
- Contributing
- License
- Acknowledgments
The Breakout game is a classic arcade game where the player controls a paddle to bounce a ball and break bricks. This project leverages the DQN algorithm to train an agent capable of playing Breakout autonomously. The DQN learns a policy to maximize the cumulative rewards, achieving impressive performance over time.
Ensure you have the following prerequisites installed:
- Python 3.6 or later
- TensorFlow
- OpenAI Gym
- Matplotlib
- Other dependencies (check
requirements.txt
)
-
Clone the repository:
git clone https://github.com/your-username/DQN-breakout.git
-
Navigate to the project directory:
cd DQN-breakout
-
Install dependencies:
pip install -r requirements.txt
To train the DQN agent for Breakout, run the following command:
python breakout.py
This will initiate the training process, and the agent will learn to play Breakout. You can customize various parameters in the script, such as epsilon values, preprocessing, learning rate and more.
The organization of this project is as follows:
-
breakout.py
: This script serves as the main implementation of the DQN training for the Breakout game. -
saved_models/
: This directory stores the saved models generated during the training process. -
experience replay/
: In this directory, you can find the saved experience replay data, crucial for reinforcement learning. -
training_stats.csv
: A CSV file where training statistics are logged, including episode rewards, epsilon values, average rewards, and more. -
requirements.txt
: This file lists all the dependencies required for a smooth installation process.
The training process comprises several key steps:
-
Environment Setup: Initialize the Breakout game environment and set up essential parameters.
-
Q-Network Implementation: Implement the Deep Q-Network (DQN) using TensorFlow and Keras.
-
Preprocessing: Transform raw frames into a suitable format for the DQN using a preprocessing function.
-
Training Loop: Execute the primary training loop, involving an exploration-exploitation strategy, experience replay, and model updates.
-
Model Saving: Periodically save both the main model and the target model during training.
-
Experience Replay Saving: Save experience replay data regularly for potential future use.
-
Training Statistics Logging: Log various training statistics, including episode rewards, epsilon values, average rewards, and other relevant metrics.
-
Training Completion Check: Check for completion criteria, such as reaching a specific running reward, and print relevant information.
-
Save Final Models and Experience Replay: Save the final trained models and the experience replay data before concluding the training process.
The trained DQN agent demonstrates its proficiency in playing the Breakout game effectively. Detailed training statistics are logged in the training_stats.csv
file, providing insights into the agent's performance throughout the training.
Contributions from the community are highly welcome. Whether you've identified a bug or have an enhancement in mind, feel free to open an issue or submit a pull request. Let's collaborate to enhance DQN-Breakout!
This project is licensed under the MIT License - see the LICENSE file for more details.