Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Glicko2

The main class of the rating system

Hierarchy

  • Glicko2

Index

Constructors

  • new Glicko2(settings?: { rating: number; rd: number; tau: number; vol: number; volatilityAlgorithm: any }): Glicko2
  • Parameters

    • settings: { rating: number; rd: number; tau: number; vol: number; volatilityAlgorithm: any } = ...
      • rating: number

        Base rating

        default

        1500

      • rd: number

        Base rating deviation

        default

        350

      • tau: number

        The system constant, which constrains the change in volatility over time

        default

        0.5

      • vol: number

        Base volatility The volatility measure indicates the degree of expected fluctuation in a player’s rating

        default

        0.06

      • volatilityAlgorithm:function
        • volatilityAlgorithm(v: number, delta: number, __namedParameters: volatilityArgs): number

    Returns Glicko2

Properties

_default_rating: number

Internal default rating in glicko format for new players

_default_rd: number

Internal default rating deviation for new players

_default_vol: number

Internal default volatility for new players

_tau: number

Internal default tau value for new players

_volatilityAlgorithm: (v: number, delta: number, __namedParameters: volatilityArgs) => number

Type declaration

    • The internal default volatility algorithm used by the Glicko2 object when making new players

      Parameters

      Returns number

players: Record<string, Player> = {}

An object of all the players cached with their key as their id

default

{}

players_index: number = 0

The number of players in the record

default

0

Methods

  • _createInternalPlayer(rating?: number, rd?: number, vol?: number, id?: number): Player
  • addMatch(player1: { id: number; rating: number; rd: number; vol: number }, player2: { id: number; rating: number; rd: number; vol: number }, outcome: number): { pl1: Player; pl2: Player }
  • Creates players and match result to be taken in account for the new rankings calculation players must have ids, they are not created if it has been done already.

    Parameters

    • player1: { id: number; rating: number; rd: number; vol: number }

      The first player

      • id: number
      • rating: number
      • rd: number
      • vol: number
    • player2: { id: number; rating: number; rd: number; vol: number }

      The second player

      • id: number
      • rating: number
      • rd: number
      • vol: number
    • outcome: number

      The outcome for the first player: 0 = defeat, 1 = victory, 0.5 = draw

    Returns { pl1: Player; pl2: Player }

    An object of the new player objects

  • addResult(player1: Player, player2: Player, outcome: number): void
  • Add a match result to be taken in account for the new rankings calculation

    Parameters

    • player1: Player

      The first player

    • player2: Player

      The second player

    • outcome: number

      The outcome of the first player : 0 = defeat, 1 = victory, 0.5 = draw

    Returns void

  • calculatePlayersRatings(): void
  • cleanPreviousMatches(): void
  • Removes all of the previous matches from each of the players objects

    Returns void

  • getPlayers(): Record<string, Player>
  • makePlayer(rating?: number, rd?: number, vol?: number): Player
  • Creates a new Player and adds it to the cache We do not expose Glicko2._createInternalPlayer directly in order to prevent the assignation of a custom player id whose uniqueness could not be guaranteed

    Parameters

    • Optional rating: number
    • Optional rd: number
    • Optional vol: number

    Returns Player

    A Player object of the new player

  • removePlayers(): void
  • Gets all the matches from the race(if is an instance of one), calculates player ratings

    example
    Glicko2.updateRatings([
    [Player1, Player2, 1],
    [Player2, Player4, 0],
    [Player3, Player1, 1],
    [Team1, Team2, 0],
    race
    ]);

    Parameters

    Returns void