Answer the question
In order to leave comments, you need to log in
How to properly implement matchmaking for multiplayer?
I would like to ask how to properly create a player search system for a 5x5 lobby, following the example of CS:GO, faceit, Dota 2. To take into account the rating of players (weak with weak, strong with strong based on previous games). If possible using Laravel as an example.
What I could come up with is that when a player presses "search", they are added to the game's search table (approx. Searching) and the table is checked to see if there are players with a similar rating. And when 10 players are recruited with the appropriate rating, then I send a response to everyone with a web socket and already there I create a lobby in another table. But I'm not sure that this is the right option, from the point of view of optimization.
Answer the question
In order to leave comments, you need to log in
I think you need to google something like: matchmaking algorithm
By the way, I hope you know English well.
I recommend sharing:
- take an array of players in the queue, sort it by rating,
- go through the array in ascending order of rating, trying to collect a lobby of the required size from nearby players, in which the difference between the ratings of the weakest and the strongest does not exceed a given number (bracket),
- if the lobby fits the condition - take the players out of the queue, divide them into teams with a close average rating,
- if the array is over - wait for new players to appear in the queue, after the appearance, go to the first step,
- if the queue hangs too long, increase the bracket, giving the opportunity to play along with a larger ranking difference.
Example:
team_size = 3
max_bracket = 250
pool = {Player1: 100, Player2: 200, Player3: 450, Player4: 460, Player5: 600}
# берем первых трех игроков:
{Player1: 100, Player2: 200, Player3: 450} # разница min/max = 350 > 250, не подходит
# сдвигаемся на одного, берем следующую тройку:
{Player2: 200, Player3: 450, Player4: 460} # разница min/max = 260 > 250, не подходит
# сдвигаемся еще на одного, берем следующую тройку:
{Player3: 450, Player4: 460, Player5: 600} # разница min/max = 150 < 250, команда подобрана
# убираем игроков из пула:
pool = {Player1: 100, Player2: 200}
# ждем появления новых игроков...
The task is more on logic and basic algorithms, nothing fantastic...
when the player presses "search",We check whether there are understaffed teams, and if there is, whether the average team rating +- error satisfies the player's rating. If there are no teams, we create a new one, write a player there, (average) rating, and wait for filling. All.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question