Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouping Algorithm - Tournament

Looking for an algorithm, or code if someone's feeling generous to do the following. I need to take an input for a number of players. The number of players will always be a factor of 4. I want to group the individual players into groups of 4, with the least number of repetition. The initial placement is trivial:

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

So players 1-4 have "seen" each other once. Everyone plays their game and then the players are shuffled. On the next pass (and subsequent passes) I want to rearrange the players so that they have the least amount of overlap. Basically, I want to prevent a player from seeing a repeated face for as long as possible, and once that is no longer possible, I want to minimize it as much as possible.

I feel like this should be a relatively simple algorithm, but every approach I end up taking feels like it's weighting itself in favor of the people that get processed first...and my gut/mind tell me that there's an absolute correct answer.

For clarity, no one is eliminated, they're just shuffled each time.

like image 743
JamesB41 Avatar asked Oct 25 '22 15:10

JamesB41


1 Answers

This is basically the Social Golfer Problem. There are many algorithms in the combinatorial optimization literature.

like image 99
dsgsdgsdg Avatar answered Oct 27 '22 09:10

dsgsdgsdg