nandakishore.v wrote:
>its 2 player game. In this game i have N players, and in each session
>each player is playing with one of N-1 players. so there are N-1
>sessions.
There is an algorithm.
First, assume there are an even number of players (if N is odd, add an
extra "dummy" player, and whenever someone is supposed to play this
extra player, that player gets a "bye" instead and plays no one.)
Let the number of players be 2K.
Divide the players into two groups, 1 through K and (K+1) through 2K.
If K is even, then rounds 1 through K-1 consist of the players in each
group playing each other. If K is odd, then rounds 1 through K
consist of the players in each group playing each other plus one game
in each round where a player from one group plays the corresponding
player in the other group (that is, 1 plays K+1 in one round, 2 plays
K+2 in another round, and so on through K playing 2K).
The remaining rounds consist of players from different groups playing
each other as follows:
In one round, put 1 against K+1, 2 against K+2, and so on, unless they
have already played each other in the first K rounds (because K was
odd), in which case start with 1 against K+2, 2 against K+3, and so on
through K-1 against 2K, and K against K+1.
In each subsequent round, "rotate" players K+1 through 2K so the
player who was against 2 in the previous round is now against 1,
whoever was against 3 is now against 2, and so on; the player who was
against 1 is now against K. Keep doing this until everybody has
played everybody else.
"Yes, but how do I get the players in each round to play each other in
the first place?" Follow the above process for players 1 to K, and
"copy" the pairings into the other group; for example, if 1 plays 3,
then K+1 plays K+3 in the same round. When a player has to play the
"dummy" player, then the corresponding player in the other group also
plays the "dummy" player, so these two play each other. Keep working
backwards until you get to a level you can solve manually.
Here is an example for 10 players:
First, solve for a group of five players, then match the two groups of
five against each other.
For five players (1-5), add player 6 as the dummy player.
Now solve for a group of six by solving for a group of three and then
matching two groups of three (1-3, 4-6) together.
Group of 3:
Round 1: 1 vs 2; 3 bye
Round 2: 1 vs 3; 2 bye
Round 3: 2 vs 3; 1 bye
Copy 1-3 to 4-6, and pair the players with byes together:
Round 1: 1 vs 2, 4 vs 5, 3 vs 6
Round 2: 1 vs 3, 4 vs 6, 2 vs 5
Round 3: 2 vs 3, 5 vs 6, 1 vs 4
For Round 4, put players in different groups against each other; you
already have 1 vs 4, so start with 1 vs 5:
Round 4: 1 vs 5, 2 vs 6, 3 vs 4
Round 5: 1 vs 6, 2 vs 4, 3 vs 5
The scheduling of 6 players is complete. Since this is actually a
5-player schedule, replace Player 6 with "bye".
Now, copy these rounds from players 1-5 to players 6-10, and again
pair two players with byes together:
Round 1: 1 vs 2, 6 vs 7, 4 vs 5, 9 vs 10, 3 vs 8
Round 2: 1 vs 3, 6 vs 8, 2 vs 5, 7 vs 10, 4 vs 9
Round 3: 2 vs 3, 7 vs 8, 1 vs 4, 6 vs 9, 5 vs 10
Round 4: 1 vs 5, 6 vs 10, 3 vs 4, 8 vs 9, 2 vs 7
Round 5: 2 vs 4, 7 vs 9, 3 vs 5, 8 vs 10, 1 vs 6
Since 1 vs 6 is already scheduled, start with 1 vs 7:
Round 6: 1 vs 7, 2 vs 8, 3 vs 9, 4 vs 10, 5 vs 6
Round 7: 1 vs 8, 2 vs 9, 3 vs 10, 4 vs 6, 5 vs 7
Round 8: 1 vs 9, 2 vs 10, 3 vs 6, 4 vs 7, 5 vs 8
Round 9: 1 vs 10, 2 vs 6, 3 vs 7, 4 vs 8, 5 vs 9
-- Don
>> Stay informed about: N player Game Algorithm