Hello,im making a matchmaking algorithm but i have so requirement to create a team on my game.So basically i have 2 different algorithm, one for dungeon,one for pvp.Here i will talk about the dungeon one.
So imagine i have a large amount of player but one team can only be 3 DPS,1 Tank,1 healer and i have to handle party parity.
Example of how is the data Structure
My question is more like how I will bring party to make one team that respect the good number of DPS,TANK and healer it’s more like a role parity like overwatch
this probably isnt the best way to do it, but its the first that comes to mind.
Start by looping through the queue and adding the roles to variables.
First item in the queue is player 1,2 and they are 2 DPS so our currentDPS variables is 2,
Next item is 1 DPS 1 Tank 1 Healer, check if 1+2 is less than or equal 3 and if 1+0 is less than or equal to 1 for the healer and the tank, and then you have a team. If they exceed the max limit just skip them and go to the next item in queue.
Once you have done that, if you couldn’t find a matching group to create a team then loop again but starting at index 2. And so on until you find a matching group, then start over.
i’d recommend having a variable for the required roles needed for each party, this will make comparing parties to each other much easier, comparing what roles are required with what roles are available.
Create a few dictionaries of all the different categories. Then after that assign a player randomly to each team:
-- Define the available player roles
local DPS = {"Player1", "Player2", "Player3", "Player4", "Player5", "Player6"}
local Tank = {"Player7", "Player8", "Player9"}
local Healer = {"Player10", "Player11"}
-- Shuffle the player lists randomly to ensure that each game is different
table.shuffle(DPS)
table.shuffle(Tank)
table.shuffle(Healer)
-- Create the team with the first 3 DPS, the first tank, and the first healer
local team = {
DPS[1], DPS[2], DPS[3], Tank[1], Healer[1]
}
-- Print out the team members for testing
print("Team Members:")
for i, player in ipairs(team) do
print(i .. ". " .. player)
end