It is an excellent method for calculating relative skill levels of players represented as numeric values.
- Consider a PvP match b/w two players, player A and player B.
- Player A has ELO rating
$R_a$ and player B has ELO rating$R_b$ . - ELO ratings of individual players reflect their relative skill levels based on performance in past matches.
- Now, a player defeating a much weaker player is not the same as defeating a much more stronger player. ELO rating takes this into account and is reflected in updated ratings of both players.
- After each match, ELO rating of both players is updated based on a formula.
- Originally, it only considers the outcome of a match.
where,
- It determines how much influence each match can have on the ELO ratings of the players.
- It can be varied according to matches, leagues, competitions, player rating levels, etc.
- Generally, can be set to
$32$ .
- Represents whether a player won or lost or drawn the match.
- Generally, it takes one of the three values:
-
$1$ for a win -
$0$ for a loss -
$0.5$ for a draw - i.e.
$S_{a} \in [0, 1]$
-
- This is where magic of ELO ratings happen.
- It represents the probability that the player will win a match.
- It is calculated based on ELO ratings of two players.
- Formula:
On solving by substituting values of
- As
$0 \leq S_a \leq 1$ and$0 \leq E_a \leq 1$ , maximum change in a player's rating can be$K$ .
- It is the rating that a new player has when he starts playing the game.
- It must be significantly larger than
$K$ factor, to allow a player to play, and lose enough matches before eventually winning matches, so that his ELO rating would finally start rising up. - Generally, can be set to
$1000$ .
- Consider a game, where the only thing which matters is not just the outcome of game, i.e. win or loss.
- Let's say:
- In 1st game, player A won over player B by 5-1 score.
- In second game player C won over player B by 2-1 score.
- In this scenario, player A had a much more dominant win than player C.
- Thus, player A much have a better rating inrease than player C.
- In this, we are considering the effect of points scored by individual players on the change in rating.
- We only consider the fact whether the player has won or lost or drawn the match.
- This is same as original ELO Rating.
- We replace
$S_a$ with the fraction of points scored by player A divided by total score. - i.e.,
where,
- This is more intuitive and we don't need to update the main rating change formula.
- But, it gives less control and predictability on the rating change.
- In this, we keep
$S_a$ same as outcome of match, i.e.,$S_a \in$ {$0, 0.5, 1$ }. - And we extend rating update formula with another scaling factor to which acts as a bonus for the amount of scored points.
- New Formula:
where,
-
$L$ can be set to 16, and can be varied as well. - This method is less intuitive, but gives much more control and predictability of the ratings.
- Using this, maximal change that a rating can have is
$K + L$ .
- I have implemented all of the above formulas in ELO class in Python and Java.
- It has a constructor and two public methods.
- constructor(): To create an instance of class ELO
- elo(): It can be called after a match with ratings of both players and match result. It returns the updated ratings of the players.
- elo_with_points(): It is similar to elo(), but this is with consideration of points scored by the two players.
- It takes 3 arguments:
- k_factor: Value of
$K$ factor. (int, default$32$ ) - c_value: Value of
$c$ number. (int, default$400$ ) - l_factor: Value of
$L$ factor. (int, default$16$ )
- k_factor: Value of
- Constructor instantiates an object of ELO class with given parameters.
- In practice, it can be called multiple times for different leagues, arenas, matches, championships, competitions, etc.
- This is the rating update function which only considers the outcome of a match.
- It takes 4 arguments:
- rating_a: Current rating of player A. (float)
- rating_b: Current rating of player B. (float)
- outcome: Outcome of a match. (int)
- outcome must
$\in$ {0, 1, 2} where,- outcome = 0
$\implies$ Match is drawn - outcome = 1
$\implies$ Player A won the match - outcome = 2
$\implies$ Player B won the match
- outcome = 0
- It returns the new ratings of the players in the form of tuple/array of float point numbers. e.g. (1400.0, 1550.0)
- It must be called after a match with the required parameters to get the new ratings of the players.
- This is the rating update formula which takes into consideration the individual points scored by the players.
- It takes 5 arguments:
- rating_a: Current rating of player A. (float)
- rating_b: Current rating of player B. (float)
- points_a: Points scored by player A. (float)
- points_b: Points scored by player B. (float)
- method: Method to use for consideration of points scored. (int, default 2)
- method must
$\in$ {0, 1, 2} where,- method = 0
$\implies$ Just consider the outcome of a match. - method = 1
$\implies$ Consider fraction of points at the place of$S_a$ . - method = 2
$\implies$ Uses the L factor for consideration of points.
- method = 0
- It returns the new ratings of the players in the form of tuple/array of float point numbers. e.g. (1400.0, 1550.0)
- It must be called after a match with the required parameters to get the new ratings of the players.
- Python: No extra libraries used.
- Java: No extra libraries used.
- ELO.py: Python implementation of ELO class.
- ELO.java: Java implementation of ELO class.