The Elo rating system is a method for calculating the relative skill levels of players in zero-sum games. Originally invented by Arpad Elo for chess, it is now the standard for online gaming matchmaking (MMR), football rankings, and board games.
How Elo Calculation Works
The system works by predicting the outcome of a match based on the rating difference between two players. If a high-rated player wins against a low-rated player, their rating increases only slightly. However, if the underdog wins, they receive a significant boost, and the favorite loses an equal amount.
2. New Rating = YourRating + K * (ActualScore – ExpectedScore)
What is the K-Factor?
The K-factor determines how much a single match affects your total rating. A high K-factor (like 32 or 40) means ratings change rapidly, which is great for new accounts trying to find their true skill level. A lower K-factor (like 10) is used for established professional tiers to ensure stability.
Elo Calculation Example
Imagine you have a 1500 rating and you play against an opponent with 1700 rating. Because they are higher ranked, your "Expected Score" is low (about 0.24). If you pull off an upset and win:
Win: You would gain roughly +24 points (with K=32).
Loss: You would only lose roughly -8 points.
function calculateElo() {
var playerRating = parseFloat(document.getElementById("playerRating").value);
var opponentRating = parseFloat(document.getElementById("opponentRating").value);
var k = parseFloat(document.getElementById("kFactor").value);
var actualScore = parseFloat(document.getElementById("outcome").value);
if (isNaN(playerRating) || isNaN(opponentRating)) {
alert("Please enter valid numerical ratings.");
return;
}
// 1. Calculate Expected Score
// Formula: Ea = 1 / (1 + 10^((Rb – Ra) / 400))
var exponent = (opponentRating – playerRating) / 400;
var expectedScore = 1 / (1 + Math.pow(10, exponent));
// 2. Calculate New Rating
// Formula: Ra' = Ra + K * (Sa – Ea)
var ratingChange = k * (actualScore – expectedScore);
var newRating = playerRating + ratingChange;
// Display Results
document.getElementById("eloResults").style.display = "block";
document.getElementById("newRatingDisplay").innerText = Math.round(newRating);
var changeText = ratingChange >= 0 ? "+" + Math.round(ratingChange) : Math.round(ratingChange);
var changeDisplay = document.getElementById("ratingChangeDisplay");
changeDisplay.innerText = changeText;
changeDisplay.style.color = ratingChange >= 0 ? "#27ae60" : "#e74c3c";
var winProbPercent = (expectedScore * 100).toFixed(1) + "%";
document.getElementById("winProbDisplay").innerText = winProbPercent;
}