# Thread: Football schedule algorithm

1. ## Football schedule algorithm

Hey guys,

I've got this old football game for my computer that I'm trying to create a season for. I've got custom leagues and teams, but the game's auto-scheduler is extremely buggy as it has teams playing each other 3 times and some other teams have up to 12 home games and whatnot.

I've figured out by hand what each teams' opponents are, and where they play them (home/away), but when I try to create a schedule I wind up getting stuck near the end of the process. I had the bright idea to program this, but quickly realised that if I knew the algorithm to program, I could've done it by hand.

There has to be a better way than an exhaustive algorithm that backs up every time it gets stuck. I've tried searching online, but found nothing relevant. Does anyone have any ideas?

2. Make something up. Given T teams, and G games in a season, assign N match-ups for each team, with the minimal amount of repeating games. If a game is to reapeat (team A playes team B for the second time), alternate the field (home/away). Also, The team who has played the most home games so far plays the game away. If it's a tie, flip a coin. (rand())

Quzah.

3. I already have a set up for which teams should play what other teams and where (including duplicate divisional opponents) based on how each team did the previous season I played. So assigning opponents is not an issue.

The problem is arranging the games into a 17 week schedule (16 games + 1 bye) such that every game fits without conflict.

Okay, let me map this out in detail. I have one league of 40 teams (2 conferences, 4 divisions each and 5 teams per division). Each team has a list of opponents (8 division, 4 conference, 4 non-conference) and a bye week that I've determined should be based on past performance.

So basically, I have 40 lists of 17 and I want to re-organize them somehow so that they match.

4. Start with this list
Team 1 plays Team 2
Team 1 plays Team 3
Team 1 plays Team 4
Team 1 plays Team 5
Team 2 plays Team 1 (this is the return visit)
Team 2 plays Team 3
Team 2 plays Team 4
Team 2 plays Team 5

Then shuffle it
Does that work?

5. Sort of, but they have to be sorted such that on the same line that Team 1 plays Team 2, Team 2 has to play Team 1.

6. Let me put it this way. Forget football, forget scheduling, for get all that. I have a list of 40 length 17 arrays, or a 40x17 matrix that looks like this:

[O] [i1] [i2] [i3] ... [i39] [i40]

[ j1] [ 2] [ 3] . . .

[j2] [ 6] [23] . . .

[j3] [ 3] [14] . . .

.
.
.

[j17] [ 5] [ 1] . . [37]

I need to sort it in such a way that for any j: (i,j) = x ==> (x,j) = i. (ie. team i, on week j has opponent x => team x on week j has opponent i).

[Edit: The matrix looks off compared to what I just did, but I hope you still understand it. Stupid text formating...]

Popular pages Recent additions