Skip to main content

No project description provided

Project description

Overview

This library is designed to rank randomizer racers. It's based on the Glicko-2 rating system with some experimental modifications. You can read about Mark Glickman's Glicko-2 system here. The multiplayer implementation was partially borrowed from ms2300's implementation.

Usage

You can install RandoRank as a python package with pip by running pip install randorank. The first thing you'll want to do is determine a period length(e.g. four weeks) and a set of constants to use for your game/category.

To use this library to rank randomizer players, you can instantiate a MultiPeriod class, set the system variables with the add_constants() method, add races with the add_races() method, then export a dictionary of players with their ranking with the rank() method. When a period has concluded, you can feed this dict into a new MultiPeriod instance with the add_players() method and continue ranking.

Setting Constants and Multiplayer Glicko Implementation

The MultiPeriod class will initialize with a default set of constants designed for the A Link to the Past Randomizer. To set your own constants, create a dict with the following keys:

example_constants = {'tau': .02,
                     'multi_slope': .008,
                     'multi_cutoff': 8,
                     'norm_factor': 1.3
                     'victory_margin': 600
                     'initial_rating': 1500,
                     'initial_deviation': 300,
                     'initial_volatility': .22}

a MultiPeriod has an attribute MultiPeriod.constants with these values as a dict. There are also set_[constant name] methods for each of these individually. tau is the Glicko system constant. For randomizer races, it should be set low, around .02. multi_slope, multi_cutoff, and norm_factor are part of the multiplayer implementation, which divides races into a series of 1v1 matches and applies a weight based on race size and how close two racers finished compared to each other and the distribution of times in the race.

The cutoff determines how many runners a race must have for the library to use the multiplayer implementation. Below that, it will use the stock Glicko formula. The normalization factor is used to determine a "floor" time for the race and is game-specific. The formula for scoring a normalized race is first_quartile + (IQR * norm_factor). Times in between are assigned a value between 0 and 1, 1 being the first place finisher. To determine a normalization factor for your game or category, you should experiment with different values for multiple races and use your best judgement to figure out which value gives the best floor time. Since this formula is less accurate with less racers, we use the cutoff to prevent it from skewing final rankings. The slope is used later as part of the formula for determining a 1v1's weight.

In races above the cutoff, we take the original weight and multiply it by the result of the following:

let normed_diff = the absolute value of the difference between the two players'
normalized scores

1 - (multi_slope * (size ** (1 - abs(normed_diff)))) * (1 / (1 - multi_slope))

This generally means that the bigger the race, and the closer the two runners' finish times, the lower the weight for their 1v1. But no matter the race size, top finishers' scores against the very bottom will remain the same.

For races below the cutoff, we use the "victory margin" in seconds to calculate a weight for each 1v1. When this value is 600 seconds, or 10 minutes, a different in times of ten minutes or more gives full weight to the 1v1. Below that, the difference is scaled for a weight between 100 and 85%. The closer the finish, the less weight is given to the 1v1.

To determine the best variables for your game or category, you'll want to look at the sorted results over several periods as well as the distribution of final ratings. Make sure the final rankings look reasonably accurate that. The distribution of scores should be somewhere between normal and right-skewed. Experiment using different values for the same data set.

Adding Races

Races are passed to the add_races() method as a list of dictionaries with names as keys and times (in seconds) as values. If a runner does not finish a race, their value should be NaN. You can set NaN values in python by importing the type from the math module(from math import nan). Suppose you want to add a race with three runners, one of whom forfeited. You would pass this dictionary:

from math import nan

example_period = MultiPeriod()
example_race = {'runner 1': 1563,
                'runner 2': 1620,
                'runner 3': nan}
example_period.add_races([example_race])

It's important that you convert all non-finishers to NaN and don't use a number like 0. NaN is a special numerical type indicating that the value is "not a number." One way to do this is applying a dictionary comprehension:

filtered_example_race = {k: math.nan if v is None else v for k, v in race.items()}

End of Period Rankings

Using the rank() method of the MultiPeriod instance will export a dictionary of dictionaries containing each runner's rating, deviation, volatility, inactive periods, variance, and delta for the end of the period. The latter three values can be discarded if you're done ranking players. If you want to continue ranking over multiple periods, you can pass this to the add_players() method of a new MultiPeriod instance.

(Experimental) If you want to calculate new mid-period with a dict of mid- period rankings and some races you'd like to add to that period you can:

  1. Pass end=False to the rank() method to get mid-period data including each player's variance and delta.
  2. Instantiate a new MultiPeriod.
  3. Take the runners who have participated only in the race(s) you want to add.
  4. Combine their pre-period rating, deviation and volatility with their mid-period variance and delta values in a dictionary.
  5. Pass this dict with only the new runners to the add_players() method of the new period.
  6. Add the new races with add_races() then rank(end=True) (the default argument to end is True.)

This will produce a rankings dict containing values for the runners in the added races. You can add them back to the first ranking dict, but make sure to zero out the delta and variance values any time you are calculating from the beginning of the period as these numbers contain information about races which was already calculated, so you will end up counting some races more than once if you don't.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

RandoRank-0.1.3.tar.gz (462.2 kB view details)

Uploaded Source

Built Distributions

RandoRank-0.1.3-cp38-none-win_amd64.whl (111.2 kB view details)

Uploaded CPython 3.8Windows x86-64

RandoRank-0.1.3-cp38-cp38-manylinux1_x86_64.whl (137.9 kB view details)

Uploaded CPython 3.8

RandoRank-0.1.3-cp38-cp38-macosx_10_7_x86_64.whl (124.4 kB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

RandoRank-0.1.3-cp37-none-win_amd64.whl (111.2 kB view details)

Uploaded CPython 3.7Windows x86-64

RandoRank-0.1.3-cp37-cp37m-manylinux1_x86_64.whl (137.9 kB view details)

Uploaded CPython 3.7m

RandoRank-0.1.3-cp37-cp37m-macosx_10_7_x86_64.whl (124.4 kB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

RandoRank-0.1.3-cp36-none-win_amd64.whl (111.3 kB view details)

Uploaded CPython 3.6Windows x86-64

RandoRank-0.1.3-cp36-cp36m-manylinux1_x86_64.whl (138.0 kB view details)

Uploaded CPython 3.6m

RandoRank-0.1.3-cp36-cp36m-macosx_10_7_x86_64.whl (124.6 kB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

RandoRank-0.1.3-cp35-none-win_amd64.whl (111.3 kB view details)

Uploaded CPython 3.5Windows x86-64

RandoRank-0.1.3-cp35-cp35m-manylinux1_x86_64.whl (138.0 kB view details)

Uploaded CPython 3.5m

File details

Details for the file RandoRank-0.1.3.tar.gz.

File metadata

  • Download URL: RandoRank-0.1.3.tar.gz
  • Upload date:
  • Size: 462.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.7.8

File hashes

Hashes for RandoRank-0.1.3.tar.gz
Algorithm Hash digest
SHA256 397f74b8139d3243246cace37a6e0bccb9188dddd68540f40ce53ab3e4c33e77
MD5 ec7a4a69746a722d396499d4d5454aa2
BLAKE2b-256 7780c06e5824f05b617f4e80301f507a14095281b2a41582371b119e1ba36947

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp38-none-win_amd64.whl.

File metadata

  • Download URL: RandoRank-0.1.3-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 111.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.7.8

File hashes

Hashes for RandoRank-0.1.3-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 dcd6c5b948789f3cdcfe6aad4f9f39ee761cc012d98d776ebbfb3c074de2881a
MD5 823b5d289e80abdbcdf0d961647d6a54
BLAKE2b-256 2b63439d7b951c3ab7fcc4f5fbf13fc200d5c683f813735f1a1e788f3ee1ff69

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for RandoRank-0.1.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8df6c53fe8c7a127b29f2fa9441c980758c50ab3d0b2b7db5162975e1557bd5d
MD5 417fb7af131f307e4c3ddf749655c9ef
BLAKE2b-256 6dcd5b4cac20fd4528773eccb3719002f218594b0e04b9160a885c8007ae4122

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for RandoRank-0.1.3-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 feda7d1912c7cd2aee1c5978d046d6a2443747579da8d619b3bdea0d7728c4c8
MD5 4946cd17dad05b2567e57f24a8b0b3ae
BLAKE2b-256 2bf22502a1a68d4452ade69d36789019b160f75f2fea1e3e66811b9ee63153dc

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp37-none-win_amd64.whl.

File metadata

  • Download URL: RandoRank-0.1.3-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 111.2 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.7.8

File hashes

Hashes for RandoRank-0.1.3-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 bed4a7303ea7537f59578b405336d298c6256dbba6c5334fce3b470cb9ca1502
MD5 733e437c54804f866d63ed15059fa843
BLAKE2b-256 1c88955101ff1563e27a29829c6db5fb1ad93d62ac0d4f05d0c0258641b54236

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for RandoRank-0.1.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 15540506e2b67de12b950f4f6163cf4cf48b6688c68e85f6425f5b5d24e26a68
MD5 8bf886adeda99a652c541d29ba8bca68
BLAKE2b-256 13ddd7511f2adb69d1529f2df349f17ff326c10c23e58b596b01d3ed188d5e4c

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for RandoRank-0.1.3-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 daf069943687a061a4fc87b5e7887b4f307b59384ad4b4a1061fca9d81cc1418
MD5 f385006cce94acf6ae7f4c2854538ef8
BLAKE2b-256 32f8c980dd725473e79c429ae75be39ed74183d3d9dba8018dad10917df46efd

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp36-none-win_amd64.whl.

File metadata

  • Download URL: RandoRank-0.1.3-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 111.3 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.7.8

File hashes

Hashes for RandoRank-0.1.3-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 3be12bdc63c766c76667245a3279c30fd299a6b93cab6bc4d2eb116f2a7c616d
MD5 c906058ccf4d97e4fa5eecfbf3d7ce7f
BLAKE2b-256 a93a2fcd1130e2e47ac3d9031fc290ffdc327ff961eec0571490ab25ec73446f

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for RandoRank-0.1.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7cd2e4e1e513cc8a414a29fd383441cbc3bbed34272b8d135fb583756a5e7afc
MD5 36f372259f9608fdc290adcd3699b896
BLAKE2b-256 2ea1a2b1521037e6463e56078f34e62ad940667bf7548cf10ab3361e06f57adf

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for RandoRank-0.1.3-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 c8e0eb415b1e11228bb2304751d56893240f7dafdf86ec53b596edaa4bf3de85
MD5 9b9600356176d092af25963d2917f4dd
BLAKE2b-256 25ad309dd41e21a3d2f70c5be15b970b37145bece9158c4fa4581f5ea99a68a8

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp35-none-win_amd64.whl.

File metadata

  • Download URL: RandoRank-0.1.3-cp35-none-win_amd64.whl
  • Upload date:
  • Size: 111.3 kB
  • Tags: CPython 3.5, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.7.8

File hashes

Hashes for RandoRank-0.1.3-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 4f908ef31207fd399eb8763909081a61d3e5515f7fa1c2a936565d665419cfff
MD5 384b948c307be945fafd109034470290
BLAKE2b-256 2f890ed5742248eaa61fc183f7ab88d3075d9fbd0db97a17a2e5993f58996beb

See more details on using hashes here.

File details

Details for the file RandoRank-0.1.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for RandoRank-0.1.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 00ff29e29b8aa8a6f13c2af0c75bb54f586d99ebc04eb69f03c9f3dbe04d11d9
MD5 a12d2d4c68624830b90acb67ec44d558
BLAKE2b-256 cc28d3d627bf5bcf0aa8890d0f1928edf770672e6f628e990d265d77ce58044d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page