glicko2
raw JSON → 2.1.0 verified Sat May 09 auth: no python
A Python implementation of the Glicko-2 rating system, used for ranking players in games like chess or esports. Current version 2.1.0, requires Python >=3.7. Maintained, release cadence irregular.
pip install glicko2 Common errors
error AttributeError: module 'glicko2' has no attribute 'Player' ↓
cause Common mistake: importing the module instead of the class.
fix
Use 'from glicko2 import Player' instead of 'import glicko2'.
error TypeError: update_player() missing 1 required positional argument: 'scores' ↓
cause Calling update_player with only opponent list, missing scores list.
fix
Provide both opponent list and scores list, e.g., update_player([opponent], [1.0]) for a win.
error ValueError: The ratings list must contain at least 1 opponent ↓
cause Passing an empty list to update_player.
fix
Ensure opponents list is non-empty before calling update_player.
Warnings
gotcha The Player.update_player() method modifies the player in place; it does not return a new Player object. ↓
fix Call update_player and then access the updated attributes on the same object.
gotcha If you pass an empty list of opponents to update_player, the player's rating will drift toward the mean, which can cause unexpected rating changes. ↓
fix Only call update_player with non-empty opponent lists and corresponding scores.
deprecated The function glicko2.glicko2() is deprecated in favor of the Player class interface. Direct function usage may be removed in future versions. ↓
fix Use the Player class and its update_player method instead.
Imports
- Player wrong
import glicko2correctfrom glicko2 import Player
Quickstart
from glicko2 import Player
# Initialize with default rating (1500), rating deviation (200), volatility (0.06)
p1 = Player()
p2 = Player()
# Simulate a match: p1 wins
p1.update_player([p2], [1.0])
p2.update_player([p1], [0.0])
print(p1.rating, p1.rd, p1.vol)
print(p2.rating, p2.rd, p2.vol)