Search Unity

Match Making 1v1

Discussion in 'Multiplayer' started by dude4004, Mar 3, 2017.

  1. dude4004

    dude4004

    Joined:
    Jul 15, 2014
    Posts:
    181
    Is there a Asset on Unity Store that provided a Match Making 1v1 where a server decide who are the 2 clients which will fight against each other by a ranking?

    I don't want to pay Unity or Photon for licences.
    I want the 2x client to be hosted together and 1 server handle the match making.

    If there is NO package that provide this, what is the best way to achieve this?

    best regards,
     
  2. Oakioats

    Oakioats

    Joined:
    Mar 27, 2016
    Posts:
    7
    I have not gotten into this. I am a beginner. What you want is a quick match right? It will do all the match making for you and pair you up with another folk. ya?

    Have you checked out the lobby manager asset? If you dig in there it provides match making for you, but it does not account for quick matching. It does provide a list of servers which you can access and then perhaps access the player who is hosting the match variable/ranking number.
     
  3. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    It's very unlikely you'll find a free service for this type of thing, if I understand you correctly. Matchmaking, as a concept, requires a server at minimum, because it needs to:
    • collect statistics on players to determine matches
    • know which players are connected/active or not
    • handle matchmaking requests
    So, there is always a server part to matchmaking and servers aren't free. The algorithms involved in matchmaking are also quite complex so the servers needed to handle matchmaking (especially for games with lots of players) often have to be quite powerful.

    Unity's and photon's matchmaking services will do what you need though. Both have limited-free/trial/cheap options so that you can get started and start paying once you're actually (hopefully) making money.

    Alternatively, you could significantly lower your costs by creating your own matchmaking server and managing the sever(s) yourself since then you avoid any overhead costs/license fees. This is obviously the more complex approach though.

    Good luck with your game!
     
  4. dude4004

    dude4004

    Joined:
    Jul 15, 2014
    Posts:
    181
    What I'm looking is doing a quick match just like Clash Royal. You do not choose the lobby or the game server. It choose it for you 1 VS 1 automatically by the ranking score. Ex : You have 1500 rating, you are matched to someone between 1450 and 1550.

    best regards,
     
  5. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    Okay, well again that is something that could be handled with unity's/photon's matchmaking. However, to give you an idea of how you could do this yourself:
    • create a simple server application (could be done in unity, or any other server application framework that you might prefer). This application will be designed to basically hold records of active players seeking games, and their rank, and match them together
    • i suggest using an application-level database engine for the management of data here, as this will make your solution more scalable during times when you have thousands of players seeking games. Sqlite is one of the more well-known and robust databases used for this type of thing. It can also be used in-memory (storing the database data on RAM) making it lightning fast to read/write to/from the database
    • when a player goes into the lobby, they would connect to this server, and send their rank
    • the server would store the rank, and some way to identify the player (in order to join a game with them). Note that at this point, if the player disconnects from the server (for whatever reason), the server must clear up the player's data, so that they are no longer considered when matching players
    • as to what you do next is up to you, but ultimately now with your player data on the server, you can communicate with it in order to match yourself to another player. The next part would be to work out how to get those players into an isolated game. I'll assume you've already got that part covered.
    This server application you could then build and run it locally for testing, and/or run it on your own dedicated server so that others can use it remotely.

    Hopefully this helps. Let me know if you get stuck.
     
  6. mikeownz

    mikeownz

    Joined:
    Mar 3, 2017
    Posts:
    21

    Donnysobonny,
    How do you implement what the OP wants to do using UNET?
    I.e setup an automatch making system without using a lobby and searching for available games?
     
  7. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    @mikeownz I had to do a bit of reading here, as it's been a while since I looked into this type of thing and it seems to have changed quite a bit. Ultimately though, here's what it looks like you need to do:
    1. set up your project with unity multiplayer: https://docs.unity3d.com/Manual/UnityMultiplayerSettingUp.html
    2. based on the documentation, once you set up the above, unity will automatically link your project to the multiplayer services you just set up. So you should now be able to use the matchmaking functionality of the HLAPI. Examples and additional info here: https://docs.unity3d.com/Manual/UnityMultiplayerIntegratingHighLevel.html
    I haven't tested the above, but it looks like that should work. Hopefully this helps!

    The example in the link above does display a simple GUI to simulate some sort of a lobby. You could bypass this if you want players to be automatically matched up, by using the CreateMatch/ListMaches/JoinMatch methods straight away, rather than when buttons are clicked like in the example. Let me know if you need further help on this.
     
    Last edited: Mar 10, 2017
  8. mikeownz

    mikeownz

    Joined:
    Mar 3, 2017
    Posts:
    21
    Thanks for the reply. Reading through this cleared mostly everything up.

    I suppose I could create some logic that goes along like this:

    Search for match script:
    On Client
    1) Get List of Matches
    2) Get a MatchInfoSnapShot on the matches
    3) If there are any matches available, try to join a match with most players in it, and comparable average Elo score (this was a nice find, because now I can match players based on skill level)
    4) If there are matches available, then join
    5) If no matches available, create a match and set Elo score

    ***The above would probably be enough for my needs. I could try to get even fancier but step 7 below could cause some issues, if two hosts cancel the match at the same time and try to join each others game.
    6) If created a match, continue to periodically get list of matches anyway (if still waiting on players)
    7) If find another match that looks like a candidate to merge matches, drop host and have all clients join new host.

    I don't see any tutorials online for this, and I would imagine this would be a very popular request.
    Maybe if I get it working, I will make a tutorial.
     
  9. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    So this is a great start, however, you shouldn't put this sort of responsibility on the client-side simply because it wont scale too well when you have thousands or more players all asking for matching at the same time. In stead:
    1. when the client joins the lobby/wants to find a game, notify the server (maybe send your elo score here, if this information is available to the client, otherwise it should already be available to the server). This will instruct the server to keep a record of the client as someone that wants to play a game
    2. the server is now responsible for knowing that the client is available. So if the client disconnects beyond this point, make sure to remove the client's records from the data
    3. the server can now periodically generate games based on all of the clients that are connected to it, acting almost like a central routing gateway. It will find players that should play together (using whatever kind of algorithm you want here, but keep it as lean as possible) and send a game identifier to those players so that they are able to join the same "game"
    4. remove the client records from the server as they are no longer needing to be put into a game
    So the result here is that the client makes one communication to the server to let the server know they want to play in a game, and then the server makes one communication to the players that have been paired together, rather than your current idea which would cause many more communications to be made over time.


    For issues where players fail to join games (which is something that will happen, how much so will depend on how complex your game is during start up), simply do another check during the start of the game. The simplest way to handle it:
    1. once you join the game, (not sure what your server logic here is) notify the server that you have joined
    2. if both/all players don't notify the server that they have joined after a certain amount of time, notify the players and send them back to the lobby
    This is just a basic example, you might need to do something different based on your setup and the type of game, but this is a pretty common way to do it.

    Hopefully this helps, let me know if you need further clarification.
     
  10. mikeownz

    mikeownz

    Joined:
    Mar 3, 2017
    Posts:
    21
    Thanks very much for walking me through the steps. I like this.