Skip to main content

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:

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]

Release files for chessratings 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chessratings 0.0.1
File Size Uploaded
chessratings-0.0.1.tar.gz 12.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chessratings 0.0.1
File Interpreter ABI Platform
chessratings-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / chessratings-0.0.1.tar.gz

Download URL chessratings-0.0.1.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2bff95304b21c738ce5a6be0d87c37a61449592bb31f16fa989119106bd2f1e3
BLAKE2b-256 checksum
How to use checksums
63199461936f1c7532af0af2955142ae1ae50a621f810235bafcc86b5f43bfe1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / chessratings-0.0.1-py3-none-any.whl

Download URL chessratings-0.0.1-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
458f5d6c4fab2775579374cec65806ec9d24d39965acad58d01004d670f1c316
BLAKE2b-256 checksum
How to use checksums
8e9b87f10c2c4cbfef45a3b3aea09b1bbc7e7da1ff533ef099e01a566ce10d02
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page