I’m making an automatic football league generator and got stuck on schedule. I have an algorithm for generating everything, but not schedule. Take a look:
[tour-id] => Array ( [playing-day] => 2013-03-07 [tour (tour-id+1)] => 9 [game-id] => Array ( [blue team-id] => 13 [red team-id] => 10 )
For example:
[8] => Array ( [playday] => 2013-03-07 [tour] => 9 [0] => Array ( [blue] => 13 [red] => 10 ) [1] => Array ( [red] => 15 [blue] => 12 ) [2] => Array ( [blue] => 6 [red] => 11 )
And now when i have got all that data I can just use few foreach()
for taking what i need. But – the thing i want is to put teams into RED & BLUE teams normally.
I mean:
- One team in one side (BLUE or RED) can play maximum 2 times;
- One team in one round must play
$totalTours/2
games in one round.
For example if there are 9 teams, in 1st round a team must play 4 tours in RED (total, not in a row) and 5 tours in BLUE. In 2nd round it must play 5 tours in RED, 4 tours in BLUE.
The algorithm must work even if there are 100 teams.
Advertisement
Answer
I think you should check the round-robin tournament-Algorithm.
In This way you can schedule your Tournament easily and the place will become optional.
When Time is reached, you can set the location home
or away