Out of interest I implemented a very basic ELO rating system. It yields the same results as my friends recent tournament on the FIDE website, nice.
Currently has no dependencies. To install any future ones just use uv:
$ uv pip install -r pyproject.tomlSee elo.py file and docstrings for more information. There are also batch methods that allow you to calculate a tournament setting slightly more easily.
import elo
u = create_user()
u.assign_rating(elo.INITIAL_RATING)
v = create_user()
v.assign_rating(elo.INITIAL_RATING)
# u and v play against 5x each other, outcomes are as follows:
game_outcomes = [GameOutcome.DRAW, GameOutcome.PLAYER_1_WIN, GameOutcome.PLAYER_2_WIN, GameOutcome.DRAW, GameOutcome.PLAYER_1_WIN]
# update ratings
for outcome in game_outcomes:
update_result = elo.calculate_elo(u.rating, v.rating, outcome)
u.assign_rating(update_result.player_1_elo)
v.assign_rating(update_result.player_2_elo)
print(f"Player u rating: {u.rating}")
print(f"Player v rating: {v.rating}")