# Match Making Groups of Players

Given a situation where I have a pool of X people of different scores (ranks) S with game size N. How do I partition the pool into N sized games where the standard deviation of ranks for each games is minimized?

(quality of the game is inversely proportional to STD of ranks)

• Possible duplicate of gamedev.stackexchange.com/questions/464/… though a smaller subset. Dec 22, 2010 at 15:47
• @The Communist Duck I don't really want a framework. I'm looking to code it myself, so I need an algorithm (or heuristics). Dec 22, 2010 at 16:05
• It's not clear what you want to happen when N|X fails. Does N vary over some range? Can I make games with anywhere between 2 and N players? Are you looking to minimize the mean, total, or some other function of the standard deviations?
– user744
Dec 23, 2010 at 11:10
• @Joe Wreschnig You can assume N % X == 0. Any N is an acceptable number, but N = 1 is the trivial case. Dec 23, 2010 at 15:33

If your values for X and N are very large, it would probably make the most sence to keep the player list sorted by Rank such that you could always take the bottom N elements to create a group. This will front-load your computation time (keeping the list sorted every time you add a new item), in contrast with the above algorithm which would require execution every time a new group is to be created.
• I've looked over this algorithm a bit and I can't understand the logic or it's result at all. Could you explain it a bit more? Why would I want a groupMembers filled with the index of players with the smallest rank? I've reworded the question, maybe that'll help make what I'm asking for more clear. Dec 23, 2010 at 0:57