Sample matchmaking requests - Amazon GameLift Servers
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Sample matchmaking requests

The following code snippets build matchmaking requests for several different matchmakers. As described, a request must provide the player attributes that are required by the matchmaker in use, as defined in the matchmaker's rule set. The attribute provided must use the same data type, number (N) or string (S) that is defined in the rule set.

# Uses matchmaker for two-team game mode based on player skill level def start_matchmaking_for_cowboys_vs_aliens(config_name, ticket_id, player_id, skill, team): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "skill": {"N": skill} }, "PlayerId": player_id, "Team": team }], TicketId=ticket_id) # Uses matchmaker for monster hunter game mode based on player skill level def start_matchmaking_for_players_vs_monster(config_name, ticket_id, player_id, skill, is_monster): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "skill": {"N": skill}, "desiredSkillOfMonster": {"N": skill}, "wantsToBeMonster": {"N": int(is_monster)} }, "PlayerId": player_id }], TicketId=ticket_id) # Uses matchmaker for brawler game mode with latency def start_matchmaking_for_three_team_brawler(config_name, ticket_id, player_id, skill, role): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "skill": {"N": skill}, "character": {"S": [role]}, }, "PlayerId": player_id, "LatencyInMs": { "us-west-2": 20} }], TicketId=ticket_id) # Uses matchmaker for multiple game modes and maps based on player experience def start_matchmaking_for_multi_map(config_name, ticket_id, player_id, skill, maps, modes): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "experience": {"N": skill}, "gameMode": {"SL": modes}, "mapPreference": {"SL": maps} }, "PlayerId": player_id }], TicketId=ticket_id)