Skip to content

About

A virtual car AI using Q-Learning and Ensemble Learning to learn and navigate custom tracks through multiple specialized experts, with real-time training stats and problem detection.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Q-Learning Car AI System with Ensemble Learning

About the Project

This project implements a sophisticated Q-Learning system combined with Ensemble Learning, where a virtual car learns to navigate custom tracks through trial and error.
The AI uses multiple specialized "experts" that cooperate and compete to find the best driving strategy.


Main Features

Track Editor

Create custom tracks using intuitive drawing tools.

Advanced AI with Multiple Experts

  • Conservative: Safe and cautious driving style
  • Aggressive: Fast and bold driving behavior
  • Explorer: Focused on exploring new areas
  • Follower: Follows successful trajectories

Additional Features

  • Turbo Mode: Speed up learning by 100x
  • Real-Time Statistics: Monitor learning progress live
  • Problem Detection: Identifies and corrects problematic zones automatically

Technologies Used

  • Python 3.8+
  • Pygame 2.6.1 – Graphics rendering and interface
  • NumPy 2.3.4 – Mathematical computations and arrays
  • Collections – Advanced data structures
  • Hashlib – Hash generation for unique state tracking

Requirements

Installing Dependencies

pip install pygame==2.6.1 numpy==2.3.4

How to use

1. Run the project

python main.py

2. Draw the Track

  • Track: Draw the path in black
  • Start Point: Mark in blue
  • Finish Point: Mark in red
  • Eraser: Fix mistakes in the drawing

3. Operation Modes

Manual Mode

  • Press ENTER after drawing the track
  • Use ARROW KEYS to drive manually
  • Press ESC to return to the editor

AI Training Mode

  • Click "Train" to start automatic learning
  • The AI learns through trial and error
  • Real-time statistics are displayed during training

Turbo Mode

  • Click "TURBO 100x" to drastically accelerate training
  • Ideal for quickly training on complex tracks

How the AI works

System Architecture

Multiple Specialized Experts

experts = {
    'conservative': defaultdict(lambda: np.zeros(5)),
    'aggressive': defaultdict(lambda: np.zeros(5)), 
    'explorer': defaultdict(lambda: np.zeros(5)),
    'follower': defaultdict(lambda: np.zeros(5))
}

Learning System

  • Q-Learning: Traditional reinforcement learning
  • Ensemble Learning: Combination of multiple strategies
  • Problem Focus: Detects and corrects difficult zones
  • Adaptive Learning: Automatically selects the best experts

Car Sensors

  • 7 sensors positioned at angles from -90° to +90°
  • Edge detection with 4 distance levels
  • Contextual state includes position, speed, and direction

About

A virtual car AI using Q-Learning and Ensemble Learning to learn and navigate custom tracks through multiple specialized experts, with real-time training stats and problem detection.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages