stupid as I am I promised a friend of mine to program something to get her an optimized tournament table for some card game.
I found out that this isn't nearly as easy as I thought, so maybe you have "the idea" that helps me along.
The rules that apply are:
0. Given k participiants and l tables (l = k div 4), each participant has to play WITH each other participant AND he has to play AGAINST each other participant as well, with the absolute number of games played being minimal and fair (i.e., don't have one player playing 10 games while another has to play only 4).
1. Each table has exactly four players per round (but players can be moved to other tables each round).
2. On each table, two players (determined by seating arrangement) play against the other two players - let's define ABCD as "(A with
against (C with D)".
So far, I have written an algorithm that finds each possible permutation for the players, eliminating "senseless" encounters (i.e., A has already played with B, against C, against D, B has already played against C, against D, C has already played with D - but not necessarily all in the same round).
What is left now is that I need to
- evenly distribute these permutations (i.e., right now because I have some for-statements, player 0 plays more games than player 1 etc, with player k-i for some small i playing the (numerically) necessary number of games)
- and distribute the permutations onto those l tables without collisions (player 0 can play at table 0, but not at table 1 in the same round etc.).
If you have any ideas (or if you want to see the source code I've created so far) plz let me know.