BattleSim/server/elo.coffee

14 lines
376 B
CoffeeScript
Raw Normal View History

2016-02-01 22:19:30 +00:00
elo = require('elo-rank')()
createPlayer = ->
{rating: 1000}
calculate = (player, matches, options = {}) ->
playerRating = player.rating
for {opponent, score} in matches
expected = elo.getExpected(playerRating, opponent.rating)
playerRating = elo.updateRating(expected, score, playerRating)
{rating: playerRating}
module.exports = {createPlayer, calculate}