I am trying to create a round-robin bracket generator for a game where each match contains three teams competing against each other (1v1v1) given the teams, rounds, and rooms in Python. I don't believe this is a programming question, as I need to know how to go about creating the bracket.
Specifically, I have 36 teams (split evenly between 2 divisions), 12 rounds, and 7 rooms (concurrent matches/round).
It should be as fair as possible. My criteria have been that every team plays the same number of rounds (+/- 1) and that no teams compete each other more than once.
The output should be something like:
*This is not fair. Team names here are first letter of division then team letter.
(Red or Green) + (A through R)
Room | Round 1 | Round 2 | Round 3 | Round 4 | ... |
---|---|---|---|---|---|
A | RA v RJ v RN | RF v RI v RP | RD v RE v RF | RJ v RO v RR | ... |
B | RH v RO v RP | RC v RG v RH | RC v RO v RQ | RF v RI v RP | ... |
C | RD v RI v RK | RB v RM v RN | RA v RG v RP | RD v RG v RQ | ... |
D | GA v GG v GL | GB v GK v GM | GF v GL v GP | GF v GH v GJ | ... |
E | GF v GN v GR | GA v GI v GP | GD v GM v GR | GD v GN v GO | ... |
F | GC v GI v GK | GE v GO v GR | GA v GE v GN | GA v GK v GR | ... |
G | GC v GI v GK | GE v GO v GR | GA v GE v GN | GA v GK v GR | ... |
I'm not a mathematician, but I'm willing to learn what I need to. That said, I'm in 11th grade. My highest level math class so far is HS Pre-Calc.
If this is the wrong place, my apologies. Can you point me to the right one?
Edit:
Correct, the divisions do not compete with each other.
I've tried several implementations. They all were some kind of brute force attempt. My hardware is decent. I tried adding threading before leaving it overnight. I added debugging to ensure it wasn't getting stuck and it didn't seem to.
- get all combinations of 3 teams (python has itertools.combinations for this)
- pick a random one
- test to see if it broke the schedule (made teams play each other twice or the same team in different rooms of the same round)
- If not add it to the schedule and repeat 2-4
The problem with brute force:
From 36 teams choose 3
- $_{36}{nCr}_{3} = 7140$
From combinations, choose 84 (7 rooms * 12 rounds) matches
- $_{7140}{nCr}_{7*12} \approx 9.5 E+196$ possibilities
MathJax has a bit of a learning curve, apparently... Sorry if the equations arn't clear.
I said the table above wasn't fair because I duplicated the 6th row to have 7 because I havn't been able to account for the number of rooms being indivisible by the number of divisions.