Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically generate a sports league schedule

I'll start of by saying that I understand that this topic is complicated and that there probably isn't an easy answer. If it were easy then everybody would be doing it. That being said...

I've been asked to build an application to manage a sports league. Most of the concepts are fairly easy to understand except for this one: How to generate a schedule of play where there are no overlaps (team plays 2 teams at once), where a team in a division plays its teams twice but plays teams from the other divisions once, and makes sure that there are no holes in the schedule (each team plays every week)

Right now the process is done manually using a rosetta stone type spreadsheet that I've built to serve this purpose, but it only works for the number of teams it was designed for. I have variations made for 30 teams, 24 teams and 28 teams. Rather than continually attempt to readjust my translation table, I'd like to be able to codify that logic and tweak that process instead.

Thoughts?

like image 851
thaBadDawg Avatar asked Jun 24 '09 08:06

thaBadDawg


People also ask

How do I set up a round robin schedule?

Round Robin scheduling: Even number of teams.Let N = number of teams in the tournament. There will be N -1 rounds (each team will play N-1 games). Since each team will play every other team once, no team will be idle during any of the rounds.

How do you schedule a 9 team league?

To generate your 9 team round robin schedule, simply set your number of games per team and weeks (not counting weeks without any games) and click GENERATE ROUND ROBIN. You'll have the option to enter team names, times, venues, scores, etc. and share it with your players. weeks .


1 Answers

There are two algorithms, one for odd teams, one for even teams to make sure the round robin happens.

I am going to generate you a graphic if i can.

ODD # of teams

The algorithm is to rotate all the teams clockwise. If we had 5 teams:

1 2 --> 3 1 --> 5 3 --> 4 5 --> 2 4
3 4     5 2     4 1     2 3     1 5
5       4       2       1       3   

At this point we have completed one round robin where everyone plays each other once... the next round would again be..

1 2
3 4
5

EVEN # of teams

When we have an even number of teams, you do the same rotation, except you hold team #1 in fixed position and rotate all the other teams around #1 in a clockwise fashion. So, if we had 4 teams..

1 2 --> 1 3 --> 1 4 
3 4     4 2     2 3 

This would be one complete round robin... the next match up would be..

1 2 
3 4 

Programmatically, There's a few ways you could approach this. Maybe the code posted above does the same thing lol..

like image 52
Jas Panesar Avatar answered Oct 23 '22 14:10

Jas Panesar