Various chess rating systems
Project description
Chessratings
A python implementation of official chess rating systems, as used by organizations such as the US Chess Federation (USCF) to rate player strength.
Currently available modules are:
- US Chess Federation (ELO): http://www.glicko.net/ratings/rating.system.pdf
Installation
Available in PyPi.
pip install chessratings
Usage
To use the chessratings package, import your module of choice into your python script:
from chessratings import uscf_elo
There are a few important concepts to know when using this package: Players and Tournaments.
A Player is a rated entity that can participate in a game/match against other Players. Players are initiated with, at minimum, the following information:
- id: an identifier such as a name
- rating: their most recent rating, if known
Additional optional arguments may vary by module and can be found in the source code.
example_player_1 = uscf_elo.Player(id='player_1', rating=1600)
example_player_2 = uscf_elo.Player(id='player_2', rating=1500)
A Tournament is a match or series of matches between two or more players. As per the official specifications, player ratings are updated after a Tournament is concluded.
A Tournament requires two arguments:
- players: a list of participating Player entities
- tournament_results: a summary of tournament results
The tournament_results must be provided in the following format:
[
[ ( player_1_id, player_2_id ), winner_id ],
[ ( ... ) ],
]
If the match was a draw, winner_id can be set to null (or any value other than one of the two player IDs). Here's an example:
players = [example_player_1, example_player_2]
tournament_results = [
[ ( 'player_1', 'player_2' ), 'player_2'],
[ ( 'player_1' ,'player_2' ), 'player_1'],
[ ( 'player_1', 'player_2' ), np.nan ]
]
tournament = uscf_elo.Tournament(players, tournament_results)
Running the tournaments will update player ratings, and optionally output summarized information about the tournament results.
tournament_results = tournament.run()
print(tournament_results)
Tournament results are presented as: player id, tournament date, tournament number, number of tournament games, number of wins, number of draws, number of losses, updated rating
[
['player_1', datetime.date(2021, 5, 20), 1, 3, 1, 1, 1, 1584.0954259202883],
['player_2', datetime.date(2021, 5, 20), 1, 3, 1, 1, 1, 1517.178456181353]
]
Contributing
If you would like to help develop this package, along with the tools you need to develop and run tests, run the following in your virtualenv:
$ pip install -e .[dev]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file chessratings-0.0.1.tar.gz
.
File metadata
- Download URL: chessratings-0.0.1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bff95304b21c738ce5a6be0d87c37a61449592bb31f16fa989119106bd2f1e3 |
|
MD5 | 4d41107057609818cee54b0eb29d0b23 |
|
BLAKE2b-256 | 63199461936f1c7532af0af2955142ae1ae50a621f810235bafcc86b5f43bfe1 |
File details
Details for the file chessratings-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: chessratings-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 458f5d6c4fab2775579374cec65806ec9d24d39965acad58d01004d670f1c316 |
|
MD5 | 68697cf9d64662779b8c9e715d012695 |
|
BLAKE2b-256 | 8e9b87f10c2c4cbfef45a3b3aea09b1bbc7e7da1ff533ef099e01a566ce10d02 |