Matchmaking to maintain fixed distribution of players
Options
avinash
✭
Hi,
I have used PUN for almost 4 years now. Have 2 live games using it. We are working on a new game which require a bit more complex matchmaking. I will right away go to the problem we are trying to solve.
Our game requires 10 players. We want to match them using PLAYER LEVEL.
Now we want a fixed distribution (not order) of players in a room. Like below
But this will not maintain the distribution. With this room might get all player with level 1 and so on. I could try to change room property when a player joins to change the criteria but by the time room property is changed, player might already join it.
The solution i think could be something like spots in room with weightage which can be changed on player join call. Something like Check and Swap feature.Please let me know if there is a way to solve this problem.
Sorry for long question but it needed to be explained
I have used PUN for almost 4 years now. Have 2 live games using it. We are working on a new game which require a bit more complex matchmaking. I will right away go to the problem we are trying to solve.
Our game requires 10 players. We want to match them using PLAYER LEVEL.
Now we want a fixed distribution (not order) of players in a room. Like below
- Player 1 - Level 1
- Player 2 - Level 1
- Player 3 - Level 1
- Player 4 - Level 1
- Player 5 - Level 2
- Player 6 - Level 2
- Player 7 - Level 2
- Player 8 - Level 2
- Player 9 - Level 3
- Player 10 - Level 3
C0 >= 1 AND C0 <= 3 // C0 is key for player level
But this will not maintain the distribution. With this room might get all player with level 1 and so on. I could try to change room property when a player joins to change the criteria but by the time room property is changed, player might already join it.
The solution i think could be something like spots in room with weightage which can be changed on player join call. Something like Check and Swap feature.Please let me know if there is a way to solve this problem.
Sorry for long question but it needed to be explained
0
Best Answer
-
Hi @avinash,
So you want to have the following distribution of players in each room:- 4 players of level 1
- 4 players of level 2
- 2 players of level 3
I want you to know that CAS for room properties is implemented in Photon. Check "Check And Swap for Properties (CAS)" section in this page.
You can also try any optimistic approach and then leave a room if a player is "not welcome":
e.g. when player is the 5th level 1
e.g. when player is the 5th level 2
e.g. when player is the 3rd level 3
COMPLEX SOLUTION DRAFT:Main idea is to try to "bulk" matchmake "batch" of players of same level at the same time.
You can break matchmaking into 3 parts;
First part:
Each player tries to find a room in the lobby of his level. Let's call it "LevelX" lobby.
e.g. player with level 1 tries to find a random room in lobby "Level1".
If no match found a room is created with max players equal to the quota needed for your final target game:
- "level1", MaxPlayers 4
- "level2", MaxPlayers 4
- "level3", MaxPlayers 2
Second part:
When a room is full. MasterClient saves room name and other players' UserIDs and leaves it temporarily.
Same actor tries to find a room in target lobby (where you want your actual games to exist):
if no room is found create one with MaxPlayers 10 and IsVisible = false
Third part:
Either ways player joins target room and reserves slots for other same level players
then (set IsVisible = false) leaves it temporarily to go back to first room and gives room ID to other players so they can all join target room.
Once all same level players join the target room, set IsVisible = true.
---
One weak point: (other than complexity and delays) 2 ex.MasterClients of same level can join same target room at the same time in step 2.
5 - 4 players of level 1
Answers
-
Hi @avinash,
So you want to have the following distribution of players in each room:- 4 players of level 1
- 4 players of level 2
- 2 players of level 3
I want you to know that CAS for room properties is implemented in Photon. Check "Check And Swap for Properties (CAS)" section in this page.
You can also try any optimistic approach and then leave a room if a player is "not welcome":
e.g. when player is the 5th level 1
e.g. when player is the 5th level 2
e.g. when player is the 3rd level 3
COMPLEX SOLUTION DRAFT:Main idea is to try to "bulk" matchmake "batch" of players of same level at the same time.
You can break matchmaking into 3 parts;
First part:
Each player tries to find a room in the lobby of his level. Let's call it "LevelX" lobby.
e.g. player with level 1 tries to find a random room in lobby "Level1".
If no match found a room is created with max players equal to the quota needed for your final target game:
- "level1", MaxPlayers 4
- "level2", MaxPlayers 4
- "level3", MaxPlayers 2
Second part:
When a room is full. MasterClient saves room name and other players' UserIDs and leaves it temporarily.
Same actor tries to find a room in target lobby (where you want your actual games to exist):
if no room is found create one with MaxPlayers 10 and IsVisible = false
Third part:
Either ways player joins target room and reserves slots for other same level players
then (set IsVisible = false) leaves it temporarily to go back to first room and gives room ID to other players so they can all join target room.
Once all same level players join the target room, set IsVisible = true.
---
One weak point: (other than complexity and delays) 2 ex.MasterClients of same level can join same target room at the same time in step 2.
5 - 4 players of level 1
-
Thanks JohnTube for such a detailed reply.
Both the approaches you explained could eventually do what i wanted. We had already thought about first one. But it would take time to match make players.
We have used Check and Swap in our game but it's not for match making. What i was thinking if Photon has similar feature for matchmaking. When a player who is searching a game for e.g. of Level1 and finds a room then on same call photon could mark a slot in room as occupied and let this player join. So in details photon room could have slots like 1,1,1,1,2,2,2,2,3,3 (for my case of 10 players) as soon as a player with 1 joins that slot is gone. But i know this is not there.
One more approach i could try is below:
Player searches for a room of Level 1. He doesn't find
Create a room with max players 4 and criteria Level 1
After 4 players of level 1 join then change max players to 8 and criteria to Level 2
When 4 more players of Level 2 join then change max players to 10 and criteria to level 3
This is again time consuming but doesn't require switching rooms of kicking players.
Note: one issue to manage would be when any player with level 1 leaves while we are searching for players of level 2.0 -
I think you can't change MaxPlayers once a room is created. You can still test it to confirm.
You can make use of CAS in Part 2 of my proposed draft to avoid 2 ex.MasterClients of same level inviting other same level players at the same time. You can send invitations (target room name) using another mean to avoid extra delay of going back to first same level room. Like Photon Chat, web service, Push Notification (data only), etc.
Also my solution relies on RoomOptions PlayerTTL, EmptyRoomTTL, CheckUserOnJoin, PublishUserIDs, MaxPlayers and IsVisible. I prefer to use different lobbies for matchmaking rather than lobby properties.0