Skip to content

JanEbbing/elo_rating_implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ELO Rating system implementation

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.

Installation

Currently has no dependencies. To install any future ones just use uv:

$ uv pip install -r pyproject.toml

Usage

See 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}")

About

Toy implementation of an elo rating system (like in chess)

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages