Created
July 7, 2013 06:39
-
-
Save mkuklis/5942570 to your computer and use it in GitHub Desktop.
elo rating
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function elo(oldRating, opponentRating, result) { | |
var kFactor; | |
var expected = 1.0 / (1.0 + Math.pow(10.0, ((opponentRating - oldRating) / 400))); | |
if (oldRating < 2100) { | |
kFactor = 32; | |
} else if (oldRating >= 2100 && oldRating <= 2400) { | |
kFactor = 24; | |
} | |
else if (oldRating > 2400) { | |
kFactor = 16; | |
} | |
return oldRating + kFactor * (result - expected); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment