AWS for Games Blog

How to use Amazon GameLift FlexMatch to implement block and avoid lists

For online game players, a key driver of player satisfaction is the availability of tools for safeguarding individuals and ensuring community health. Competitive games are especially prone to toxic interactions, and a healthy community will increase player retention. Block and avoid lists are a way to ensure that your players don’t have to interact or play with players that they don’t want to. In this blog post we will cover how to implement block and avoid lists using Amazon GameLift FlexMatch rule sets and player attributes.

Amazon GameLift FlexMatch is a matchmaking service that allows you to create custom rules for matchmaking and fine-tune the matchmaking algorithm.

Benefits of Amazon GameLift FlexMatch

  • FlexMatch is a scalable matchmaking service that you can use as a standalone solution or as a fully integrated feature with Amazon GameLift managed hosting.
  • The robust rules language lets you customize the matchmaking process for your games. Use the Amazon GameLift console to build from samples or start from scratch.
  • Find a balance between match speed and quality. A quality match will be one with players in a similar skill range, with low latency between them. Set match rules to quickly find matches that have lower quality, or increase matchmaking time to find the best match for an optimum player experience.
  • Make matches based on well-matched players or well-matched teams. Create a match where all players have similar characteristics, such as skill or experience. Alternatively, form matches where the combined characteristics of each team are similar, even if the characteristics of individual players are more varied.
  • Prioritize how player latency factors into a match. Set a hard limit on latency for all players in a match, make sure that everyone in a match experiences similar latency, or do both.

Before we create rule sets for block and avoid lists, we must understand two core components of a matchmaking rule set: player attributes and rule expansions.

Player attributes

Player attributes are characteristics of players that can be used to match the different players during a session. For example, you can pass in each player’s skill level to only match similarly skilled players. Player attributes are declared when designing a rule set and require a unique name and data type. For block and avoid lists, FlexMatch supports a string_list data type which can be used to send the player IDs to those block or avoid lists.

Example:

    "playerAttributes": [{
         "name": "BlockList",
         "type": "string_list",
         "default": []
     }]

For more information, see how to design a rule-set.

Expansion rules

Expansion rules are used to relax match criteria if FlexMatch is finding it difficult to satisfy all of the conditions. For example, you can create an expansion rule that increases the maximum permitted latency when tickets remain unmatched for a period of time that you define.

For avoid lists, you can use an expansion rule to match players only when no other matches are available.

Expansion rules do not apply to block lists, but are used in our avoid list rule set.

Block and Avoid List Considerations

Before implementing a rule set that uses a block or avoid list, consider the following issues:

  • Currently there is a limit of 100 items in a player attribute string list, so the maximum players on a block or avoid list is 100.
  • Any additional rules in a ruleset will increase matchmaking times, as they result in fewer acceptable matches. If you have a small player base, block lists will not be appropriate for this reason. A player that has been blocked by a large number of people will have little available games and may not be able to find a match. If you have a large player base and your game requires large teams, you may also find that matchmaking times significantly increase. This is because each player can have their own block list, which must be compared against multiple proposed matches and is more likely to cause match conflicts. In these cases, using an avoid list is an alternative
  • FlexMatch processes rule expansions in a certain order. You have to set expansionAgeSelection to “newest” or “oldest” to define whether expansion age is calculated based on the newest or the oldest ticket in the potential match. If the expansion is looking at the newest ticket, matchmaking will happen more slowly. It will ensure that the full time has elapsed before any player is matched with a player on their avoid list. The oldest setting  is  quicker, but the player is much more likely to be put into a game with someone on their avoid list. A block list doesn’t have expansions so this doesn’t apply here. For more information, see the documentation on match ruleset property definitions.

We recommend that you test your rule set before implementing a block or avoid list. To do this you can use the Amazon GameLift Testing Toolkit. This will allow you to make changes to and block and allow list settings without running them on the live game.

FlexMatch block list

Block lists are hard limits on who any given player will be matched with. The block list allows players to moderate who they play with by ensuring that any blocked players will not be put in the same match.

Here’s an example of a rule set that uses a block list. This example passes in each player’s block list, which consists of a list of player IDs, as a player attribute. When FlexMatch evaluates a player for a potential match, the PlayerIdNotInBlocklList rule compares that player’s block list against the list of all player IDs in a proposed match.

{
    "name": "Player Block List",
    "ruleLanguageVersion": "1.0",
    "teams": [{
        "maxPlayers": 5,
        "minPlayers": 5,
        "name": "red"
    }, {
        "maxPlayers": 5,
        "minPlayers": 5,
        "name": "blue"
    }],
    "playerAttributes": [{
        "name": "BlockList",
        "type": "string_list",
        "default": []
    }],
    "rules": [{
        "name": "PlayerIdNotInBlockList",
        "type": "collection",
        "operation": "reference_intersection_count",
        "measurements": "flatten(teams[*].players.attributes[BlockList])",
        "referenceValue": "flatten(teams[*].players[playerId])",
        "maxCount": 0
    }]
}

FlexMatch avoid lists

Avoid lists are similar to block lists but are more flexible. Not being matched with a player on the avoid list is treated as a preference, instead of a requirement. To set up an avoid list, use the same type of rule as with a block list, and add an expansion rule.

Here’s an example of a rule set that uses an avoid list. As with the block list example, this example initially prevents a match with any player on the avoid list. The expansion rule then increases the acceptable number of players on the avoid list by 10 (defined by the value, which means that all players are allowed to match after the waiting time) every 15 seconds.

{
    "name": "Player Avoid List",
    "ruleLanguageVersion": "1.0",
    "teams": [{
        "maxPlayers": 5,
        "minPlayers": 5,
        "name": "red"
    }, {
        "maxPlayers": 5,
        "minPlayers": 5,
        "name": "blue"
    }],
    "playerAttributes": [{
        "name": "AvoidList",
        "type": "string_list",
        "default": []
    }],
    "rules": [{
        "name": "PlayerIdNotInAvoidList",
        "type": "collection",
        "operation": "reference_intersection_count",
        "measurements": "flatten(teams[*].players.attributes[AvoidList])",
        "referenceValue": "flatten(teams[*].players[playerId])",
        "maxCount": 0
    }],
    "expansions": [{
        "target": "rules[PlayerIdNotInAvoidList].maxCount",
        "steps": [{
            "waitTimeSeconds": 15,
            "value": 10
        }]
    }]
}

Amazon GameLift console walkthrough

  1. Go to the Amazon GameLift service in the AWS console.

Amazon GameLift console home page.

  1. Select the FlexMatch dropdown from the navigation pane and select Matchmaking rule sets. Then select the Create matchmaking rule set

Amazon Gamelift console matchmaking rule sets page.

  1. You can then choose between using a pre-built sample template, clone from one of your existing rule sets, or start from scratch.

Amazon GameLift console template selection.

  1. In our case, we will use the From scratch

Amazon GameLift console choose from scratch.

  1. You can check that your rule set syntax matches the FlexMatch rules language by selecting the Validate There will be a tooltip to confirm that the ruleset is valid.

Amazon GameLift console define and create page with the valid ruleset tooltip.

  1. Select the Create button at the bottom of the screen. Please bear in mind that the rule sets cannot be updated after creation.

Amazon GameLift console rule set create button.

 

Conclusion

In summary, when using Amazon GameLift FlexMatch with player attributes, you can create a flexible and dynamic system that uses player preferences  during the matchmaking process. Use this in conjunction with the Amazon GameLift Testing Toolkit to test and fine tune your rules.

Suggested readings

Amazon GameLift documentation
Amazon GameLift Testing Toolkit solution
Amazon GameLift Multiplayer session-based game hosting solution with serverless backend
FlexMatch compound rules blog post 

Additional materials

AWS Solutions Library: Community Health
AWS for Games Success Stories