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.
This is basically the Social Golfer Problem. There are many algorithms in the combinatorial optimization literature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With