Building a World Cup Predictor from One Prompt: Elo Ratings and Monte Carlo in Practice

    A one-sentence request produced a runnable 2026 World Cup title-probability tool based on Elo ratings and Monte Carlo simulation. This article walks through the modeling choices, score sampling, simulation loop, how to read the results, and how the tool was packaged into a shareable product.

    Building a World Cup Predictor from One Prompt: Elo Ratings and Monte Carlo in Practice

    From a single requirement to a runnable product

    The starting point was simple. I gave an AI coding assistant one sentence:

    “Build a 2026 World Cup title-probability predictor using Elo ratings and Monte Carlo simulation.”

    Then I made a cup of tea. When I came back, the working directory already contained a tool that could simulate a full 48-team tournament, predict score distributions, and generate shareable links. The API cost came to about 13 dollars—slightly more than a takeout meal, and far less than a weekend of hand-written code.

    What is worth reviewing is not only the feeling that “AI writes code quickly,” but the technical approach behind it, which can be abstracted and reused. This article unpacks that predictor: how the data model is built, how the simulation runs, how the project is organized, how cost is accounted for, and how the results should be read.

    1. Why Elo plus Monte Carlo

    Predicting a football title is a multi-stage problem with strong randomness. With 48 teams, a group stage plus a knockout stage, and matches decided in a single game, any deterministic model will be badly distorted. Two approaches are common:

    1. Implied probabilities from historical odds: direct and accurate, but dependent on external data and hard to customize (for example, “a key player is injured”).
    2. Ratings plus random simulation: use a strength rating such as Elo to drive match-by-match simulation, then estimate title frequency from enough runs. This is flexible, interpretable, and extensible.

    We chose the second path for three reasons:

    • Elo is a public, continuously updated strength measure that reflects recent international results.
    • A single match can be turned into an expected win rate from the Elo gap, using a simple and widely tested formula.
    • Monte Carlo fits the combinatorial explosion of a knockout tree; ten thousand runs are enough to produce a stable title distribution.

    1.1 Converting an Elo gap into a win probability

    If the Elo gap between two teams is ΔE, one side’s expected score (an approximation of the probability of not losing in regular time) is:

    1. P(A does not lose) = 1 / (1 + 10^(-ΔE / 400))

    In the implementation, the three-way outcome of win / draw / loss is simplified to a binary advance / fail to advance. That cuts modeling complexity sharply. It is entirely reasonable in the knockout stage. If the group stage needs exact standings, draw probability can be split out later.

    1.2 Generating scores with a Poisson distribution

    To output a predicted score distribution, each match needs a sampled score. The classic method maps the Elo gap to expected goals λ, then samples each team’s goals from a Poisson distribution:

    1. import numpy as np
    2. def expected_goals(elo_a, elo_b, base=1.35):
    3. diff = (elo_a - elo_b) / 400.0
    4. lambda_a = base * (10 ** diff)
    5. lambda_b = base * (10 ** (-diff))
    6. return lambda_a, lambda_b
    7. def sample_score(lambda_a, lambda_b, rng):
    8. return rng.poisson(lambda_a), rng.poisson(lambda_b)

    Adjusting base by stage (group matches and knockout matches have different attacking intensity) produces score distributions that match intuition and have a data basis. The frequency of a specific score across 100,000 matches is that score’s predicted probability.

    2. Engineering the Monte Carlo loop

    The core of the predictor is a two-stage loop: the group stage simulates points and qualification, and the knockout stage simulates a single-elimination bracket.

    2.1 Data structures

    • teams: a dictionary keyed by team name, with values {elo, group};
    • schedule: the 48-team structure (groups plus knockout pairing rules);
    • accumulator: counters for titles, final appearances, exits at each stage, and score distributions.

    2.2 One simulation pass

    1. for simulation in range(N):
    2. results = simulate_group_stage(teams, rng)
    3. bracket = build_bracket(results)
    4. champion = simulate_knockout(bracket, rng)
    5. accumulator[champion] += 1

    Important details:

    1. Random-seed management: numpy.random.default_rng(seed) creates an independent random stream so results are reproducible and parallel simulation is straightforward.
    2. Draws: in the group stage, Poisson-sampled scores feed the points table directly. In the knockout stage, a draw can be resolved by extra time or penalties using the Elo-derived win rate, simplified to a Bernoulli draw.
    3. Performance: pure Python needs a few seconds for 10,000 runs. NumPy vectorized sampling can bring that under a second. If the workload later grows to one million runs, multiprocessing can shard the work by seed.

    2.3 Aggregating results

    After the runs, each team’s title frequency is its title probability. The same output can also include:

    • Conditional probabilities of reaching the quarterfinals, semifinals, and final;
    • The most likely final pairings;
    • Average goals and common score distributions.

    3. Reading the results: three counterintuitive findings behind the top five taking about 70%

    Using June Elo data from a public football-rating site and 10,000 simulations, the top five title probabilities were:

    Team Elo Title probability
    Spain 2157 about 31.9%
    Argentina 2115 about 17.8%
    France 2063 about 9.2%
    Brazil 1991 about 6.6%
    England 2021 about 6.0%

    The top five account for about 70%, and the other 43 teams share about 30%. That overall distribution is broadly consistent with the implied probabilities of mainstream bookmaker odds, which suggests the framework is reliable. Three details in the simulation still run against popular intuition, and they show the value of combining Elo with bracket structure:

    1. Colombia is systematically underrated. An Elo of 1982 puts them seventh in the world, above the Netherlands and Germany, yet many forecasts leave them out. They were drawn into a relatively open group, so qualification is not especially hard. Once in the knockout stage, the expected win rates supported by Elo are enough to go a long way. They also reached the final of the last Copa América, and the core squad is still there.

    2. Seeded teams have very different draw luck. Some seeds face opponents barely above Elo 1400; others meet sides above 1900. Differences in group-stage strength, passed through the bracket, can significantly amplify or compress title probability. That is why intuition based only on a strength ranking often fails: bracket structure is a second-order effect, but in this kind of tournament it matters a great deal.

    3. Japan’s Elo is higher than most people expect. A rating of 1906 ranks them 14th in the world and first in Asia, more than 130 points above the next Asian side. The gap to the Netherlands is only 42 points. Forty-two points is also the gap between Spain and Argentina. In the Elo system, Japan’s threat to stronger teams is real and measurable, not a sentimental bonus.

    3.1 A method drawn from these findings

    • Do not look only at average strength; look at conditional paths. A knockout is a chain of conditional probabilities. The distribution of group-stage opponents changes the pairing probability of every later round.
    • Calibrate intuition with the absolute Elo gap. Forty-two points is about one tier, but it is far from insurmountable (roughly 56% versus 44%).
    • Check the model against odds. Agreement between the model’s totals and market odds suggests the framework is sound. The places where the model disagrees with intuition are the incremental information worth examining.

    4. Project structure and productization

    A tool generated from one sentence still needs supporting modules before it is a usable product.

    4.1 Layered layout

    1. predictor/
    2. ├── data/ # team Elo, groups, and schedule
    3. ├── engine/ # Elo model, Poisson sampling, Monte Carlo loop
    4. ├── api/ # parameter checks, job orchestration, result cache
    5. ├── web/ # frontend visualization and share links
    6. └── tests/ # unit tests and regression tests

    4.2 Frontend visualization

    The results are best shown in three layers:

    1. A title-probability bar chart (sorted by probability, highlighting the top five and “others”);
    2. Round-by-round advancement for each team (a funnel from group qualification to the round of 16, quarterfinals, semifinals, final, and title);
    3. A final-pairing heatmap (a matrix of the probability that any two teams meet in the final).

    Sharing is deliberately simple: encode the simulation parameters (data version, number of runs, and random seed) in the URL query string. Opening the link asks the backend to run the same simulation again, which reproduces the same result. That avoids storing user data and makes the shared link naturally verifiable.

    4.3 Cost and iteration

    All of the generated code—the Elo data structures, Poisson score generation, Monte Carlo loop, and frontend—cost about 13 dollars in one pass. For an individual developer, this is evidence that a requirement can become a product: once generative tools understand enough context and can organize code, the bottleneck moves from writing code to defining the problem and the acceptance criteria clearly.

    A few practical ways to control cost:

    • Write the requirement as one clear sentence plus explicit acceptance criteria (outputs, format, and interaction);
    • Generate in stages: data model and simulation engine first, then the frontend after tests pass;
    • Review generated code by hand, especially random seeds, probability normalization, and boundary conditions, which are easy to get wrong.

    5. Reusable extensions

    The architecture is not limited to football. Any setting with a strength rating, multi-round elimination, and strong randomness can use it:

    • Esports: the same idea applies to Elo or Glicko rating systems;
    • Project risk: replace Elo with a success-rate score and simulate the probability of clearing multi-stage milestones;
    • Sales funnels: treat stage conversion rates as “strength” and use Monte Carlo to estimate the deal distribution;
    • Disaster-recovery drills and capacity planning: combine a fault tree with Monte Carlo to estimate the distribution of service availability.

    Closing

    Between one sentence and a tool that can run a full 48-team schedule, output score distributions, and support shareable reproduction, the gap is no longer a weekend of typing hundreds of lines. It is a clear technical design: Elo quantifies strength, the Poisson distribution generates scores, Monte Carlo propagates probability, and engineering packaging provides the product experience. The 13-dollar bill did not buy the code itself. It bought the efficiency of compressing a vague idea into something that runs. For a developer, the investment that lasts is understanding the modeling tradeoffs at each step—because next time you only need to change the data source to predict any other “tournament.”