@serpentine/glicko2
v1.0.1
Published
Glicko2 rating system
Downloads
4
Readme
glicko2
A javascript implementation of the glicko2 rating system.
Motivation
Existing javascript implementations seemed to be either outdated, overly complicated, or extremely inefficient (lots of recalculated values). This package is meant to solve these problems. The package itself is tiny (< 100 SLOC), has no dependencies, and is extremely readable (it should be quite easy to read the source code side-by-side with the official specs).
Installation
npm install @serpentine/glicko2
Note: This package was mainly created for Serpentine, but should be useable anywhere.
Usage
const glicko2 = require('glicko2');
// Object represention of a player whose rating we want to update
const player = {
rating: 1500,
rd: 200,
volatility: 0.06,
};
// Initialize the System Constant (tau) and Convergence Tolerance (epsilon)
// This example shows the defaults.
glicko2.init({
systemConstant: 0.3,
convergenceTolerance: 0.000001,
});
// Update the player based on a batch of results (the rating period).
// This updates the player object in place.
glicko2.update(player, [
{
rating: 1400,
rd: 30,
score: 1,
},
{
rating: 1550,
rd: 100,
score: 0,
},
{
rating: 1700,
rd: 300,
score: 0,
},
]);