Sign In Register

How can we help you today?

Start a new topic
Answered

Implementing Random Matchmaking

I saw an older thread on this topic (https://support.gamesparks.net/support/discussions/topics/1000024080) and wanted to check in about any update or how I might be able to "roll my own".


The basic feature is to allow a user to be randomly matched up with another user in the system, but based on some criteria. For example, if every player has an ELO rating value, I might want to select two people who have similar ratings so the match is even. Other examples might be choosing a player who is at a similar level or only choosing another player who has been active in the past 60 days.


In my particular case, it doesn't matter if the other user is online (async), and the other person doesn't need to be looking for a match.


There doesn't seem to be a built-in way to do this with GameSparks, but I'm guessing I might be able to store relevant matchmaking data in it's own NoSQL collection and then query that data to find a match? Or is it possible to access/query/index the a Players collection directly and use either the ScriptData or PrivateData for each player?


Not that I want the problem solved for me, but I'm evaluating using GameSparks and I want to get a sense of how easily doable this sort of thing would be and the amount of flexibility the system provides to implement something like this that isn't provided on a silver platter :).


Best Answer

Hi Clark,


So this is very doable on GameSparks! What I would do on this case is set it up so that when a player registers, we create a new document for that player in a runtimeCollection called "playerMatchmakingProfile" or something to that effect. In that document I would store all the relevant matchmaking information and the playerId, you could then fire an event which uses SparkMongoCursor to iterate through the documents in the collection and compare the ELO ratings, level and how active they have been.


The event could store an array of appropriate candidates, then pick from that selection which one to match the player with and fire off a CreateChallengeRequest (using SendRequest) with their playerId.


It is definitely possible to store all the relevant data in the player's ScriptData and/or PrivateData (the difference being PrivateData is only accessible through cloud code) but I would still recommend storing at least a player index in a separate runtimeCollection as these are much fast to loop through than the systemCollection where the player profiles are stored.


There are plenty of examples on the forums of storing and retrieving data from a custom collection, but if you have any more questions, please, don't hesitate to ask!

Shane


Answer

Hi Clark,


So this is very doable on GameSparks! What I would do on this case is set it up so that when a player registers, we create a new document for that player in a runtimeCollection called "playerMatchmakingProfile" or something to that effect. In that document I would store all the relevant matchmaking information and the playerId, you could then fire an event which uses SparkMongoCursor to iterate through the documents in the collection and compare the ELO ratings, level and how active they have been.


The event could store an array of appropriate candidates, then pick from that selection which one to match the player with and fire off a CreateChallengeRequest (using SendRequest) with their playerId.


It is definitely possible to store all the relevant data in the player's ScriptData and/or PrivateData (the difference being PrivateData is only accessible through cloud code) but I would still recommend storing at least a player index in a separate runtimeCollection as these are much fast to loop through than the systemCollection where the player profiles are stored.


There are plenty of examples on the forums of storing and retrieving data from a custom collection, but if you have any more questions, please, don't hesitate to ask!

Shane

For creating a system like this I'm trying this approach. Might not cover all your things but it can be the simplest thing i can think off.


1. Create a leaderboard(lets a global score LB) according to your priority for matchmaking. - this is to fetch players near the current players rank.

2. There is a request which will retrieve players around you PlayersAroundMe.

3. When user clicks on random, Pass  a challenge create request with param flag as random and just fetch the above details in cloud code, pick the player from leaderboard and auto-accept the request .


Thats it!


I just got this idea and seems simple to try out, how ever what Shane suggested could be the proper way to do though. I will try out this and share you the code/examples if i'm done with it. meanwhile if you like the approach pls suggest some ideas to improve this.


Thanks,

Ayyappa.


Login to post a comment