Hi everyone,
I want to be upfront: I am not very experienced with Python and I have never built a website before. I used AI to write the vast majority of the code for this project, but all the underlying mechanics, concepts, and football logic are entirely my own ideas.
I have built a "detailed" World Cup 2026 Simulator. It is currently running in a Jupyter Notebook using ipywidgets. It has gotten quite complex, but after a lot of testing, I think most of the bugs are finally removed. I just wanted to share it here in case anyone finds it interesting!
I have attached some pictures of the UI to this post, including the group phase dashboard, the knockout bracket, the Monte Carlo analytics tables, the tactical blackboard with formations, and the live match logs.
Here is a breakdown of what the engine actually does:
1. Data Sources & Ratings
Player Data: I used the most up-to-date ratings I could find from FIFACM to generate the squads. It is not quite Football Manager, but it accurately reflects players who just had breakout seasons.
Team Strength: The core engine calculates base strength using the latest international Elo ratings combined with Nate Silver's PELE ratings. I also implemented a home court advantage modifier for the host nations.
2. Tactical Lineups & Match Engine
Auto-Lineups: The tactical board auto-generates starting XIs based on player ratings, ensuring realistic formations (always having at least 3 defenders and 1 attacker).
Goal Generation (Poisson): The base team strength is dynamically modified by the actual offensive and defensive ratings of the specific players on the pitch. These combined stats are then fed into a Poisson distribution algorithm to generate the final goals scored.
3. Dynamic Incidents (Cards, Injuries & Form)
Red Cards & Injuries: A red card brings the team's total ratings down, and the penalty is heavily weighted by the minute it occurs. An early red card will devastate a team's chances. Injuries force substitutions and have variable durations, keeping players out of future matches.
Form / Momentum: There is a randomness element for players overperforming or underperforming. This allows a weaker team to sometimes go on an absolute generational run if their squad catches fire.
4. Monte Carlo Analytics & Sandbox Mode
Deep Stats: The Monte Carlo analysis runs thousands of background tournaments to calculate general survival probabilities and expected group placements. It also tracks historical matchup trends to see which teams consistently eliminate specific rivals.
Sandbox Mode: I can manually override specific match scores or force a team into a certain group placement, and the rest of the simulation will dynamically adapt to that new reality.
What I want to add next:
If anyone is interested in checking out the code or the concepts, please let me know! I would also love to eventually turn this into a proper web application, so any general pointers on that front are always welcome too.
Here is the link to google colab:
https://colab.research.google.com/drive/1GdXpbuYboTxk7goLebzQCCXw2GAOwTA8?usp=sharing
Also to run the simulation u must always first update the standings!