Results 1 to 4 of 4
Thread: Algorithm for match play
Hybrid View
-
06-23-2005, 12:56 PM #1WHT Addict
- 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.
-
06-24-2005, 12:45 AM #2Web Hosting Master
- Join Date
- Dec 2004
- Location
- Canada
- Posts
- 1,097
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.
-
06-26-2005, 09:10 AM #3Web Hosting Guru
- Join Date
- May 2004
- Location
- Singapore
- Posts
- 263
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);}
-
06-28-2005, 12:46 PM #4WHT Addict
- 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