By: Amir Matianiu, Daniel Smith, Jim Chen, Diar Shakimov
A Pygame racing environment with Gymnasium API for training RL agents using LIDAR sensors.
- Gymnasium-compatible API - Standard RL interface for easy integration
- Headless mode support - Fast training without rendering (1000s of steps/second)
- LIDAR-based observation - 5 distance sensors for environment perception
- Checkpoint system - Track progress through colored checkpoints
- Multiple tracks - Support for different track layouts, make yours HERE
- Collision detection - Rotated hitbox-based collision system
pip install pygame gymnasium numpy torch matplotlib pyyamlpython agent.py your_hyperparameters --trainpython agent.py your_hyperparametersCheckout the env_demo
| Action | Description |
|---|---|
| 0 | Steer left |
| 1 | Steer right |
| 2 | Accelerate |
| 3 | Steer left + Accelerate |
| 4 | Steer right + Accelerate |
| 5 | Do nothing |
5 normalized LIDAR distances [0.0-1.0] at angles: -60°, -30°, 0°, +30°, +60°
- 0.0 = far from obstacle
- 1.0 = obstacle adjacent
| Event | Reward | Notes |
|---|---|---|
| Speed | +0.1 × speed | Max +0.8/step |
| Stationary | -0.1 | Speed < 0.5 |
| Collision | -1.0 | Episode ends |
| Checkpoint | +10.0 | 5 per lap |
| Complete Lap | +50.0 | All checkpoints |
- Max Speed: 8.0 | Acceleration: 0.25 | Friction: 5% | Turn: 4°/action
racer.py # Environment
agent.py # DQN trainer
hyperparameters.yml # Config
tracks/track*.png # Track images
runs/ # Training outputs