DEV Community

Waqas R
Waqas R

Posted on

How we built a 10,000-run Monte Carlo simulator for the 2026 World Cup

The 2026 World Cup is the first with 48 teams and 104 matches, which makes it a genuinely interesting simulation problem: a new Round of 32, best-third qualification rules, and group tiebreakers that branch in ugly ways. We built a simulator that runs the whole tournament 10,000 times and publishes champion probabilities for every nation. Here's the engineering side.

Why Monte Carlo instead of closed-form

With 12 groups of 4 plus best-third qualification, the bracket space explodes. Closed-form approaches lose the path-dependence (who you meet in the R32 depends on which groups produce best-thirds). Sampling the tournament end-to-end 10,000 times converges nicely for champion probabilities and is simple to reason about.

The architecture (boring on purpose)

  • Per-match win/draw/loss probabilities come from our rating model (the same engine behind our FPL projections; inputs are public signals like rankings and squad data).
  • The simulator is a pure TypeScript function, deterministic given a seed (mulberry32 PRNG), so any board we publish is reproducible.
  • It runs in a Next.js ISR route revalidating hourly. No workers, no queues: 10,000 tournament runs are just arithmetic over a fixtures array and finish in well under a second.
  • Played matches lock in real results; the sim only samples what hasn't happened yet, so the board tilts as the tournament progresses.

The part that matters: a public accuracy record

Prediction content is cheap; accountability isn't. Every match prediction is auto-graded after full time on a public model-record page: probability given, result, running Brier score. If the model has a bad tournament, that page will say so. Every prediction site should do this.

Open data

Model outputs (per-match probabilities, champion odds, fixtures) are published as CSVs under CC BY 4.0:

Happy to answer questions about the simulation layer, the Next.js setup, or how we grade accuracy. (The rating model's internals stay private; everything about the simulation layer is fair game.)

Top comments (0)