0.4.4 • Published 6 years ago

ratings v0.4.4

Weekly downloads
13
License
MIT
Repository
github
Last release
6 years ago

ratings

Helper module for calculating ELO ratings adjustments and chance

Installation

> npm install ratings --save
> yarn add ratings

Usage

const elo = require('ratings')

// or ES6
import * as elo from 'ratings'

// Return the chance of victory for the
elo.chance(1550 /* home rating */, 1650 /* away rating */);

// Calculate the rating adjustment
elo.adjustment(1550, 1650, -1)

API

chance

Returns the expected chance of victory for each player (0.00 -> 1.00)

interface Chance {
    // Percentages in 0.00 -> 1.00
    white: number
    black: number
}
function chance(whiteRating: number, blackRating: number): Chance

adjustment

See Options interface Returns the adjusted ratings based on the provided result Adjustment and score range can be adjusted in options

// 1: White win, 0: Draw, -1: Black win
type Result = 1 | 0 | -1

interface Adjustment {
    // Ratings after adjustment:
    white: number
    black: number

    // Rating shift applied
    shift: {
        white: number
        black: number
    }
}

function adjustment(whiteRating: number, blackRating: number, result: Result, kFactor: number = 32): Adjustment
0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago