This project showcases a Deep Q-Network (DQN) based reinforcement learning agent trained to play the Chrome Dino game. Built using PyGame and Gym style wrapper, the agent learns to survive and jump over obstacles effectively, mimicking human play through observation-based state input.
- Custom Game Environment: Recreated Chrome Dino game using PyGame
- Gym-Compatible: Environment is wrapped using Gym style wrapper for easy training/testing
- DQN Agent: Deep Q-Learning with experience replay and target network
- Frame Skipping: Improves training efficiency and simulates human-like reaction
- Metrics & Logging: Training reward graphs and test performance included
-
Clone the repo:
git clone https://github.com/Tanmay0766/Ai-Dino-Agent-using-DQN.git cd Ai-Dino-Agent-using-DQN
-
Create the Conda Environment:
Create a new environment using the provided environment.yml file:
conda env create -f environment.yml
Activate the Environment:
conda activate your-env-name
-
Install dependencies:
pip install -r requirements.txt
-
Run training:
python train.py
-
Test the trained agent:
python test.py
The agent receives the following state vector:
- Dino's vertical position
- Vertical velocity
- Distance to next cactus
- Cactus height
- Cactus width
- game.py_# Original dino game
- dino_env.py_# Pygame environment logic
- gym_dino_env.py_# Gym wrapper
- agent.py_# DQN agent
- train.py_# Training script
- test1.py_# Testing script
- test2.py_# Test metrices and graph
- best_dqn_dino.pth_# Saved model (trained)
- README.md
This project is licensed under the MIT License.