Overview
The Race Engine provides a comprehensive lap-by-lap Formula 1 race simulation with realistic tire degradation, pit stop strategies, safety car periods, weather changes, and driver-specific performance characteristics.Core Function
simulate_race()
Simulates a complete Formula 1 race with all 20 drivers across 50 laps.
Weather condition for the raceOptions:
"DRY"- Normal dry conditions"LIGHT_RAIN"- Light rain (intermediate tires optimal)"HEAVY_RAIN"- Heavy rain (wet tires required)
Circuit type affecting driver performanceOptions:
"STANDARD"- Typical balanced circuit"STREET"- Street circuit (Monaco, Singapore)"FAST"- High-speed circuit (Monza, Silverstone)"TECHNICAL"- Technical circuit (Hungary, Spain)"DESERT"- Desert circuit (Bahrain, Abu Dhabi)
Random seed for reproducible simulations. If not provided, results will vary on each run.
Response Structure
Initial weather condition
Circuit type
Total race laps (50)
Full name of race winner
Array of 3 driver names on the podium [P1, P2, P3]
Number of drivers who did not finish
Array of driver results (20 drivers)
Detailed log for each lap
Array of driver codes leading each lap (50 elements)
Array of lap numbers when safety car was deployed
Array of tuples [(lap, weather), …] showing weather changes
Example Response
CarState Class
Internal class representing each car’s state during the race.Properties
Three-letter driver code
Full driver name
Team name
Driver skill rating (0.80-0.97)
Wet weather skill rating (0.79-0.98)
Tire management ability (0.76-0.96)
Overtaking ability (0.72-0.90)
Defensive ability (0.70-0.90)
Team car performance (0.80-0.96)
Current race position
Cumulative race time in seconds
Current tire compound
Laps on current tires
Data References
DRIVERS Dictionary
All 20 drivers for 2026 season with performance attributes:TEAM_CAR Performance
Team car performance multipliers:STRATEGIES
Available pit stop strategies:Race Constants
Total laps in a race
Time lost in pit lane (seconds)
Base lap time offset for each compound (seconds)
Degradation per lap for each compound (seconds)
Lap number when degradation accelerates
Race Events
Safety Car
- Trigger Probability: 4% per lap
- Duration: 3-6 laps
- Effect: Slows all cars to minimum 115s lap time
- Strategic Impact: Teams often pit during safety car periods
Virtual Safety Car
- Trigger Probability: 2% per lap (only when SC not active)
- Effect: Moderate pace reduction
DNF (Did Not Finish)
- Probability: 0.6% per driver per lap
- Causes: Mechanical failure or crash
- Effect: Driver retires from race
Weather Changes
- Trigger: 3% chance per lap after lap 5
- DRY → LIGHT_RAIN: Forces tire changes to intermediates
- LIGHT_RAIN → HEAVY_RAIN or DRY: Strategic tire decisions
- Wet Penalty: +3s on slicks in light rain, +8s in heavy rain
Usage Examples
Performance Notes
- Average simulation time: ~0.5-1.0 seconds per race
- Deterministic when seed is provided
- All 50 laps simulated with full physics
- Output JSON size: ~50-100KB per race