Minimalistic Javascript implementation of a Elo rating system. K-factor of 32 is used.
- Include
elo.js
- Use
Elo.getNewRating()
to calculate the new rating, orElo.getRatingDelta()
to calculate the delta.
Calculates my new rating given the following parameters:
myRating (number)
- My rating before the game, e.g. 1600opponentRating (number)
- Opponent's rating before the game, e.g. 1700myGameResult (number)
- The result of the game,1
if I won,0
if I lost, or0.5
if draw
Elo.getNewRating(1600, 1700, 1) // => 1620
Elo.getNewRating(1600, 1700, 0.5) // => 1604
Elo.getNewRating(1600, 1700, 0) // => 1588
Calculates my new rating given the following parameters:
myRating (number)
- My rating before the game, e.g. 1600opponentRating (number)
- Opponent's rating before the game, e.g. 1700myGameResult (number)
- The result of the game,1
if I won,0
if I lost, or0.5
if draw
Elo.getRatingDelta(1600, 1700, 1) // => 20
Elo.getRatingDelta(1600, 1700, 0.5) // => 4
Elo.getRatingDelta(1600, 1700, 0) // => -12