Fast, Simple, Fairest Team Making System
In most competitive games, it can be frustrating to have teams that are such different in skill ranges. This new team-making system can generate the fairest teams possible. Compared to most common methods this is ~24x more accurate and fair (when tested with 40 players and their “power” ranging from 1-30). It is significantly slower, but with 40 people, it still manages to operate in under 0.0005 seconds(V4.0, V5.0 is 0.002), which is still blazing fast. The module has a sensitivity option if you are fine with teams being further apart in power. By default, the sensitivity is 0, which means the module will continue to search until a pair has a difference of 0 between the 2 teams, or if it cannot find something with 0 difference, it will pick the next best option. This module does not use leaderstats instead you decide the players’ power using their leaderstats or a custom formula. Ex. A player’s power could be determined by their level * KDR. Odd teams such as 4v3 will be made if the module is requested with an odd number of players.
This Module comes in 2 options, V4.0 and V5.0, For team making, they function the same. The difference? V4.0 is built to handle 2-12 players. V5.0 runs slower because it extends V4.0 and is able to handle 2-40 players. If your game is guaranteed to have 12 or fewer players, use V4.0. If you will ever have over 12 players, you need V5.0.
How do I install / Use it in my game?
Once downloaded, Place either module in ServerStorage, ReplicatedStorage or ServerScriptStorage, your choice. You can then require the module by using
local module = require(ReplicatedStorage[“TeamMakingSystemV4.0”]) --or [“TeamMakingSystemV5.0”])
The module’s function is called BestMatch. You can use the module by doing:
--TeamA and TeamB are a table of all the players on that team.
--Diff is the difference in “power” between the 2 teams
local TeamA, TeamB, Diff = module.BestMatch(PlayerTable)
The PlayerTable needs to be a dictionary of the players and their “Power”. The players can be the players name or their player instance.
local PlayerTable = {
["Player1"] = math.random(1,30),
["Player2"] = math.random(1,30),
["Player3"] = math.random(1,30),
["Player4"] = math.random(1,30),
["Player5"] = math.random(1,30)}
-- The players power would be in the place of math.random()
Only one of the modules is required, you DO NOT need both for either to run.
If you are unsure of how to use this module, there is an included demo request script on how to use it.
How does it work?
V4.0
Once requested, the module calculates how many combinations of teams are possible. Using lexicographical order, The module cycles through all of the possible team combinations seeing if a pair of teams fit within the sensitivity. If it finds a pair that fits within the sensitivity, it will break the loop and automatically return that pair as the fairest team. If a pair does not fit in the sensitivity, the pair will be added to a list of options that will be used if no other pairs fit. If no pairs fit the sensitivity, it will cycle through all of the options and return the one with the lowest difference between the two teams.
V5.0
V5.0 has V4.0 built into it. (Process shown in picture below) Once requested it will check if the game has sent more than 10 players, if not then it will use the built-in V4.0 function, if it did, it will continue to break down the table until it’s a table of 10 players or less. Ex. A table of 40 players would be broken down into 4 tables of 10 players. The module then requests the same function as V4.0 and will optimize the 4 tables of 10 players into 8 groups of 5 players. The module then creates a table of the 8 groups and the power of each group. These 8 groups are run through the V4.0 function again simulating 8 players but each “player” is linked back to a table of the actual players. Once the function completed, The two teams of groups are broken down into 2 teams of players. The module then returns these 2 teams and the power difference between them.
What’s Included?
TraditionalTeamMaking - More common, faster, significantly less accurate, available for testing
TeamMakingSystemV4.0
TeamMakingSystemV5.0
Example Req Script - Shows how to use
DataTestScript - Benchmarking, Runs modules 50x, to find averages (time and accuracy)
Place:Forum Team Making Place.rbxl (23.6 KB)
SourceCode
Thanks for Reading / Trying it out! If there are any issues with it, don’t hesitate to DM me here on the Forum.