Skip to content

Instantly share code, notes, and snippets.

@antonegas
antonegas / elo.py
Last active February 26, 2026 14:06
Elo rating class in python
class Elo:
def __init__(self, rating: float = 1000.0):
self.rating = rating
def _expected(self, other: Elo) -> float:
"""
Calculates the expected outcome when playing against an other player.
"""
magic_number = 1.0 / 400.0
q1 = 10**(self.rating * magic_number)