I knocked up an algorithm that does the job without brute force. It looks solely at rating. I think it is good enough to put straight into the lobby.
How it works:
- Code: Select all
Foreach player ordered by rating descending
Put them in the team with the lowest total rating (that is not full)
You can see what it does for these 12 players when put into 2, 3, 4, 6 teams...
- Code: Select all
Players: 1200, 1100, 900, 900, 800, 800, 700, 700, 500, 500, 500, 300
Team 1 Team 2
Total 4400 4500
-----------------------------------------------------------------------------
Slot 1 1200 1100
Slot 2 900 900
Slot 3 800 800
Slot 4 700 700
Slot 5 500 500
Slot 6 300 500
Team 1 Team 2 Team 3
Total 3000 2900 3000
-----------------------------------------------------------------------------
Slot 1 1200 1100 900
Slot 2 800 800 900
Slot 3 500 700 700
Slot 4 500 300 500
Team 1 Team 2 Team 3 Team 4
Total 2200 2300 2200 2200
-----------------------------------------------------------------------------
Slot 1 1200 1100 900 900
Slot 2 700 700 800 800
Slot 3 300 500 500 500
Team 1 Team 2 Team 3 Team 4 Team 5 Team 6
Total 1500 1600 1400 1400 1500 1500
-----------------------------------------------------------------------------
Slot 1 1200 1100 900 900 800 800
Slot 2 300 500 500 500 700 700
Here's how it handles 4 imbalanced players
- Code: Select all
Players: 2000, 900, 900, 50
Team 1 Team 2
Total 2050 1800
-----------------------------------------------------------------------------
Slot 1 2000 900
Slot 2 50 900
This is 4 balanceable players
- Code: Select all
Players: 2000, 1800, 1200, 1150
Team 1 Team 2
Total 3150 3000
-----------------------------------------------------------------------------
Slot 1 2000 1800
Slot 2 1150 1200
Lets do an experiment. I am about to change the rating of the 1700 player in this example.
- Code: Select all
Players: 2000, 1800, 1800, 1700, 1200, 10
Team 1 Team 2
Total 3710 4800
-----------------------------------------------------------------------------
Slot 1 2000 1800
Slot 2 1700 1800
Slot 3 10 1200
When he is 1600 it forces the 1200 and 10 to swap teams
- Code: Select all
Players: 2000, 1800, 1800, 1600, 1200, 10
Team 1 Team 2
Total 4800 3610
-----------------------------------------------------------------------------
Slot 1 2000 1800
Slot 2 1600 1800
Slot 3 1200 10
When he is 100 there is no further rffect
- Code: Select all
Players: 2000, 1800, 1800, 1200, 100, 10
Team 1 Team 2
Total 3300 3610
-----------------------------------------------------------------------------
Slot 1 2000 1800
Slot 2 1200 1800
Slot 3 100 10
So the player is considered "balanced with 2000 and 1200 against 1800 1800 10" until the player is 1700. Once he hits that threshold the teams are all rejigged so the player is no longer with the 1200. At that point it is more balanced for him to be with 2000 and 10
Here is my C# script which should be renamed to "auto faf teams.linq" then opened in linqpad