Skip to content

Instantly share code, notes, and snippets.

@ecto
Created January 16, 2011 02:19
Show Gist options
  • Save ecto/781478 to your computer and use it in GitHub Desktop.
Save ecto/781478 to your computer and use it in GitHub Desktop.
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