I'm trying to find an algorithm which would arrange ranked players into 2 teams automatically before the game starts in a balanced way.
The game has 2 teams, each team can have up to 5 players, and each player has a skill rating, the higher the rating the greater the skill of the player in the game. Player rating ranges from 900 to 2100.
Example:
- player1 - rating: 1400
- player2 - rating: 1450
- player3 - rating: 1500
- player4 - rating: 1550
- player5 - rating: 1600
- player6 - rating: 1650
- player7 - rating: 1700
- player8 - rating: 1750
- player9 - rating: 1800
- player10 - rating: 1850
How to arrange these players into 2 teams so that the team average rating between teams is as balanced as possible ie. the difference between 2 teams average rating is the smallest?