Skip to content
Advertisement

Football league scheduling algorithm (with sync. home/away)

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:

JavaScript

For example:

JavaScript

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

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement