Skip to main content
Module

x/glicko2/deno_dist/index.ts>Glicko2

🎖️ Implementation of the Glicko-2 rating system in Typescript
Latest
class Glicko2
import { Glicko2 } from "https://deno.land/x/glicko2@v1.3.2/deno_dist/index.ts";

The main class of the rating system

Constructors

new
Glicko2(settings?: { tau: number; rating: number; vol: number; rd: number; volatilityAlgorithm: (
v: number,
delta: number,
unnamed 2: volatilityArgs,
) => number; }
)

Properties

private
_default_rating

Internal default rating in glicko format for new players

private
_default_rd

Internal default rating deviation for new players

private
_default_vol

Internal default volatility for new players

private
_tau

Internal default tau value for new players

private
_volatilityAlgorithm: (
v: number,
delta: number,
unnamed 2: volatilityArgs,
) => number

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

private
players: Record<string, Player>

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

private
players_index: number

The number of players in the record

Methods

private
_createInternalPlayer(
rating?: number,
rd?: number,
vol?: number,
id?: number,
)
addMatch(
player1: { rating: number; rd: number; vol: number; id: number; },
player2: { rating: number; rd: number; vol: number; id: number; },
outcome: matchResult | 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.

addResult(
player1: Player,
player2: Player,
outcome: matchResult | number,
): void

Add a match result to be taken in account for the new rankings calculation

Updates the ratings for all the players

Removes all of the previous matches from each of the players objects

getPlayers(): Record<string, Player>

Gets an array of matches between 2 teams and their composite player object

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

makeRace(results: Player[][]): Race

Removes all the players from the cache

updateRatings(matches: (playerMatch | Race | teamMatch)[]): void

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