

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 예제: 최선의 매치 검색을 위한 명시적 정렬 사용
<a name="match-examples-4"></a>

이 예제에서는 플레이어 수가 각 세 명인 두 팀으로 구성된 간단한 매치를 설정합니다. 가능한 최선의 매치를 최대한 빨리 찾기 위해 명시적 정렬 규칙을 사용하는 방법을 설명합니다. 이들 규칙은 모든 액티브 매치메이킹 티켓을 정렬하여 특정 키 요건을 기준으로 최선의 매치를 생성합니다. 이 예제는 다음 지침으로 구현됩니다.
+ 두 개의 플레이어 팀을 생성합니다.
+ 각 팀마다 정확히 3명의 플레이어를 포함합니다.
+ 다음 플레이어 속성을 포함합니다.
  + 경험 레벨(제공되지 않은 경우, 기본 설정 50).
  + 선호 게임 모드(복수 값 나열 가능)(제공되지 않은 경우 기본 설정 "협동" 및 "데스매치").
  + 선호 게임 맵(맵 이름 및 선호 가중치 포함)(제공되지 않은 경우 기본 설정 `"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
    }]
}
```