cscorley / killer-queen

A Django app for Killer Queen league registration, team mixing, and (manual) stat tracking
2 stars 0 forks source link

team allocation could be 'better' #11

Closed cscorley closed 6 years ago

cscorley commented 6 years ago

Currently, the suggestion algo uses a three step process based on player rank. Assuming a set of 4 teams with 5 players each, ranked 1..20:

  1. Group the players into sets of 4 (the desired number of teams)
    (1, 2, 3, 4)
    (5, 6, 7, 8)
    (9, 10, 11, 12)
    (13, 14, 15, 16)
    (17 18, 19, 20)
  2. Reverse the odd rows
    (1, 2, 3, 4)
    (8, 7, 6, 5)  <
    (9, 10, 11, 12)
    (16, 15, 14, 13)  <
    (17 18, 19, 20)
  3. Transpose the matrix (rotate) to form the teams of 5
    (1, 8, 9, 16, 17)
    (2, 7, 10, 15, 18)
    (3, 6, 11, 14, 19)
    (4, 5, 12, 13, 20)

This is fine, as it produces teams with averages within 1 point of another.

(1, 8, 9, 16, 17), mean = 10.2
(2, 7, 10, 15, 18), mean = 10.4
(3, 6, 11, 14, 19), mean = 10.6
(4, 5, 12, 13, 20), mean = 10.8

However, we'd really prefer if we could pair the worst players with the best players. An algorithm for this could work on a set of 20 players as such:

Pool: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 18, 19, 20)

  1. Allocate the top 4 players to the first position of each team:
    (1)
    (2)
    (3)
    (4)
    Pool: (5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
  2. Then allocate the 4 worst players in reverse:
    (1, 20)
    (2, 19)
    (3, 18)
    (4, 17)
    Pool: (5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
  3. Repeat step 1:
    (1, 20, 5)
    (2, 19, 6)
    (3, 18, 7)
    (4, 17, 8)
    Pool: (9, 10, 11, 12, 13, 14, 15, 16)
  4. Repeat step 2:
    (1, 20, 5, 16)
    (2, 19, 6, 15)
    (3, 18, 7, 14)
    (4, 17, 8, 13)
    Pool: (9, 10, 11, 12)
  5. Repeat step 1:
    (1, 20, 5, 16, 9)
    (2, 19, 6, 15, 10)
    (3, 18, 7, 14, 11)
    (4, 17, 8, 13, 12)
    Pool: (empty)

This should produce teams that are equivalent in terms of means, but instead explicitly pairs the worst with the best:

(1, 20, 5, 16, 9), mean = 10.2
(2, 19, 6, 15, 10), mean = 10.4
(3, 18, 7, 14, 11), mean = 10.6
(4, 17, 8, 13, 12), mean = 10.8
cscorley commented 6 years ago

Another alternative to the current approach is to always flip the last group.