Draw a track, watch 8 cars learn to drive it from scratch using reinforcement learning. Takes ~5–10 minutes to start seeing clean laps depending on track complexity.
- Draw a closed loop by clicking waypoints on screen. The track is built from a cubic spline fit to your points, 80px wide.
- Training starts immediately with 8 parallel environments running PPO (via Stable Baselines 3). Each car gets a 21-dimensional observation: 9 raycasts, speed, angular velocity, and 5 lookahead points along the centreline.
- Reward is simply forward progress along the track (+0.005 per pixel), with a -5 penalty for crashing and +10 bonus for completing a lap.
- Hit Space during training to watch the current model, R to resume training, D to redraw.
pip install stable-baselines3 pygame scipy numpy gymnasium
python main.pyDeveloped on WSL2/Ubuntu with WSLg for the display. Should work natively on Linux; Windows/Mac may need minor pygame tweaks.
