Author Topic: What's the best way to do matchmaking?  (Read 7746 times)

aceteams

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 3
    • View Profile
What's the best way to do matchmaking?
« on: December 28, 2013, 10:55:48 PM »
We're making a competitive 1v1 game and we want to implement a match-making lobby. We have a few problems and a few ideas. We figured we would ask first to save time.  ;D

1) How should the matchmaking algorithm work with tnet? Should we write our own LobbyServer? Or is there a way to distribute these calculations among the users? Or should we write a "special" client who manages all of this, while using the built-in TN servers? Or something else we haven't thought of?

2) Should GameServers be on the client devices or on our server? We're having trouble with this at the moment. If we run a GameServer on our EC2 instance, we can fiddle with permissions and port forwarding until it works. However, we can only have one game going at a time. But if we just use the EC2 instance as a lobby and try to run the GameServers on our own computers, we aren't able to get a connection going ("unable to connect" messages.) It seems like if we want it to work for users, we shouldn't need to fiddle with it - it should just work. Does this sound like we're doing something wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #1 on: December 29, 2013, 01:39:22 AM »
1. Easiest... I'd say use TNet's server broadcast feature to periodically advertise the player's "LFG" status. Other players will pick up on this RFC and whether respond to it, or do nothing. Broadcasting a message to people not in the same channel is just like sending any other RFC. Just make sure that the RFC exists on all players (so make it in a script attached to the TNManager or something else that's persistent).

2. Why only one game? A server can have any number of games on it, provided each game is in their own channel (as it should be). Make sure to choose a unique channel ID when joining a channel to create new games. There is also a function for that too.

aceteams

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 3
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #2 on: December 29, 2013, 02:03:30 AM »

1. Hmm, there are many possibilities for this. An idea I just came up with: have an "LFG" channel, where the host is responsible for assignments - that way there are no awkward collisions, and also no need for a separate program.

2. Ah! Now I feel a bit dumb. For some reason I had the impression that there was a 1-to-1 correspondence between channels and scenes, and that if you had multiple channels they had to be in different scenes. Thanks!

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #3 on: June 13, 2016, 09:29:37 AM »
Hello,
The prototype that i am working on is similar to a billiards game (https://en.wikipedia.org/wiki/Carom_billiards)
Trying to figure out how to go about a match making system for that,

Right now the Game Flow is very simple and only 2 players can play.

Menu Scene (Press Join to Start Game) only uses Channel 1 so only a single session is possible.
Game Scene (Player Spawns and waits for player 2)
When both are ready, game starts!

so if i want a match making system using RFC how should i go about that?

Learning Tnet so that we can start a full fledged multiplayer game soon, please excuse all the questions.
Thank you! :)

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #4 on: June 13, 2016, 06:01:39 PM »
I'd start out with some sort of Que system and then a rank system to sort the Que into something like "novice" or "pro".



In the end, the rank system would be key:

http://research.microsoft.com/en-us/projects/trueskill/details.aspx

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #5 on: June 14, 2016, 12:10:33 AM »
Hello devomage,
Thanks for the reply, yes i get that some sort of ranking system like MMR system for DotA, etc..
I was asking for the implementation advice using RFC like ArenMook had mentioned before.

How will Player A broadcast a message when he is searching for a game, and how can Player B join the match? The basic flow of how this can be achieved.

And how should i start new game sessions in another channel?  Can i scan all available channels to check and assign appropriate number for a new game session?

« Last Edit: June 14, 2016, 12:37:30 AM by neeraj »

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #6 on: June 14, 2016, 07:25:38 AM »
GameType: Billiards (1 vs 1)
The Prototype Starts with the Menu Scene (Channel: 1 All Players AutoJoin here),
  • If you press find then Match Making triggers...
  • RFC is sent to all player in MM, the rating logic would be Applied to find the appropriate Player
  • Then the 2 players would start a game channel to play the session

I wanted to ask if this right approach for matchmaking?
This is just so that i can setup a small base on matchmaking,
Please suggest, Thank you!

  1.  
  2.  public void MatchMake()
  3.     {
  4.         StartCoroutine(MatchMaking());
  5.         matchMakebutton.SetActive(false);
  6.         matchMakingAnimate.SetActive(true);
  7.     }
  8.  
  9.     void StopMatchMaking()
  10.     {
  11.         matchMakingAnimate.SetActive(false);
  12.         matchMakebutton.SetActive(true);
  13.         StopAllCoroutines();
  14.     }
  15.    
  16.     IEnumerator MatchMaking()
  17.     {
  18.         Vector3 info;
  19.         info.x = TNManager.playerID;
  20.         info.y = 200;
  21.         info.z = 0;
  22.         tno.Send("RFC_MatchMake", Target.Others, info);
  23.         yield return new WaitForSeconds(0.5f);
  24.         StartCoroutine(MatchMaking());
  25.     }    
  26.    
  27.     /// <summary>
  28.     ///  X is Player ID
  29.     ///  Y is Rating
  30.     ///  Z is Something..
  31.     /// </summary>
  32.     /// <param name="_MMR"></param>
  33.     [RFC]
  34.     void RFC_MatchMake(Vector3 _MMR)
  35.     {
  36.         if(matchMakingAnimate.activeInHierarchy)
  37.         {
  38.             matchedOpponent = _MMR;
  39.             if (matchedOpponent.y == 200) //Match Making Logic!
  40.             {
  41.                 Debug.Log("Match Found!");
  42.                 if (TNManager.playerID < matchedOpponent.x) //if My Player id is Less than the opponents ID.
  43.                 {
  44.                     StopAllCoroutines(); // Stop Match Making
  45.                     HostGame(); //I will be the host!
  46.                 }
  47.             }
  48.         }
  49.     }
  50.  
  51.     public void HostGame()
  52.     {
  53.         TNManager.GetChannelList(_CallOnChannelList);
  54.     }
  55.    
  56.     /// <summary>
  57.     /// Channels list
  58.     /// </summary>
  59.     void _CallOnChannelList(List<Channel.Info> chList)
  60.     {
  61.         int lastChannelID = chList[chList.size - 1].id + 1;        
  62.  
  63.         Vector3 info;
  64.         info.x = matchedOpponent.x;
  65.         info.y = lastChannelID;
  66.         info.z = 0;
  67.         tno.Send("RFC_JoinGame", Target.Others, info);
  68.  
  69.         JoinChannel(lastChannelID);
  70.     }
  71.  
  72.     void JoinChannel(int _channelID)
  73.     {
  74.         if(TNManager.GetChannel(_channelID).players.Count < 2)
  75.         {
  76.             TNManager.JoinChannel(_channelID, sceneName, true, 2, null);
  77.         }
  78.         else
  79.         {
  80.             Debug.LogError("Game has already Started");
  81.         }      
  82.     }
  83.  
  84.     /// <summary>
  85.     /// X is Player ID
  86.     /// Y is Channel ID
  87.     /// Z is Something
  88.     /// </summary>
  89.     /// <param name="_joinData"></param>
  90.     [RFC]
  91.     void RFC_JoinGame(Vector3 _joinData)
  92.     {
  93.         if(TNManager.playerID == (int)_joinData.x)
  94.         {
  95.             JoinChannel((int)_joinData.y);
  96.         }      
  97.     }
  98.  
« Last Edit: June 15, 2016, 12:27:02 AM by neeraj »

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #7 on: June 14, 2016, 09:43:44 PM »
Personally, I'd stay away from Coroutines - networking tends to be it's own event system.  Also you might utilize built in player data (ie set a bool for "is looking for match"). 

Overall it appears you have a sound concept though.

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #8 on: June 15, 2016, 12:24:15 AM »
Thank you devomage,
I thought Coroutines would help in periodic data transfer? Should the alternate would be using an Update with a timed RFC call?

And i will look into PlayerData, its similar to PlayerPrefs right?
Also i did not understand what you meant by "networking tends to be it's own event system"

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #9 on: June 15, 2016, 08:45:13 PM »
Also i did not understand what you meant by "networking tends to be it's own event system"

Generally speaking, in a client/server model you make a request and get a response...  for example, requesting a channel list.

In your case - you wouldnt need to loop "MatchMaking()" because it would only be needed when a player clicks a button.



I spent a few minutes on an example:

http://pastebin.com/ga8Y9yHc

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #10 on: June 16, 2016, 12:30:44 AM »
Thanks a ton!  ;D
i will go through and implement it !
I might have some doubts but will get back soon.

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #11 on: June 16, 2016, 07:45:03 AM »
Ok i think i get it, So say the game was booted by Player A, then by Player B. Since Player A Joined the Lobby Channel first, he will be the channel Host and he is the one who receives all Matchmaking queries and replies to them.

So another question, if suppose i want to stall the matchmaking a little longer to check for the appropriate player (Based on player rank) and then pair them together. How can
that be accomplished ?
Something like Hearthstone https://www.youtube.com/watch?v=60fW2YxIISQ

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #12 on: June 16, 2016, 03:13:53 PM »
getting a match is going to take no time at all.  i would "fake it" and add a splash screen after the RFC to "enter game" is received.  then, when the splash screen is finished, enter the game scene.  you also could make it the first thing that happens after entering the game scene.  it's really design preference at that point.

neeraj

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #13 on: June 17, 2016, 12:06:00 AM »
Yea i understand this but i am getting very curious now, so taking another example: why does it take longer in Rocket League's case: https://youtu.be/8x7wj8lBJP0?t=27
Is it because its pairing them together and finding a dedicated server for them? but again i assume it should be also faster right?

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: What's the best way to do matchmaking?
« Reply #14 on: June 17, 2016, 11:49:35 PM »
140,000 users and 3 servers...

100% speculation, but perhaps something like this:

- get Que list from each server?
- find a match
- alert player - if player goes offline or joins another match in the meantime - rinse/repeat

Guess it could take some time with that sort of load.