开发者

Grouping Algorithm - Tournament

开发者 https://www.devze.com 2023-02-25 11:49 出处:网络
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

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 tha开发者_StackOverflow社区t 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号