

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 例: 明示的な並べ替えを使用して最適なマッチングを見つける
<a name="match-examples-4"></a>

この例では、3 人ずつのプレイヤーで構成される 2 つのチームでシンプルなマッチングを設定します。明示的な並べ替えルールを使用して、可能な限り最良のマッチングをできるだけ早く見つける方法を示します。これらのルールでは、すべてのアクティブなマッチメーキングチケットを事前に並べ替え、特定のキーとなる要件に基づいて最適な対戦を作成します。この例は、以下の手順に従って実装します。
+ プレイヤーのチームを 2 つ作成します。
+ 各チームを正確に 3 人のプレイヤーで構成します。
+ 以下のプレイヤー属性を含めます。
  + 経験レベル (指定しない場合、デフォルトで 50 が使用されます)。
  + 優先するゲームモード (複数の値をリスト可能) (指定しない場合、デフォルトで「クープ」と「デスマッチ」が使用されます)。
  + 優先するゲームマップ (マップ名と優先重み付けを含む) (指定しない場合、デフォルトで重み 100 の `"defaultMap"` が使用されます)。
+ 事前並べ替えを設定します。
  + アンカープレイヤーとして同じゲームマップを優先する度合いに基づいてプレイヤーを並べ替えます。プレイヤーのお気に入りのゲームマップは複数存在することがあるため、この例では優先値を使用しています。
  + 経験レベルがアンカープレイヤーとどれだけ近くマッチングするかに基づいてプレイヤーを並べ替えます。この並べ替えにより、すべてのチーム間ですべてのプレイヤーの経験レベルができるだけ近いものになります。
+ すべてのチーム間ですべてのプレイヤーが少なくとも 1 つのゲームモードを共通して選択している必要があります。
+ すべてのチーム間ですべてのプレイヤーが少なくとも 1 つのゲームマップを共通して選択している必要があります。

このルールセットの使用に関する注意事項 
+ ゲームマップの並べ替えでは、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
    }]
}
```