More info can be found here http://en.wikipedia.org/wiki/Elo_rating_system#Mathematical_details.
-
-
Save mkuklis/5942586 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( | |
a, // old rating | |
b, // opponent rating | |
c, // result 0 - lost 0.5 - draw 1 - win | |
e, // expected probability | |
k // k-factor | |
){ | |
e = 1 / (1 + Math.pow(10, ((b - a) / 400))); // calculate probability | |
// find k-factor | |
if (b < 2100) k = 32; | |
else if (b >= 2100 && b <= 2400) k = 24; | |
else if (b > 2400) k = 16; | |
return b + k * (c - e); // return new 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(a,b,c,e,k){e=1/(1+Math.pow(10,((b-a)/400)));if(b<2100)k=32;else if(b>=2100&&b<=2400)k=24;else if(b>2400)k=16;return b+k*(c-e)} |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
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
{ | |
"name": "elo", | |
"description": "Elo rating calculation", | |
"keywords": [ | |
"game", | |
"elo", | |
"rating", | |
"calculation" | |
] | |
} |
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
<!DOCTYPE html> | |
<title>Foo</title> | |
<div>Expected value: <b>1316</b></div> | |
<div>Actual value: <b id="ret"></b></div> | |
<script> | |
var elo = function(a,b,c,e,k){e=1/(1+Math.pow(10,((b-a)/400)));if(b<2100)k=32;else if(b>=2100&&b<=2400)k=24;else if(b>2400)k=16;return b+k*(c-e)} | |
document.getElementById( "ret" ).innerHTML = elo(1300, 1300, 1); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Allow me to be your caddy for this code golf: