Skip to content

Instantly share code, notes, and snippets.

@Noxville
Created May 7, 2015 15:41
Show Gist options
  • Save Noxville/249fa126e72c6ef28eb3 to your computer and use it in GitHub Desktop.
Save Noxville/249fa126e72c6ef28eb3 to your computer and use it in GitHub Desktop.
Elo Calculation Snippet
final static double K_WEIGHTING = 64.0
final static double MEAN_RATING = 1000.0
def newRadElo = calculateElo(radElo, direElo, (winner == "Radiant"))
def newDireElo = calculateElo(direElo, radElo, (winner == "Dire"))
double calculateElo(Elo thisTeam, Elo otherTeam, boolean win) {
double diff = (win ? 1.0 : -1.0) * (thisTeam.rating - otherTeam.rating) / 400.00
double _d = 1.0 / (1.0 + Math.pow(10.0, diff))
double _e = K_WEIGHTING * _d
return win ? thisTeam.rating + _e : thisTeam.rating - _e
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment