skillratings

Skillratings allows you to calculate a player's skill instantly, or after tournaments/rating periods, using a variety of well known (and lesser known) skill rating algorithms.
This library is incredibly lightweight, user-friendly, and of course, blazingly fast.

Currently supported algorithms:

These are mainly known from their usage in chess and online games.

Installation

Add the following to your Cargo.toml file:

toml [dependencies] skillratings = "0.13.1"

Basic Usage

Quick disclaimer: Below are the most basic use cases for each supported algorithm, in a 1-vs-1 format.
Each rating algorithm has many more associated functions, for example getting a rating using a list of outcomes, or getting the expected scores of a match.

Head over to the documentation for more information and examples.

Elo rating system

```rust use skillratings::{ elo::elo, outcomes::Outcomes, rating::EloRating, config::EloConfig };

// Initialise a new player rating. let player_one = EloRating::new();

// Or you can initialise it with your own values of course. // Imagine these numbers being pulled from a database. let somerating = 1325.0; let playertwo = EloRating{ rating: some_rating, };

// The outcome of the match is from the perspective of player one. let outcome = Outcomes::WIN;

// The config allows you to specify certain values in the Elo calculation. let config = EloConfig::new();

// The elo function will calculate the new ratings for both players and return them. let (newplayerone, newplayertwo) = elo(&playerone, &playertwo, &outcome, &config); ```

Glicko rating system

```rust use skillratings::{ glicko::glicko, outcomes::Outcomes, rating::GlickoRating };

// Initialise a new player rating. let player_one = GlickoRating::new();

// Or you can initialise it with your own values of course. // Imagine these numbers being pulled from a database. let (somerating, somedeviation) = (1325.0, 230.0); let playertwo = GlickoRating{ rating: somerating, deviation: some_deviation, };

// The outcome of the match is from the perspective of player one. let outcome = Outcomes::WIN;

// The glicko function will calculate the new ratings for both players and return them. let (newplayerone, newplayertwo) = glicko(&playerone, &playertwo, &outcome); ```

Glicko-2 rating system

```rust use skillratings::{ glicko2::glicko2, outcomes::Outcomes, rating::Glicko2Rating, config::Glicko2Config };

// Initialise a new player rating. let player_one = Glicko2Rating::new();

// Or you can initialise it with your own values of course. // Imagine these numbers being pulled from a database. let (somerating, somedeviation, somevolatility) = (1325.0, 230.0, 0.05932); let playertwo = Glicko2Rating{ rating: somerating, deviation: somedeviation, volatility: some_volatility, };

// The outcome of the match is from the perspective of player one. let outcome = Outcomes::WIN;

// The config allows you to specify certain values in the Glicko-2 calculation. let config = Glicko2Config::new();

// The glicko2 function will calculate the new ratings for both players and return them. let (newplayerone, newplayertwo) = glicko2(&playerone, &playertwo, &outcome, &config); ```

TrueSkill rating system

Caution regarding usage of TrueSkill: Microsoft permits only Xbox Live games or non-commercial projects to use TrueSkill(TM). If your project is commercial, you should use another rating system included here.

```rust use skillratings::{ trueskill::trueskill, outcomes::Outcomes, rating::TrueSkillRating, config::TrueSkillConfig };

// Initialise a new player rating. let player_one = TrueSkillRating::new();

// Or you can initialise it with your own values of course. // Imagine these numbers being pulled from a database. let (somerating, someuncertainty) = (34.2, 2.3); let playertwo = TrueSkillRating{ rating: somerating, uncertainty: some_uncertainty, };

// The outcome of the match is from the perspective of player one. let outcome = Outcomes::WIN;

// The config allows you to specify certain values in the TrueSkill calculation. let config = TrueSkillConfig::new();

// The trueskill function will calculate the new ratings for both players and return them. let (newplayerone, newplayertwo) = trueskill(&playerone, &playertwo, &outcome, &config); ```

Weng-Lin rating system

(A Bayesian Approximation Method for Online Ranking)

```rust use skillratings::{ wenglin::wenglin, outcomes::Outcomes, rating::WengLinRating, config::WengLinConfig };

// Initialise a new player rating. let player_one = WengLinRating::new();

// Or you can initialise it with your own values of course. // Imagine these numbers being pulled from a database. let (somerating, someuncertainty) = (41.2, 2.12); let playertwo = WengLinRating{ rating: somerating, uncertainty: some_uncertainty, };

// The outcome of the match is from the perspective of player one. let outcome = Outcomes::WIN;

// The config allows you to specify certain values in the Weng-Lin calculation. let config = WengLinConfig::new();

// The wenglin function will calculate the new ratings for both players and return them. let (newplayerone, newplayertwo) = wenglin(&playerone, &playertwo, &outcome, &config); ```

DWZ (Deutsche Wertungszahl) rating system

```rust use skillratings::{ dwz::dwz, outcomes::Outcomes, rating::DWZRating };

// Initialise a new player rating. // We need to set the actual age for the player, // if you are unsure what to set here, choose something that is greater than 25. let player_one = DWZRating::new(19);

// Or you can initialise it with your own values of course. // Imagine these numbers being pulled from a database. let (somerating, someindex, someage) = (1325.0, 51, 27); let playertwo = DWZRating{ rating: somerating, index: someindex, age: some_age, };

// The outcome of the match is from the perspective of player one. let outcome = Outcomes::WIN;

// The dwz function will calculate the new ratings for both players and return them. let (newplayerone, newplayertwo) = dwz(&playerone, &playertwo, &outcome); ```

Ingo rating system

```rust use skillratings::{ ingo::ingo, outcomes::Outcomes, rating::IngoRating };

// Initialise a new player rating. // We need to set the actual age for the player, // if you are unsure what to set here, choose something that is greater than 25. let player_one = IngoRating::new(19);

// Or you can initialise it with your own values of course. // Imagine these numbers being pulled from a database. let (somerating, someage) = (150.4, 23); let playertwo = IngoRating{ rating: somerating, age: some_age, };

// The outcome of the match is from the perspective of player one. let outcome = Outcomes::WIN;

// The ingo function will calculate the new ratings for both players and return them. let (newplayerone, newplayertwo) = ingo(&playerone, &playertwo, &outcome); ```

License

This project is licensed under the MIT License.