I have been thinking about how to approach the problem of making a matchmaking system, and I have a few ideas but haven’t tried any of them yet so I’d like some support on what would be most efficient.
If I wanted to include offline players in this matchmaking, what would be the best way to do this?
I was thinking load all of the data and look for players with similar stats as yours, but that seems extremely inefficient.
The best way I can describe this since I haven’t actually done much on it yet is:
What do you mean by offline players? As in they have a Roblox account, but are not online, or are not currently a member of Roblox, but you have info on?
If you have database experience, you could create a website to do the processing for you. All you’d need to do on your game’s end is post player data (privacy and security considerations!), and get matches. And on the website you can insert into the database, and select matches. Databases are very powerful if you know how to use them!
And yes, you can use data stores like Legosweat just said!
Lets say there was 1000 different bases in the datastore, wouldn’t it be bad for the server to load all this data to find a base for the player to attack?
I played a game quite similar so I think I get the general idea. Similar level is the only way about matching players, and xp can be gained through building, upgrading, doing achievements, and winning players’ islands or clan whatever. If that is not efficient enough, there’d have to be a complex algorithm for that. When the player goes offline, save their buildings through iteration, i.e Sniper_Tower, and its position relative to his building point, also its upgrade and other changeable stats that can be affected by the player- and so on. EVERY stat has to be saved. And it should be a breeze from there to load up the datastore, search up the offline player, and generate his clan using all the information you saved. And easily update the offline users’ stats on his buildings damage, etc. as well as deleting objects which have been fully broken, then all saved in the end. I’m just babbling on at this point but you get what I mean. You just need most of your reliability on datastores for this- so that’s something to look into.
And xp is much more efficient for a net stat to compare players for matchmaking.
I would say like servers with just 1 player, and they queue up to battle with other people?
Like Battle Royal but instead of building a deck, you build your base, army, etc.
I don’t think you will be able to do this within datastore budget assuming each player’s data is saved in its own key, unless your metric for matchmaking can be summarized in a single numeric ordered value (then you could use OrderedDataStores). But even then, there might be too much stuff to sort through to fit within ordered datastore budget, if you have a high volume of players.
You will probably need to set up an external web service that saves some metadata on each player and then lets you do the matchmaking algorithm on that external server, and returns the player to matchmake with to the Roblox game server. The Roblox server can then only load the datastore data of that player to make the match happen.
You could have a ModuleScript do all the matchmaking as a hybrid option. Then it would not matter what option you start with, as long as the interface (functions, methods, and properties), stays the same. This is similar to how enterprise level applications work. If you’re game gains traction, you can upgrade to a more robust algorithm, or leverage other servers (database servers).
You do have access to 200 player servers, that should be enough to cover matchmaking unless the players are in a small server.
As @buildthomas said… to efficiently do this I would make some sort of webservice that stores data on the match a user is going in to as well as how many other players are queuing for it, if it has less then the max players put the user in that lobby
Well that’s kind of what matchmaking is… and you can do this (with any level of optimization/approximation you want) but doing it on your own web server is probably easier than using data stores, but it’s of course not impossible and completely up to you.
For a Clash of Clans-like matchmaking, I’d suggest a queue system where attacking an offline user removes them from/ moves them to the back of the datastore.
One way of doing this could be to use ordered datastores with the keys set to some sort of variant generated using the os.time() of the offline players disconnection to ensure newer disconnections get attacked later than older ones.
With the issue of personalized matchmaking, I’d suggest doing what Clash of Clans does and create “leagues” where players in a range of levels are separated into ordered datastores per their league.
The major bottleneck in this case isn’t the CPU, the bottleneck is the loading of data. DataStores are infeasible because of this, and as other users have pointed out, the only good option is a web service.