FlexMatch规则集示例 - 亚马逊 GameLift
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

FlexMatch规则集示例

FlexMatch, 规则集可以涵盖各种对战情况。以下示例符合 FlexMatch 配置结构和属性表达式语言。完整复制这些规则集或根据需要选择组件。

有关使用 FlexMatch 规则和规则集的更多信息,请参阅以下主题:

注意

当评估包含多个玩家的对战票证时,请求中的所有玩家都必须满足对战要求。

示例 1:创建两支队伍,队员人数相等

此示例说明如何按照以下说明设置两个势均力敌的玩家对战团队。

  • 创建两个玩家团队。

    • 每个团队包含四到八个玩家。

    • 最终团队必须具有相同数量的玩家。

  • 附上玩家的技能水平 (如果未提供,则默认为 10)。

  • 选择与其他玩家技能水平相当的玩家。确保这两个团队的平均玩家技能在 10 点以内。

  • 如果未能快速填充对战游戏,则放宽玩家技能要求以在合理的时间内完成对战游戏。

    • 5 秒之后,扩大搜索范围以允许创建平均玩家技能在 50 点以内的团队。

    • 15 秒之后,扩大搜索范围以允许创建平均玩家技能在 100 点以内的团队。

使用此规则集的说明:

  • 此示例允许创建包含 4 到 8 位玩家的任何规模的团队 (但两个团队的规模必须相同)。对于在有效规模范围内的团队,对战构建器会尽量尝试匹配允许的最大玩家数量。

  • FairTeamSkill 规则集可确保根据玩家技能构建对战团队。要对每个新的潜在玩家评估此规则,FlexMatch, 会暂时将玩家加入团队并计算平均值。如果规则失败,则不会将潜在玩家添加到对战游戏。

  • 由于这两个团队具有相同的结构,您可以选择仅创建一个团队定义,并将团队数量设置为“2”。在这种情况下,如果您将团队命名为“aliens”,那么为您的团队分配的名称将为“aliens_1”和“aliens_2”。

{ "name": "aliens_vs_cowboys", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "skill", "type": "number", "default": 10 }], "teams": [{ "name": "cowboys", "maxPlayers": 8, "minPlayers": 4 }, { "name": "aliens", "maxPlayers": 8, "minPlayers": 4 }], "rules": [{ "name": "FairTeamSkill", "description": "The average skill of players in each team is within 10 points from the average skill of all players in the match", "type": "distance", // get skill values for players in each team and average separately to produce list of two numbers "measurements": [ "avg(teams[*].players.attributes[skill])" ], // get skill values for players in each team, flatten into a single list, and average to produce an overall average "referenceValue": "avg(flatten(teams[*].players.attributes[skill]))", "maxDistance": 10 // minDistance would achieve the opposite result }, { "name": "EqualTeamSizes", "description": "Only launch a game when the number of players in each team matches, e.g. 4v4, 5v5, 6v6, 7v7, 8v8", "type": "comparison", "measurements": [ "count(teams[cowboys].players)" ], "referenceValue": "count(teams[aliens].players)", "operation": "=" // other operations: !=, <, <=, >, >= }], "expansions": [{ "target": "rules[FairTeamSkill].maxDistance", "steps": [{ "waitTimeSeconds": 5, "value": 50 }, { "waitTimeSeconds": 15, "value": 100 }] }] }

示例 2:创建参差不齐的队伍(猎人大战怪兽)

此示例描述了一组玩家搜捕单个怪物的游戏模式。玩家可以选择猎人或怪物角色。猎人指定他们希望对战的怪物的最低技能水平。可随时间推移放宽猎人团队的最小规模以完成对战游戏。此方案规定了以下说明:

  • 创建一个包含五个猎人的团队。

  • 创建一个包含单个怪物的团队。

  • 包含以下玩家属性:

    • 玩家的技能水平 (如果未提供,则默认为 10)。

    • 玩家首选的怪物技能水平 (如果未提供,则默认为 10)。

    • 玩家是否想成为怪物 (如果未提供,则默认为 0 或 false)。

  • 根据以下条件选择将成为怪物的玩家:

    • 玩家必须请求怪物角色。

    • 玩家必须满足或超过已添加到猎人团队的玩家的首选最高技能水平。

  • 根据以下条件选择将加入猎人团队的玩家:

    • 请求怪物角色的玩家无法加入猎人团队。

    • 如果怪物角色已填充,玩家必须要有低于建议怪物技能的怪物技能水平。

  • 如果对战游戏未快速填满,则放宽猎人团队的最小规模,如下所示:

    • 30 秒后,允许启动猎人团队只包含四个玩家的游戏。

    • 60 秒后,允许启动猎人团队只包含三个玩家的游戏。

使用此规则集的说明:

  • 通过为猎人和怪物分别创建两个单独的团队,您可以根据不同的条件评估团队成员。

{ "name": "players_vs_monster_5_vs_1", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "skill", "type": "number", "default": 10 },{ "name": "desiredSkillOfMonster", "type": "number", "default": 10 },{ "name": "wantsToBeMonster", "type": "number", "default": 0 }], "teams": [{ "name": "players", "maxPlayers": 5, "minPlayers": 5 }, { "name": "monster", "maxPlayers": 1, "minPlayers": 1 }], "rules": [{ "name": "MonsterSelection", "description": "Only users that request playing as monster are assigned to the monster team", "type": "comparison", "measurements": ["teams[monster].players.attributes[wantsToBeMonster]"], "referenceValue": 1, "operation": "=" },{ "name": "PlayerSelection", "description": "Do not place people who want to be monsters in the players team", "type": "comparison", "measurements": ["teams[players].players.attributes[wantsToBeMonster]"], "referenceValue": 0, "operation": "=" },{ "name": "MonsterSkill", "description": "Monsters must meet the skill requested by all players", "type": "comparison", "measurements": ["avg(teams[monster].players.attributes[skill])"], "referenceValue": "max(teams[players].players.attributes[desiredSkillOfMonster])", "operation": ">=" }], "expansions": [{ "target": "teams[players].minPlayers", "steps": [{ "waitTimeSeconds": 30, "value": 4 },{ "waitTimeSeconds": 60, "value": 3 }] }] }

示例 3:设置团队级别要求和延迟限制

此示例说明如何设置玩家团队,并为每个团队应用规则集,而不是为每个玩家应用规则集。它使用单个定义创建三个平均的对战团队。它还会设置所有玩家的最大延迟。随着时间的推移可以放宽延迟最大值以完成对战游戏。此方案规定了以下说明:

  • 创建三个玩家团队。

    • 每个团队包含三到五个玩家。

    • 最终团队必须包含数量相同或基本相同的玩家 (一个团队中)。

  • 包含以下玩家属性:

    • 玩家的技能水平 (如果未提供,则默认为 10)。

    • 玩家的人物角色 (如果未提供,则默认为“peasant”)。

  • 选择与对战游戏中其他玩家技能水平相当的玩家。

    • 确保每个团队的平均玩家技能在 10 点以内。

  • 将团队数量限制为“medic”角色的以下数量:

    • 整个对战游戏最多可以包含 5 个医生。

  • 仅匹配报告 50 毫秒或更少延迟的玩家。

  • 如果对战游戏未快速填满,则放宽玩家的延迟要求,如下所示:

    • 10 秒之后,允许将玩家的延迟时间值增加到 100 毫秒。

    • 20 秒之后,允许将玩家的延迟时间值增加到 150 毫秒。

使用此规则集的说明:

  • 规则集可确保根据玩家技能构建对战团队。为评估 FairTeamSkill 规则,FlexMatch 会暂时将潜在玩家加入团队并计算团队中玩家的平均技能。然后,它将规则与两个团队中的玩家平均技能进行比较。如果规则失败,则不会将潜在玩家添加到对战游戏。

  • 团队和对战游戏级别的要求 (医生总数) 通过一组规则实现。此规则类型会获取所有玩家的角色属性列表,并针对最大数量进行检查。使用 flatten 为所有团队中的所有玩家创建列表。

  • 根据延迟进行评估时,请注意以下几点:

    • 延迟数据在对战请求中作为玩家对象的一部分提供。它不是玩家属性,因此无需列出。

    • 对战构建器按区域评估延迟。延迟高于最大延迟的任何区域都将被忽略。要让对战游戏接受,玩家必须至少有一个区域的延迟低于最大延迟。

    • 如果对战请求忽略一个或多个玩家的延迟数据,则会拒绝所有对战游戏的请求。

{ "name": "three_team_game", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "skill", "type": "number", "default": 10 },{ "name": "character", "type": "string_list", "default": [ "peasant" ] }], "teams": [{ "name": "trio", "minPlayers": 3, "maxPlayers": 5, "quantity": 3 }], "rules": [{ "name": "FairTeamSkill", "description": "The average skill of players in each team is within 10 points from the average skill of players in the match", "type": "distance", // get players for each team, and average separately to produce list of 3 "measurements": [ "avg(teams[*].players.attributes[skill])" ], // get players for each team, flatten into a single list, and average to produce overall average "referenceValue": "avg(flatten(teams[*].players.attributes[skill]))", "maxDistance": 10 // minDistance would achieve the opposite result }, { "name": "CloseTeamSizes", "description": "Only launch a game when the team sizes are within 1 of each other. e.g. 3 v 3 v 4 is okay, but not 3 v 5 v 5", "type": "distance", "measurements": [ "max(count(teams[*].players))"], "referenceValue": "min(count(teams[*].players))", "maxDistance": 1 }, { "name": "OverallMedicLimit", "description": "Don't allow more than 5 medics in the game", "type": "collection", // This is similar to above, but the flatten flattens everything into a single // list of characters in the game. "measurements": [ "flatten(teams[*].players.attributes[character])"], "operation": "contains", "referenceValue": "medic", "maxCount": 5 }, { "name": "FastConnection", "description": "Prefer matches with fast player connections first", "type": "latency", "maxLatency": 50 }], "expansions": [{ "target": "rules[FastConnection].maxLatency", "steps": [{ "waitTimeSeconds": 10, "value": 100 }, { "waitTimeSeconds": 20, "value": 150 }] }] }

示例 4:使用显式排序来查找最佳匹配项

此示例设置了包含三个玩家的两个团队的简单对战游戏。它介绍了如何使用显式排序规则才能尽快找到最佳对战游戏。这些规则对所有活跃的配对门票进行排序,以根据某些关键要求创建最佳匹配. 此方案根据以下说明实现:

  • 创建两个玩家团队。

  • 每个团队只包含三个玩家。

  • 包含以下玩家属性:

    • 经验等级 (如果未提供,则默认为 50)。

    • 首选游戏模式 (可以列出多个值) (如果未提供,则默认为“coop”和“deathmatch”)。

    • 首选游戏地图,包括地图名称和首选权重 (如果未提供,则默认使用 "defaultMap" 和权重 100)。

  • 设置预排序:

    • 根据与基准点玩家相同的游戏地图的首选项来对玩家排序。玩家可以有多个最喜欢的游戏地图,因此本示例使用首选项值。

    • 根据玩家与基准点玩家的经验等级的接近程度对玩家排序。采用这种排序方式,所有玩家在所有团队中的经验等级会尽可能地接近。

  • 所有团队中的所有玩家必须至少选择一个共同的游戏模式。

  • 所有团队中的所有玩家必须至少选择一个共同的游戏地图。

使用此规则集的说明:

  • 游戏地图排序采用与 mapPreference 属性值进行比较的绝对排序。由于它是规则集中的第一个,此排序将首先执行。

  • 经验排序采用比较潜在玩家的技能级别与基准点玩家的技能的距离排序。

  • 排序按它们在规则集中的排列顺序执行。在这种情况下,玩家先按游戏地图首选项进行排序,然后按经验等级排序。

{ "name": "multi_map_game", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "experience", "type": "number", "default": 50 }, { "name": "gameMode", "type": "string_list", "default": [ "deathmatch", "coop" ] }, { "name": "mapPreference", "type": "string_number_map", "default": { "defaultMap": 100 } }, { "name": "acceptableMaps", "type": "string_list", "default": [ "defaultMap" ] }], "teams": [{ "name": "red", "maxPlayers": 3, "minPlayers": 3 }, { "name": "blue", "maxPlayers": 3, "minPlayers": 3 }], "rules": [{ // We placed this rule first since we want to prioritize players preferring the same map "name": "MapPreference", "description": "Favor grouping players that have the highest map preference aligned with the anchor's favorite", // This rule is just for sorting potential matches. We sort by the absolute value of a field. "type": "absoluteSort", // Highest values go first "sortDirection": "descending", // Sort is based on the mapPreference attribute. "sortAttribute": "mapPreference", // We find the key in the anchor's mapPreference attribute that has the highest value. // That's the key that we use for all players when sorting. "mapKey": "maxValue" }, { // This rule is second because any tie-breakers should be ordered by similar experience values "name": "ExperienceAffinity", "description": "Favor players with similar experience", // This rule is just for sorting potential matches. We sort by the distance from the anchor. "type": "distanceSort", // Lowest distance goes first "sortDirection": "ascending", "sortAttribute": "experience" }, { "name": "SharedMode", "description": "The players must have at least one game mode in common", "type": "collection", "operation": "intersection", "measurements": [ "flatten(teams[*].players.attributes[gameMode])"], "minCount": 1 }, { "name": "MapOverlap", "description": "The players must have at least one map in common", "type": "collection", "operation": "intersection", "measurements": [ "flatten(teams[*].players.attributes[acceptableMaps])"], "minCount": 1 }] }

示例 5:在多个玩家属性之间查找交集

此示例说明如何使用集合规则,在两个或更多玩家属性中查找交集。在处理集合时,您可以对单个属性使用 intersection 操作,并对多个属性使用 reference_intersection_count 操作。

为了说明这种方法,此示例会在对战游戏中根据玩家的角色首选项来评估玩家。示例游戏是一种 “free-for-all” 风格,其中比赛中的所有玩家都是对手。每个玩家需要 (1) 为自己选择一个角色,(2) 选择他们希望作为对手的角色。我们需要一个规则,该规则可确保对战游戏中的每位玩家所使用的角色都位于所有其他玩家的首选对手列表中。

该示例规则集描述了一个具有以下特征的对战游戏:

  • 团队结构:一个团队 5 个玩家

  • 玩家属性:

    • myCharacter:玩家的选定角色。

    • preferredOpponents:玩家希望作为对手的角色的列表。

  • 对战游戏规则:如果每个正在使用的角色都位于各个玩家的首选对手列表中,则潜在的对战游戏是可接受的。

为了实施该对战游戏规则,此示例使用具有以下属性值的集合规则:

  • 操作-使用reference_intersection_count运算来评估测量值中的每个字符串列表如何与参考值中的字符串列表相交。

  • 测量-使用flatten属性表达式创建字符串列表列表,每个字符串列表包含一个玩家的 my Character 属性值。

  • 参考值-使用set_intersection属性表达式创建一个包含所有 prefer redoPoPon ents 属性值的字符串列表,这些值是比赛中每个玩家共用的。

  • 限制 — 设置minCount为 1,以确保每个玩家选择的角色(测量中的字符串列表)与所有玩家共有的至少一个首选对手相匹配。 (参考值中的字符串)。

  • 扩展 — 如果匹配项未在 15 秒内填满,则放宽最低交叉点要求。

此规则的流程如下:

  1. 将一位玩家添加到潜在对战游戏。重新计算参考值 (字符串列表),以便包含与新玩家的首选对手列表的交集。重新计算测量值 (字符串列表的列表),以便将新玩家的选定角色作为新的字符串列表添加。

  2. 亚马逊GameLift会验证测量值(玩家选择的角色)中的每个字符串列表是否与参考值(玩家的首选对手)中的至少一个字符串相交。在本示例中,由于测量值中的每个字符串列表中仅包含一个值,因此交集为 0 或 1。

  3. 如果测量值中的任何字符串列表与参考值字符串列表不相交,则该规则失败,并且从潜在对战游戏中删除该新玩家。

  4. 如果对战游戏在 15 秒内未满员,则放弃对手匹配要求,以便在对战游戏中填满剩余的玩家位置。

{ "name": "preferred_characters", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "myCharacter", "type": "string_list" }, { "name": "preferredOpponents", "type": "string_list" }], "teams": [{ "name": "red", "minPlayers": 5, "maxPlayers": 5 }], "rules": [{ "description": "Make sure that all players in the match are using a character that is on all other players' preferred opponents list.", "name": "OpponentMatch", "type": "collection", "operation": "reference_intersection_count", "measurements": ["flatten(teams[*].players.attributes[myCharacter])"], "referenceValue": "set_intersection(flatten(teams[*].players.attributes[preferredOpponents]))", "minCount":1 }], "expansions": [{ "target": "rules[OpponentMatch].minCount", "steps": [{ "waitTimeSeconds": 15, "value": 0 }] }] }

示例 6:比较所有玩家的属性

此示例说明如何在一组玩家之间比较玩家属性。

该示例规则集描述了一个具有以下特征的对战游戏:

  • 团队结构:两个单人游戏团队

  • 玩家属性:

    • gameMode:玩家选择的游戏类型 (如果未提供,则默认设置为“基于次序”)。

    • gameMap:玩家选择的游戏世界 (如果未提供,则默认设置为 1)。

    • character:玩家选择的角色(无默认值,表示玩家必须指定角色)。

  • 对战游戏规则:匹配的玩家必须满足以下要求:

    • 玩家必须选择相同的游戏模式。

    • 玩家必须选择相同的游戏地图。

    • 玩家必须选择不同的角色。

使用此规则集的说明:

  • 为了实施该对战游戏规则,此示例使用比较规则来检查所有玩家的属性值。对于游戏模式和地图,该规则验证值是相同的。对于角色,该规则验证值是不同的。

  • 此示例使用一个玩家定义与数量属性来创建两个玩家团队。为团队分配了下列名称:“player_1”和“player_2”。

{ "name": "", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "gameMode", "type": "string", "default": "turn-based" }, { "name": "gameMap", "type": "number", "default": 1 }, { "name": "character", "type": "number" }], "teams": [{ "name": "player", "minPlayers": 1, "maxPlayers": 1, "quantity": 2 }], "rules": [{ "name": "SameGameMode", "description": "Only match players when they choose the same game type", "type": "comparison", "operation": "=", "measurements": ["flatten(teams[*].players.attributes[gameMode])"] }, { "name": "SameGameMap", "description": "Only match players when they're in the same map", "type": "comparison", "operation": "=", "measurements": ["flatten(teams[*].players.attributes[gameMap])"] }, { "name": "DifferentCharacter", "description": "Only match players when they're using different characters", "type": "comparison", "operation": "!=", "measurements": ["flatten(teams[*].players.attributes[character])"] }] }

示例 7:创建大型比赛

此示例说明如何为超过 40 位玩家的对战设置规则集。当规则集描述 maxPlayer 总数大于 40 的团队时,该团队会被处理为大型对战。在 设计FlexMatch大型比赛规则集 中了解更多信息。

此示例规则集使用以下说明创建对战:

  • 创建一个最多有 200 位玩家的团队,玩家人数最低要求为 175 位。

  • 平衡条件:根据相似的技能级别选择玩家。所有玩家均必须报告其技能级别才能被匹配。

  • 批处理首选项:在创建对战时按类似的平衡条件分组玩家。

  • 延迟规则:将可接受的最大玩家延迟设置为 150 毫秒。

  • 如果未能快速填充对战游戏,则放宽要求以在合理的时间内完成匹配。

    • 10 秒后,接受有 150 位玩家的团队。

    • 12 秒后,将可接受的最大延迟提高到 200 毫秒。

    • 15 秒后,接受有 100 位玩家的团队。

使用此规则集的说明:

  • 由于算法使用“最大群体”批处理首选项,玩家会根据平衡条件排序。因此,对战往往填得更满,包含技能更加类似的玩家。所有玩家均符合可接受的延迟要求,但可能无法在他们的位置获得可能的最佳延迟。

  • 此规则集中使用的算法策略“最大群体”是默认设置。要使用默认设置,您可以选择忽略此设置。

  • 如果您已启用了对战回填,请不要太快地放宽玩家计数要求,否则,您最后可能会有太多部分填充的游戏会话。在 放宽大型比赛要求 中了解更多信息。

{ "name": "free-for-all", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "skill", "type": "number" }], "algorithm": { "balancedAttribute": "skill", "strategy": "balanced", "batchingPreference": "largestPopulation" }, "teams": [{ "name": "Marauders", "maxPlayers": 200, "minPlayers": 175 }], "rules": [{ "name": "low-latency", "description": "Sets maximum acceptable latency", "type": "latency", "maxLatency": 150 }], "expansions": [{ "target": "rules[low-latency].maxLatency", "steps": [{ "waitTimeSeconds": 12, "value": 200 }], }, { "target": "teams[Marauders].minPlayers", "steps": [{ "waitTimeSeconds": 10, "value": 150 }, { "waitTimeSeconds": 15, "value": 100 }] }] }

示例 8:创建多队大型比赛

此示例说明如何为有多个团队可能超过 40 位玩家的对战设置规则集。此示例说明如何使用一个定义创建多个相同的团队,以及规模不对称的团队如何在对战创建过程中填充。

此示例规则集使用以下说明创建对战:

  • 创建十个相同的“猎人”团队,每个团队最多有 15 位玩家,并创建一个刚好有 5 位玩家的“怪物”团队。

  • 平衡条件:根据怪物技能的数量选择玩家。如果玩家未报告其技能计数,请使用默认值 5。

  • 批处理首选项:根据玩家报告最快玩家延迟的区域分组玩家。

  • 延迟规则:将可接受的最大玩家延迟设置为 200 毫秒。

  • 如果未能快速填充对战游戏,则放宽要求以在合理的时间内完成匹配。

    • 15 秒后,接受有 10 位玩家的团队。

    • 20 秒后,接受有 8 位玩家的团队。

使用此规则集的说明:

  • 该规则集定义了可能最多容纳 155 名玩家的队伍,这使其成为一场大型比赛。(10 x 15 猎人 + 5 个怪物 = 155)

  • 由于算法使用“最快区域”批处理首选项,玩家更可能被置于他们报告更快延迟的区域,而不是他们报告较高(但可接受)延迟的区域。同时,可能有更少玩家的对战和平衡条件(怪物技能的数量)可能会变化更大。

  • 当为多团队定义(数量 > 1)定义了扩展时,扩展将应用于使用该定义创建的所有团队。因此,通过放宽猎人团队的最低玩家设置,全部十个猎人团队都会受到均等的影响。

  • 由于此规则集经过优化以最大程度地减少玩家延迟,延迟规则将充当“捕获全部”方法来排除没有可接受连接选项的玩家。我们不需要放宽此要求。

  • 下面介绍了 FlexMatch 在有任何扩展生效之前如何针对此规则集填充对战:

    • 还没有团队达到 minPlayers 计数。猎人团队有 15 个空闲位置,怪物团队有 5 个空闲位置。

      • 前 100 个玩家被分配(每个团队 10 个)到十个猎人团队。

      • 接下来 22 个玩家按顺序分配(每个团队 2 个)到猎人团队和怪物团队。

    • 猎人团队已达到每个团队 12 个玩家的 minPlayers 计数。怪物团队有 2 个玩家,还未达到 minPlayers 计数。

      • 接下来的三个玩家被分配到怪物团队。

    • 所有团队均达到 minPlayers 计数。每个猎人团队都有三个空闲位置。怪物团队已满。

      • 最后 30 个玩家按顺序分配到猎人团队,确保所有猎人团队具有几乎相同的规模(加上或减去一个玩家)。

  • 如果您已为使用此规则集创建的对战启用了回填,请不要太快地放宽玩家计数要求,否则,您最后可能会有太多部分填充的游戏会话。在 放宽大型比赛要求 中了解更多信息。

{ "name": "monster-hunters", "ruleLanguageVersion": "1.0", "playerAttributes": [{ "name": "monster-kills", "type": "number", "default": 5 }], "algorithm": { "balancedAttribute": "monster-kills", "strategy": "balanced", "batchingPreference": "fastestRegion" }, "teams": [{ "name": "Monsters", "maxPlayers": 5, "minPlayers": 5 }, { "name": "Hunters", "maxPlayers": 15, "minPlayers": 12, "quantity": 10 }], "rules": [{ "name": "latency-catchall", "description": "Sets maximum acceptable latency", "type": "latency", "maxLatency": 150 }], "expansions": [{ "target": "teams[Hunters].minPlayers", "steps": [{ "waitTimeSeconds": 15, "value": 10 }, { "waitTimeSeconds": 20, "value": 8 }] }] }

示例 9:与具有相似属性的玩家进行大型比赛

此示例说明如何为两支队伍的比赛设置规则集batchDistance. 在示例中:

  • SimilarLeague规则确保比赛中的所有玩家与其他玩家的league距离在2以内。

  • SimilarSkill规则确保比赛中的所有玩家与其他玩家的skill距离在10以内。如果玩家等待了 10 秒,则距离会扩大到 20 秒。如果玩家已等待 20 秒,则距离将扩大到 40。

  • SameMap规则确保比赛中的所有玩家都提出相同的要求map

  • SameMode规则确保比赛中的所有玩家都提出相同的要求mode

{ "ruleLanguageVersion": "1.0", "teams": [{ "name": "red", "minPlayers": 100, "maxPlayers": 100 }, { "name": "blue", "minPlayers": 100, "maxPlayers": 100 }], "algorithm": { "strategy":"balanced", "balancedAttribute": "skill", "batchingPreference":"fastestRegion" }, "playerAttributes": [{ "name": "league", "type": "number" },{ "name": "skill", "type": "number" },{ "name": "map", "type": "string" },{ "name": "mode", "type": "string" }], "rules": [{ "name": "SimilarLeague", "type": "batchDistance", "batchAttribute": "league", "maxDistance": 2 }, { "name": "SimilarSkill", "type": "batchDistance", "batchAttribute": "skill", "maxDistance": 10 }, { "name": "SameMap", "type": "batchDistance", "batchAttribute": "map" }, { "name": "SameMode", "type": "batchDistance", "batchAttribute": "mode" }], "expansions": [{ "target": "rules[SimilarSkill].maxDistance", "steps": [{ "waitTimeSeconds": 10, "value": 20 }, { "waitTimeSeconds": 20, "value": 40 }] }] }

示例 10:使用复合规则与具有相似属性或相似选择的玩家进行比赛

此示例说明如何为两支队伍的比赛设置规则集compound. 在示例中:

  • SimilarLeagueDistance规则确保比赛中的所有玩家与其他玩家的league距离在2以内。

  • SimilarSkillDistance规则确保比赛中的所有玩家与其他玩家的skill距离在10以内。如果玩家等待了 10 秒,则距离会扩大到 20 秒。如果玩家已等待 20 秒,则距离将扩大到 40。

  • SameMapComparison规则确保比赛中的所有玩家都提出相同的要求map

  • SameModeComparison规则确保比赛中的所有玩家都提出相同的要求mode

  • 如果满足以下至少一个条件,则该CompoundRuleMatchmaker规则可确保匹配:

    • 比赛中的玩家提出了相同map和相同的要求mode

    • 比赛中的玩家具有可比skill的和league属性。

{ "ruleLanguageVersion": "1.0", "teams": [{ "name": "red", "minPlayers": 10, "maxPlayers": 20 }, { "name": "blue", "minPlayers": 10, "maxPlayers": 20 }], "algorithm": { "strategy":"balanced", "balancedAttribute": "skill", "batchingPreference":"fastestRegion" }, "playerAttributes": [{ "name": "league", "type": "number" },{ "name": "skill", "type": "number" },{ "name": "map", "type": "string" },{ "name": "mode", "type": "string" }], "rules": [{ "name": "SimilarLeagueDistance", "type": "distance", "measurements": ["max(flatten(teams[*].players.attributes[league]))"], "referenceValue": "min(flatten(teams[*].players.attributes[league]))", "maxDistance": 2 }, { "name": "SimilarSkillDistance", "type": "distance", "measurements": ["max(flatten(teams[*].players.attributes[skill]))"], "referenceValue": "min(flatten(teams[*].players.attributes[skill]))", "maxDistance": 10 }, { "name": "SameMapComparison", "type": "comparison", "operation": "=", "measurements": ["flatten(teams[*].players.attributes[map])"] }, { "name": "SameModeComparison", "type": "comparison", "operation": "=", "measurements": ["flatten(teams[*].players.attributes[mode])"] }, { "name": "CompoundRuleMatchmaker", "type": "compound", "statement": "or(and(SameMapComparison, SameModeComparison), and(SimilarSkillDistance, SimilarLeagueDistance))" }], "expansions": [{ "target": "rules[SimilarSkillDistance].maxDistance", "steps": [{ "waitTimeSeconds": 10, "value": 20 }, { "waitTimeSeconds": 20, "value": 40 }] }] }

示例 11:玩家避开名单

此示例规则允许玩家避开他们不想与之配对的其他玩家。每个玩家都可以定义一个避开名单,由媒人在选择玩家时进行评估. 如果玩家在现有玩家的避开名单上,则他们将被禁止参加比赛。

{ "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 }] }