11 lines
326 B
JavaScript
11 lines
326 B
JavaScript
|
// elo.js
|
||
|
function calculateElo(currentRating, opponentRating, actualScore, kFactor = 32) {
|
||
|
const expectedScore = 1 / (1 + Math.pow(10, (opponentRating - currentRating) / 400));
|
||
|
const newRating = currentRating + kFactor * (actualScore - expectedScore);
|
||
|
return newRating;
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
calculateElo,
|
||
|
};
|