Skip to content

About

๐Ÿš— Deep Q-Network (DQN) car racing project - Final semester project for AI/ML course. Learn to build and train autonomous agents using reinforcement learning with PyTorch and PyGame. Complete with GUI interface and training visualization.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

ย 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ AI Racing Project - Deep Reinforcement Learning for Autonomous Driving

๐Ÿšง This repository is archived / no longer maintained as of May 2025. Feel free to fork or use the code as needed.

Python PyTorch Deep Learning Reinforcement Learning GUI

๐Ÿ’ผ Key Technical Skills Demonstrated

๐Ÿค– Machine Learning & AI

  • Deep Q-Network (DQN): Custom implementation with experience replay and target networks
  • Reinforcement Learning: State-action-reward optimization for autonomous decision making
  • Neural Network Architecture: Multi-layer perceptron with ReLU activation (256โ†’128โ†’4)
  • Prioritized Experience Replay: Advanced sampling strategy for efficient learning
  • Hyperparameter Tuning: Epsilon-greedy strategy, learning rate optimization

๐Ÿ’ป Software Engineering

  • Object-Oriented Programming: Clean, modular Python codebase with proper inheritance
  • GUI Development: Professional PyQt5 interface with real-time data visualization
  • Design Patterns: MVC architecture, threading for non-blocking operations
  • Data Management: CSV logging, model serialization, replay buffer implementation
  • Version Control: Git workflow with feature branches and proper documentation

๐Ÿ”ฌ Data Science & Analytics

  • Real-time Visualization: Matplotlib integration for training metrics and performance analysis
  • Statistical Analysis: Training convergence monitoring, performance benchmarking
  • Data Processing: State normalization, reward engineering, noise injection for robustness
  • Model Evaluation: Comparative analysis between DQN and NEAT algorithms

๐ŸŽฎ Computer Graphics & Simulation

  • 2D Game Engine: PyGame implementation with collision detection and physics
  • Sensor Simulation: Radar-based perception system with distance measurements
  • Computer Vision: Environmental state representation and feature extraction
  • Real-time Rendering: 60fps visualization with dynamic object movement

๐ŸŽฏ Project Highlights for Employers

๐Ÿš€ Innovation & Problem Solving

  • Implemented state-of-the-art DQN algorithm from scratch (not using high-level libraries)
  • Designed custom reward function balancing multiple objectives (speed, safety, efficiency)
  • Solved complex continuous control problem using discrete action space
  • Created robust training pipeline with checkpoint management and recovery

๐Ÿ“Š Business Value & Impact

  • Autonomous Systems: Directly applicable to self-driving cars, robotics, and automation
  • Scalable Architecture: Modular design allows easy extension to new environments
  • Performance Optimization: CUDA acceleration for faster training on GPU
  • User Experience: Professional GUI makes complex AI accessible to non-technical users

๐Ÿ› ๏ธ Technical Implementation Details

# Core DQN Architecture
class DQN(nn.Module):
    def __init__(self, input_dim=5, output_dim=4):
        super(DQN, self).__init__()
        self.net = nn.Sequential(
            nn.Linear(input_dim, 256),
            nn.ReLU(),
            nn.Linear(256, 128),
            nn.ReLU(),
            nn.Linear(128, output_dim)
        )
  • Advanced Features: Target network stabilization, epsilon decay scheduling
  • Memory Management: Circular buffer with prioritized sampling (20K+ experiences)
  • Training Stability: Gradient clipping, loss smoothing, periodic target updates

๐Ÿ—๏ธ System Architecture & Design

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   PyQt5 GUI     โ”‚โ—„โ”€โ”€โ–บโ”‚   DQN Agent      โ”‚โ—„โ”€โ”€โ–บโ”‚  Racing Env     โ”‚
โ”‚  - Model Mgmt   โ”‚    โ”‚  - Neural Net    โ”‚    โ”‚  - Physics      โ”‚
โ”‚  - Training UI  โ”‚    โ”‚  - Replay Buffer โ”‚    โ”‚  - Collision    โ”‚
โ”‚  - Visualizationโ”‚    โ”‚  - Target Net    โ”‚    โ”‚  - Sensors      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Data Analytics โ”‚    โ”‚   PyTorch Core   โ”‚    โ”‚   PyGame Engine โ”‚
โ”‚  - CSV Logging  โ”‚    โ”‚  - CUDA Support  โ”‚    โ”‚  - 2D Graphics  โ”‚
โ”‚  - Matplotlib   โ”‚    โ”‚  - Optimization  โ”‚    โ”‚  - Event Loop   โ”‚
โ”‚  - Performance  โ”‚    โ”‚  - Gradients     โ”‚    โ”‚  - Asset Mgmt   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๏ฟฝ Results & Performance Metrics

๐Ÿ“Š Performance Improvements

Aspect Improvement Description
Navigation Capability Learns to complete tracks without crashes after training
Decision Making Develops smooth steering and speed control strategies
Learning Efficiency Demonstrates convergence within hundreds of episodes
Behavioral Consistency Achieves reproducible performance across multiple runs
Collision Avoidance Significant reduction in wall collisions and crashes
Track Completion Progressive improvement from frequent crashes to successful laps

๐Ÿ”ฌ Algorithm Comparison

  • DQN vs NEAT: Both implementations included for comparative analysis
  • Hyperparameter Sensitivity: Extensive testing of learning rates, batch sizes
  • Generalization: Models perform well across different track layouts

๏ฟฝ Installation & Demo

Quick Setup

git clone https://github.com/YourUsername/AI_Racing_Project
cd AI_Racing_Project
pip install -r requirements.txt
python src/UI.py  # Launch professional GUI

Core Dependencies

torch>=1.9.0      # Deep learning framework
numpy>=1.21.0     # Numerical computing
pygame>=2.0.0     # Game engine
PyQt5>=5.15.0     # Professional GUI
matplotlib>=3.5.0 # Data visualization

๏ฟฝ Learning Outcomes & Professional Growth

๐Ÿ“š Advanced Concepts Mastered

  • Temporal Difference Learning: Q-learning with function approximation
  • Experience Replay: Breaking correlation in sequential data
  • Exploration vs Exploitation: Epsilon-greedy with decay scheduling
  • Neural Network Optimization: Adam optimizer, gradient clipping
  • Multi-threading: Non-blocking GUI with background training

๐ŸŽฏ Industry-Relevant Skills

  • MLOps: Model versioning, checkpoint management, reproducible training
  • Software Architecture: Separation of concerns, dependency injection
  • Performance Optimization: GPU acceleration, memory management
  • User Interface Design: Intuitive controls, real-time feedback
  • Documentation: Comprehensive README, code comments, API documentation

๐Ÿ”ฌ Research & Development

  • Literature review of DQN variants and improvements
  • Experimental design for hyperparameter optimization
  • Statistical analysis of training convergence
  • Comparative evaluation of different algorithms

๐Ÿ† Why This Project Stands Out

๐Ÿ’ก Technical Depth

  • From Scratch Implementation: No high-level RL libraries, pure PyTorch and mathematical understanding
  • Production-Ready Code: Error handling, logging, configuration management
  • Scalable Design: Easy to extend with new algorithms or environments
  • Best Practices: Type hints, docstrings, unit testing structure

๐ŸŽฏ Real-World Applications

  • Autonomous Vehicles: Direct relevance to self-driving car industry
  • Robotics: Path planning and navigation algorithms
  • Game AI: Advanced NPC behavior and decision making
  • Financial Trading: Sequential decision making under uncertainty

๐Ÿ“ˆ Measurable Impact

  • Algorithm Performance: Quantifiable improvement metrics
  • Code Quality: Clean, maintainable, well-documented codebase
  • User Experience: Professional interface accessible to stakeholders
  • Knowledge Transfer: Comprehensive documentation for team collaboration

๐Ÿ™ Acknowledgments & References

๐Ÿ“š Core Inspiration

  • Original Concept: Cheesy AI - Car Racing Tutorial
    • Base game mechanics and track design inspiration
    • Physics simulation and collision detection concepts
    • NEAT algorithm implementation reference
  • Code Optimization: NeuralNine (Florian Dedov)
    • Code structure improvements and optimization techniques
    • Enhanced commenting and documentation practices
    • Python best practices implementation
  • Algorithm Enhancement: Custom DQN implementation with advanced RL features

๐Ÿ› ๏ธ Technical Frameworks

  • PyTorch Team: Deep learning framework and CUDA optimization
  • PyGame Community: 2D game engine and graphics rendering
  • PyQt5 Developers: Professional GUI framework
  • Open Source Community: Matplotlib, NumPy, and scientific Python ecosystem

๐ŸŽฏ Academic References

  • "Playing Atari with Deep Reinforcement Learning" - Mnih et al. (2013)
  • "Prioritized Experience Replay" - Schaul et al. (2015)
  • "NEAT: NeuroEvolution of Augmenting Topologies" - Stanley & Miikkulainen (2002)

This project represents a significant evolution from the original tutorial, incorporating advanced RL techniques, professional software architecture, and production-ready implementation for portfolio demonstration.

About

๐Ÿš— Deep Q-Network (DQN) car racing project - Final semester project for AI/ML course. Learn to build and train autonomous agents using reinforcement learning with PyTorch and PyGame. Complete with GUI interface and training visualization.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages