Chapter 40 Instructor Notes — Capstone: Your F1 Race Strategy Simulator
Chapter: Capstone: Your F1 Race Strategy Simulator — Built, Validated, and Ready for the Next Grand Prix · Exercises · Quiz · Case Study 1 · Case Study 2 · Key Takeaways · Discussion guide · Project rubrics
Chapter 40 assembles Box Box into one command, runs it on the 2026 Las Vegas GP, and then does what most capstones skip: it tests the tool on six real races and on every dry Grand Prix of 2025 and 2026, using only information available before each race. The result is mixed and the chapter says so. The simulator gets stop counts and timing windows right more often than compounds, matches "always one stop" on stop counts rather than beating it, and underrates pole-sitters. Each miss is traced to an input or a design choice. Students write cli.py, report.py and the smoke tests, and finish with a recipe for pointing the tool at the next race.
Learning objectives
By the end of the session, students should be able to:
- Run
python -m boxbox simulateandvalidate, and read the four outputs: clean-race optimum, robust policy, clock-only comparison and outcome distribution. - State the pre-race rule (every input cut at the race's start time; only the grid and starting tyres come from the race) and explain why validation without it is dishonest.
- Explain the three integration fixes made in the adapter: phantom stints, the current pit lane, and the 2026 pit-loss shift.
- Score a recommendation with the stops, timing and compounds checks, and against a baseline such as "always one stop".
- Use a hindsight run to decide whether a miss came from the inputs or the optimiser.
- Name the four measured weaknesses and say how each changes a report's reading.
- Refresh the data and run the tool on a race outside the snapshot.
Threshold concept
This chapter has no formal threshold concept. Its key idea is that a model is finished when it can be scored in public, and its misses are explained. The season backtest makes the point sharply: the pre-race optimum matches the winner's stop count only one race more often than "always one stop" (21 against 20 of 34), but swapping in the race's own degradation fixes four misses and breaks none. Students who have this stop defending the optimiser and start auditing the inputs.
Suggested 75-minute session plan
| Time | Segment | What happens |
|---|---|---|
| 0–8 min | Hook | Las Vegas 2026, lap 19: the safety car, and 16 of the 20 cars that stopped making their first stop that lap. Ask: "Could a model have told you, the night before, what to do?" |
| 8–18 min | Concept | The pipeline (§40.1) and the pre-race rule (§40.2). Draw the module chain on the board while students name the chapter behind each step. |
| 18–35 min | Live demo | Run the CLI (see below). Narrate the inputs block line by line while the simulation runs, then open the HTML report. |
| 35–55 min | Activity | Six groups, one validation race each (§40.5). Each explains its verdict and names the cause of every failed check. |
| 55–68 min | Concept | The season backtest and the four weaknesses (§40.6–§40.7). Ask which weakness each group's race exposed. |
| 68–75 min | Wrap-up | Introduce the capstone task and rubric. Exit ticket: "Which one number in a Box Box report would you check first, and why?" |
Running Box Box live in class
- Command: from the book's
project\directory, runpython -m boxbox simulate --year 2026 --gp vegas. With the default seed (42) it reproduces the chapter's tables: ANT 0.299 and VER 0.209 to win, flexible policy 13.289 expected points, two-stop +13.973 s in the clock-only runs. - Timing: the project README estimates about 45 s on a laptop. Machines vary: in a check made for this guide, one machine took about 95 s for the default run, of which roughly 36–39 s was building the inputs, and about 64 s with
--sims 2000 --compare-sims 1000. Time it on the classroom machine beforehand. - Use the wait. Progress lines appear as each stage finishes (inputs, clean optimum, simulations). Walk through the §40.3 inputs block while the races run: each line is a chapter.
- Output location: by default the run writes
report.html,result.jsonandfield_probabilities.csvtoproject\output\2026-vegas\, replacing what is there. Add--outwith another folder to keep the shipped files intact. - Fallback: if the run fails or the room is short of time, open the saved report at
images/ch40-report-2026-vegas.htmlin the chapter folder. - Second run, if time allows:
python -m boxbox validate --year 2025 --gp rodriguezgives Box Box's pre-race Anchor B call: best lap 35, window 31–39, actual 34. Chapter 22's lap 36, window 33–40 came from the race's own early stints; the one-lap difference is the history-based SOFT rate (0.061 against the race's 0.054 s/lap). Both windows contain the actual stop.
Key numbers students should leave with
- Pipeline: 41 modules and 14,963 code lines; 14 modules are called by the pipeline, 8 are used inside them, 17 are analysis-only.
- Las Vegas 2026 (pre-race, 10,000 races, seed 42): clean optimum SOFT–HARD on lap 15 (window 10–20); for Verstappen's tyres, lap 22 (window 18–27), actual 19 under the SC. Robust policy: flexible. P(win) ANT 0.299, VER 0.209; GBM VER 0.659. No car ran a HARD.
- Six validation races: stops 4/6, timing 3/6, compounds 3/6; one AGREE (2026 United States), four PARTIAL, one MISS (2026 Barcelona).
- Season backtest (34 dry GPs, 2025–26): pre-race stop count matches 21/34, against 20/34 for "always one stop"; hindsight degradation 25/34. Ten of 13 misses wanted too few stops.
- Inputs beat optimisers: Barcelona 2026 pre-race deg 0.067/0.058/0.050 s/lap against the race's 0.237/0.182/0.124.
- Pole-sitter bias: grid-1 cars won 9 of 14 dry 2026 races (R4–R21); mean simulated P(win) 0.395, or 0.478 at half the pace SD.
- Fuel correction: raw, default and data-driven corrections moved the winner's best stop lap by up to 19 laps.
- Anchor C: the headline result is a two-stop +10.10 s slower and faster in 18.9% of 10,000 Singapore races, with the flexible one-stop gaining 0.84 s (Chapter 27); §40.9 quotes these values. Even at 3× the hazard the two-stop is still +8.8 s.
Common misconceptions and remedies
| Misconception | Remedy |
|---|---|
| "It got Las Vegas right, so it works." | One race is one data point. Show the 21/34 season result alongside "always one stop" (20/34). |
| "A better optimiser would fix the misses." | Hindsight deg fixes 4 and breaks 0; the optimiser was not the problem. |
| "Using all the data makes validation stronger." | Book-wide constants include the race being tested. That is leakage, and the smoke tests check for it. |
| "The simulator's P(win) is a calibrated probability." | Read front-row P(win) as a floor; cross-check against the GBM and the pole base rate (62.6%, 2023–26). |
| "A wet-hazard row is a wet-race simulation." | The engine has no wet tyres; the row changes only the incident hazard. |
| "The next race just works." | Pre-race mode applies no grid penalties. Check the official grid. |
Exercises to assign
- Core (everyone): Part A — A2, A3, A5, A7, A10; Part B — B1 (one-stop formula), B2 (break-even), B4 (Brier score).
- Code lab: Part C — C1 (Las Vegas for Norris) and C2 (Singapore stop windows). Add C3 (the fuel switch) and C7 (GBM vs simulator) for the Analytics track.
- Judgment: Part D — D4 (the strategist's briefing) and D5 (model vs base rate).
- Stretch: Part E — E1 (per-car pace uncertainty) and E3 (the next Grand Prix), which is the natural basis for the capstone forecast.
- Interleaving: M2 (Chapters 14 + 27 + 40) and M4 (Chapters 26 + 38 + 40).
Lab tips
- Run order:
03_validation_suite.pyfirst (about 5 min; cachesoutput/val_*.pkl), then02_las_vegas_2026.py,04_known_weaknesses.py(about 3 min on the first run),05_season_backtest.py(about 40 s),case_study_01.py,01_pipeline_map.pyandproject_checkpoint.py(about 2 min). - Caching:
03 --cachedrescores without resimulating;02 --refreshforces a new Las Vegas run. - Tests:
pytest tests -qfromproject\runs 55 smoke tests in under a minute. - Gotcha — ambiguous
--gp: "United States" also matches Miami and Las Vegas. Use thecircuit_refor the round;python -m boxbox races --year 2026lists them. - Gotcha — Monte Carlo noise: Verstappen's one-stop P(win) is 0.197 at 5,000 races per policy and 0.237 at 1,000. The policy ranking does not change.
The capstone project
Assign the capstone using section 3 of the project rubrics: a pre-registered forecast for a race outside the snapshot (Analytics) or a validated recommendation driven by the student's own lap simulator (Engineering), plus the 10-minute presentation. Stress the automatic zero for a forecast changed after the race, and reward honest, explained misses.
Connections
- Backward: Chapter 12 (the optimiser), Chapter 22 (degradation and its fuel correction), Chapter 27 (the engine and its pole bias), Chapter 38 (why calibration matters before any price).
- Outward: Chapter 39 shows how
series.RuleProfilepoints the same machinery at another championship.