I am new to coding so please forgive if I overlook anything simple. I am writing a program to make four teams of four. Each player has a certain point value for 11 different categories (eg. speed, agility, strength, etc.). I know I could average these categories together and just balance off that, but that leaves some teams wildly unbalanced in certain categories.
I have a separate program that takes in one set of point values, iterates through all possible combinations of teams, and returns the set for which the teams have the lowest standard deviation. I have also written some code myself that calculates the difference between each the average score for each category and that player's score for that category to get each player's point differential for each category.
However, I do not know how to use this data to get what I want: teams balanced off each category. I assume the best way to do this would be, for each team, minimizing the sum of the absolute values of each team's collective point differential. I have included a simplification of my code below:
d1_game1 = player1_points - average_points # this is repeated for each player and each game
game1Differentials = [d1_game1, d2_game1, d3_game1, ..., d16_game1] # There are 11 of these, one for each category
team1Differential = sum(abs([game1Differentials, game2Differentials, ..., game11Differentials]))
This team1Differential value is what is tripping me up; how do I take player differentials and convert them to team differentials? Would I have to try every combination of players?
values_to_minimize = [team1Differential, team2Differential, team3Differential, team4Differential]
I assume that this approach combined with the function from the code I linked above is almost all the way there, but how could this be applied to multiple metrics? I feel that it is a simple option that I am overlooking. This problem has been stopping me for days and I would really appreciate any help. Also if I am looking at this the wrong way and there is an easier method to get what I want, please let me know.