Matchmaking role parity algorithm

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

local Partys = {
	{Players = {
		1,2
	},Role = {
		D = 2
	}},
	{Players = {
		3,4,5
	},Role = {
		D = 1,T=1,H=1
	}},
	{Players = {
		6,7
	},Role = {
		D=2
	}},
	{Players = {
		8
	},Role = {
		D=1
	}},{Players = {
		9,10
	},Role = {
		H=1,T=1
	}},
}

D = DPS,H= healer,T= tank in a party
so i don’t ask for the code just some example and how you will make that

Assuming that your question is how to assign a specific number of individual roles to players in a team, I would do the following:

  1. Store the list of players that are not assigned to a role in a variable
  2. Make a function that can assign a role to a player and then remove it from that list
  3. Go by every role and utilize the function according to your requirements. Do this until all players are assigned to a role.

You can probably reuse this algorithm for the PVP game mode.

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

Disclaimer: This code was partially or fully AI-generated from: https://chat.openai.com/chat

This would work I think but it doesn’t handle parity.I thought about something I will try it today

OK cool, if there are any other issues let us know.

Ok, wel you can use my algorithm nonetheless, but you would have to get a list of players for every party in a team.