Distributing players to tables

Posted by IVlad on Stack Overflow See other posts from Stack Overflow or by IVlad
Published on 2012-10-25T22:38:07Z Indexed on 2012/10/26 11:01 UTC
Read the original article Hit count: 178

Filed under:
|
|

Consider N = 4k players, k tables and a number of clans such that each member can belong to one clan. A clan can contain at most k players.

We want to organize 3 rounds of a game such that, for each table that seats exactly 4 players, no 2 players sitting there are part of the same clan, and, for the later rounds, no 2 players sitting there have sat at the same table before. All players play all rounds.

How can we do this efficiently if N can be about ~80 large?

I thought of this:

for each table T:
  repeat until 4 players have been seated at T:
    pick a random player X that is not currently seated anywhere
    if X has not sat at the same table as anyone currently at T AND
       X is not from the same clan as anyone currently at T
       seat X at T
       break

I am not sure if this will always finish or if it can get stuck even if there is a valid assignment. Even if this works, is there a better way to do it?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about math