Search code examples
unity-game-enginematchmaking

Dummy players in with unity matchmaker


I'm creating a multiplayer card game, this game needs 4 players exactly, it's two teams of 2 players playing against each other. I'm using Unity Services Matchmaker, here is my match rules JSON :

{
  "Name": "same bet",
  "MatchDefinition": {
    "Teams": [
      {
        "Name": "team",
        "TeamCount": {
          "Min": 2,
          "Max": 2
        },
        "PlayerCount": {
          "Min": 2,
          "Max": 2
        },
        "TeamRules": [
          {
            "Name": "same bet",
            "Type": "Equality",
            "Source": "Players.CustomData.bet",
            "Reference": "200",
            "Not": false,
            "EnableRule": true
          }
        ]
      }
    ],
    "MatchRules": [
      {
        "Name": "bet 200",
        "Type": "Equality",
        "Source": "Players.CustomData.bet",
        "Reference": "200",
        "Not": false,
        "EnableRule": true
      }
    ]
  },
  "BackfillEnabled": false
}

If I'm not wrong, here I'm telling the matchmaker that game needs 2 teams and each team need 2 players and all players have put same bet 200 (correct me if I'm wrong please).

if my match rules json is good, my question is the following : as my game is new, I'm not expecting lot of players in first days, so I'm afraid that first players never find a match, is there a way to tell the matchmaker to start a game when certain time is elapsed and tell my server game to fill with bot players ?


Solution

  • Thank to @derHugo 's answer, the relaxation of matchmaking rules was the solution for my use-case.

    For future readers : Using relaxation is like telling the matchmaker after X seconds if there are some tickets that are not matched, change this values in the rules ... In my use-case I used the relaxation as follow : first of all I tell the matchmaker that the server needs 2 teams of 2 players, but if after 10 seconds there are not enough players, relax the rules and require minimum 1 team of 1 player, which means the server can start with 1 player.

    From the game server side, I changed it so that when it's started and some number of players are connected to it but after 5s the required number of players is not fulfilled, it means that it has to fill the gap with bots.

    here is my matchmaker rules JSON using relaxation

    {
      "Name": "same bet",
      "MatchDefinition": {
        "Teams": [
          {
            "Name": "team",
            "TeamCount": {
              "Min": 2,
              "Max": 2,
              "Relaxations": [
                {
                  "Type": "RangeControl.ReplaceMin",
                  "AgeType": "Oldest",
                  "Value": 1,
                  "AtSeconds": 10
                }
              ]
            },
            "PlayerCount": {
              "Min": 2,
              "Max": 2,
              "Relaxations": [
                {
                  "Type": "RangeControl.ReplaceMin",
                  "AgeType": "Oldest",
                  "Value": 1,
                  "AtSeconds": 10
                }
              ]
            },
            "TeamRules": [
              {
                "Name": "same bet",
                "Type": "Equality",
                "Source": "Players.CustomData.bet",
                "Reference": "200",
                "Not": false,
                "EnableRule": true
              }
            ]
          }
        ],
        "MatchRules": [
          {
            "Name": "bet 200",
            "Type": "Equality",
            "Source": "Players.CustomData.bet",
            "Reference": "200",
            "Not": false,
            "EnableRule": true
          }
        ]
      },
      "BackfillEnabled": false
    }