Created
January 16, 2011 02:19
-
-
Save ecto/781478 to your computer and use it in GitHub Desktop.
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 adjust(ratings) { | |
ratings[0] = ratings[0] ? parseFloat(ratings[0]) : 1000; | |
ratings[1] = ratings[1] ? parseFloat(ratings[1]) : 1000; | |
var winnerExpected = 1 / (1 + (Math.pow(10,(ratings[1] - ratings[0]) / 400))); | |
var loserExpected = 1 / (1 + (Math.pow(10,(ratings[0] - ratings[1]) / 400))); | |
var k = 30; | |
var winnerAdjustment = Math.round(ratings[0] + (k * (1 - winnerExpected))); | |
var loserAdjustment = Math.round(ratings[1] + (k * (0 - loserExpected))); | |
return [winnerAdjustment, loserAdjustment]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment