This Python project simulates a completely randomized football (soccer) World Cup tournament. The simulation follows a comprehensive process from team selection to crowning a champion, introducing elements of chance and randomness at each stage.
📦FWC22-simulation
┣ 📂group_stage
┃ ┣ 📂groups
┃ ┣ 📂results
┃ ┗ 📂tables
┣ 📂knockout_stage
┃ ┣ 📂final
┃ ┣ 📂quarter_finals
┃ ┣ 📂round_of_16
┃ ┣ 📂semi_finals
┃ ┗ 📊qualified.csv
┣ 📂src
┃ ┣ 🐍__init__.py
┃ ┣ 🐍q1_create_groups.py
┃ ┣ 🐍q2_generate_groups_results.py
┃ ┣ 🐍q3_create_group_tables.py
┃ ┣ 🐍q4_generate_knockout_teams.py
┃ ┗ 🐍q5_simulate_knockout_stage.py
┣ 📊FWC22_teams.csv
┣ 📜Instructions_FR.pdf
┣ 📜LICENSE
┣ 📜README.md
┗ 🐍q6_main.py
The simulation is implemented across multiple Python scripts, each handling a specific phase of the World Cup:
-
Group Stage Team Assignment
- Randomly distributes teams into 8 groups of 4 teams
- Generates group composition files
-
Match Simulation
- Simulates matches within each group
- Generates random scores for each match
- Implements a simple scoring system
-
Group Table Calculation
- Calculates points for each team based on match results
- Generates group standings
- Determines top two teams from each group
-
Knockout Stage Team Selection
- Selects 16 teams (top two from each group) for the knockout rounds
- Prepares teams for elimination matches
-
Knockout Stage Simulation
- Simulates matches from Round of 16 to Final
- Uses probabilistic methods to determine winners
- Generates results for each round
- Completely randomized match and tournament outcomes
- Modular Python script design
- CSV-based data handling
- Flexible group and knockout stage simulations
- Group Stage: Random score generation (0-3 goals)
- Points System:
- Win: 3 points
- Draw: 1 point
- Loss: 0 points
- Knockout Stages: Winner determined by coin-flip probability
The project includes an open-ended question about making match simulations more realistic. Potential enhancements could include:
- Incorporating team rankings
- Adding more complex scoring probabilities
- Considering team historical performance
- Python 3.x
- Standard library modules:
random
,os
- Ensure you have a
FWC22_teams.csv
file with participating teams - Run scripts with
q6_main.py
or in sequence:q1_generate_groups.py
q2_generate_groups_results.py
q3_create_group_tables.py
q4_generate_knockout_teams.py
q5_simulate_knockout_stage.py
This project is licensed under the MIT License. See the LICENSE file for details.
Romain TROILLARD