Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    170

    Algorithm for match play

    Ok I am trying to come up with a type of algorithm for a type of match play.

    We have 14 teams total.
    4 rounds in total.
    The teams need to play all the opposing teams atleast once before repeating.

    The rounds are setup like so:
    R1= 1vs2 ; 3vs4; 5vs6; 7vs8; 9vs10; 11vs12; 13vs14;
    R2=13vs2; 1vs4; 3vs6; 5vs8; 7vs10; 9vs12; 11vs14;
    R3= etc etc
    R4=etc etc

    4 Rounds Make up 1 Game

    After all the teams play each other atleast once they are allowed to start repeating again.

    Any help would be greatly appreciated.

    P.S. THIS IS NOT HOMEWORK FOR ME. If someone could give me a push in the right direction I would appreciate it. My teacher asked if I could come up with something and I told him that I would try.

  2. #2
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    1,082
    You'll want to put all the teams into an array of some sort. At the start, have the opponent be at an offset of one from the starting point. Iterate through the array until all teams are assigned a game. On the second round, the opponent is at an offset of two. Repeat with an offset of three, etc. until n-1 rounds have been set up.

  3. #3
    Join Date
    May 2004
    Location
    Singapore
    Posts
    262
    I've implemented in PHP an algorithm for round robin pairings, which sounds much like what you're trying to do.

    Round Robin Generator
    #include<cstdio>
    char*s="#include<cstdio>%cchar*s=%c%s%c;%cint main(){std::printf(s,10,34,s,34,10);}";
    int main(){std::printf(s,10,34,s,34,10);}

  4. #4
    Join Date
    Oct 2003
    Posts
    170
    Originally posted by laserlight
    I've implemented in PHP an algorithm for round robin pairings, which sounds much like what you're trying to do.

    Round Robin Generator
    Thanks man.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •