ding.league.metric¶
ding.league.metric
¶
EloCalculator
¶
Bases: object
Overview
A class that calculates Elo ratings for players based on game results.
Attributes:
| Name | Type | Description |
|---|---|---|
- |
score
|
obj: |
Interfaces
__init__, get_new_rating, get_new_rating_array.
get_new_rating(rating_a, rating_b, result, k_factor=32, beta=200)
classmethod
¶
Overview
Calculates the new ratings for two players based on their current ratings and game result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
- rating_a (
|
obj: |
required | |
- rating_b (
|
obj: |
required | |
- result (
|
obj: |
required | |
- k_factor (
|
obj: |
required | |
- beta (
|
obj: |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int]
|
-ret (:obj: |
get_new_rating_array(rating, result, game_count, k_factor=32, beta=200)
classmethod
¶
Overview
Calculates the new ratings for multiple players based on their current ratings, game results, and game counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
- rating (obj
|
|
required | |
- result (obj
|
|
required | |
- game_count (obj
|
|
required | |
- k_factor (obj
|
|
required | |
- beta (obj
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
-ret(obj: |
Shapes
- rating (obj:
np.ndarray): :math:(N, ), N is the number of player - result (obj:
np.ndarray): :math:(N, N) - game_count (obj:
np.ndarray): :math:(N, N)
PlayerRating
¶
Bases: Rating
Overview
Represents the rating of a player.
Interfaces
__init__, __repr__.
LeagueMetricEnv
¶
Bases: TrueSkill
Overview
A class that represents a TrueSkill rating system for game players. Inherits from the TrueSkill class. For more details, please refer to https://trueskill.org/.
Interfaces
__init__, create_rating, rate_1vs1, rate_1vsC.
create_rating(mu=None, sigma=None, elo_init=None)
¶
Overview
Creates a new player rating object with the specified mean, standard deviation, and Elo rating.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
- mu (
|
obj: |
required | |
- sigma (
|
obj: |
required | |
- elo_init (
|
obj:int`): The initial Elo rating value for the player. If not provided, the default elo_init value of the LeagueMetricEnv class is used. |
required |
Returns:
| Type | Description |
|---|---|
PlayerRating
|
|
rate_1vs1(team1, team2, result=None, **kwargs)
¶
Overview
Rates two teams of players against each other in a 1 vs 1 match and returns the updated ratings for both teams.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
- team1 (
|
obj: |
required | |
- team2 (
|
obj: |
required | |
- result (
|
obj: |
required |
Returns:
| Type | Description |
|---|---|
Tuple[PlayerRating, PlayerRating]
|
|
rate_1vsC(team1, team2, result)
¶
Overview
Rates a team of players against a single player in a 1 vs C match and returns the updated rating for the team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
- team1 (
|
obj: |
required | |
- team2 (
|
obj: |
required | |
- result (
|
obj: |
required |
Returns:
| Type | Description |
|---|---|
PlayerRating
|
|
Full Source Code
../ding/league/metric.py