An advanced, real-time Formula 1 race strategy simulator that combines a high-performance C++ Monte Carlo Engine with a Python-based live telemetry tracker. This project is designed to predict race outcomes, evaluate tyre degradation, and optimize pit-stop strategies dynamically using live AWS telemetry data.
The system follows a strict decoupling between heavy mathematical computation and live data processing:
- The C++ Core Engine (
/src,/include/f1sim): Handles the mathematical modeling of the race. It features a custom tyre degradation model and a Monte Carlo simulation engine capable of running thousands of race permutations in milliseconds to calculate expected total race times and probabilistic finishing positions. - The Python Telemetry Layer (
/scripts): Acts as the live data ingestion and visualization layer. It hooks into live telemetry (via AWS/FastF1), handles missing data points (e.g., VSC latency dropouts), and outputs the current race state tolive_state.json. - Inter-Process Communication: The C++ engine parses the live JSON state (via
nlohmann/json), computes the Monte Carlo distributions, and exports the results to CSV files (monte_carlo_results.csv), which are then dynamically plotted by Python using Matplotlib.
- Live AWS Telemetry Integration: Real-time tracking of lap times, tyre compounds, and driver positions.
- Dynamic Tyre Degradation Model: Calculates performance drop-off based on tyre age and compound (Soft, Medium, Hard).
- Monte Carlo Strategy Optimization: Runs probabilistic distributions to determine the optimal pit lap and predict final race gaps.
- Robust Anomaly Handling: Features a "memory" state in the Python tracker to handle temporary F1 API telemetry dropouts (e.g., during pit entry or Virtual Safety Car periods) without crashing the C++ engine.
f1_strategy_sim/
├── include/f1sim/ # C++ Headers (Car, RaceSession, MonteCarloEngine, TyreModel, etc.)
├── src/ # C++ Source Files
├── scripts/ # Python Modules (live_tracker.py, mega_dashboard.py)
├── tests/ # Unit tests for the C++ mathematical models
├── CMakeLists.txt # Build configuration
└── live_dashboard.bat # Windows execution script to run the full pipeline
- C++17 Compiler (GCC/MSVC) and CMake.
- Python 3.9+ with
requirements-live.txtinstalled.
mkdir build && cd build
cmake ..
cmake --build . --config ReleaseExecute the batch script to launch both the live tracker and the Monte Carlo visualization dashboard simultaneously:
./live_dashboard.batSergio Software Engineering & Race Strategy Enthusiast