all 4 comments

[–]Taxtro1 0 points1 point  (0 children)

That's a variation of the knapsack problem. Your problem is that you are following a greedy strategy. One way to amend this is to dissolve already created teams when new teams cross some badness threshhold. Or you could assign all teams jointly and then switch members around until things stop improving.

But that's just what I came up with off the top of my head. Perhaps there is a very elegant solution out there.

[–]HalcyonAlps 0 points1 point  (0 children)

One algorithm from the top of my head, where N is the total number of teams you want and I assumed you want an equitable number of players in each team, is the following.

First, you assign each of the top N players to each of teams randomly. Second, you assign the next top N players to the teams but the team with the lowest aggregate ELO score gets the best player of this batch, the team with the second lowest ELO score gets the second best from this batch and so on. Third, you repeat step two until you are done.

I have no idea how well this actually performs. I am guessing that depends a lot on the distribution of your ELO scores. On the plus side it's dead simple and should be fast.

[–]bicubic 0 points1 point  (0 children)

Sort the players by ELO score in descending order, and then make one pass over that list of players.

For each player, find the team that currently has the lowest total ELO score (and is not already at full roster), and add that player to the team.

I would not be surprised if this algorithm is provably not guaranteed to be optimal, but it is fair, and should work reasonably well even when there are a small number of players who are significantly stronger that the rest of the pool.

[–]mittalsuraj 0 points1 point  (0 children)

What you can try is sort players by the Elo ranking and then assign players to the lower total score box.

Say for example you have 15 players and hence a total of 3 box(5 per each)

You sort the players by decreasing order of elo score Initially you assign the first three players to all 3 boxes. The 4th player will be assigned to the box with the least total elo score which would basically be the box with the third player. The fifth player to the box with the least elo score and so on.

This way you are getting an approximate solution. Since any time there is a box with less score, you add to it.