Football schedule algorithm

This is a discussion on Football schedule algorithm within the C Programming forums, part of the General Programming Boards category; Hey guys, I've got this old football game for my computer that I'm trying to create a season for. I've ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    24

    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. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    24
    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. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    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?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    24
    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. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    24
    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...]
    Last edited by Zughiaq; 09-03-2005 at 01:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Implement of a Fast Time Series Evaluation Algorithm
    By BiGreat in forum C Programming
    Replies: 7
    Last Post: 12-04-2007, 01:30 AM
  2. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21