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:
- Elo
- Glicko
- Glicko-2
- TrueSkill
- Weng-Lin (Bayesian Approxmation Method)
- DWZ (Deutsche Wertungszahl)
- Ingo
These are mainly known from their usage in chess and online games.
Installation
Add the following to your Cargo.toml file:
[]
= "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
use ;
// Initialise a new player rating.
let player_one = new;
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let some_rating = 1325.0;
let player_two = EloRating;
// The outcome of the match is from the perspective of player one.
let outcome = WIN;
// The config allows you to specify certain values in the Elo calculation.
let config = new;
// The elo function will calculate the new ratings for both players and return them.
let = elo;
Glicko rating system
use ;
// Initialise a new player rating.
let player_one = new;
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let = ;
let player_two = GlickoRating;
// The outcome of the match is from the perspective of player one.
let outcome = WIN;
// The glicko function will calculate the new ratings for both players and return them.
let = glicko;
Glicko-2 rating system
use ;
// Initialise a new player rating.
let player_one = new;
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let = ;
let player_two = Glicko2Rating;
// The outcome of the match is from the perspective of player one.
let outcome = WIN;
// The config allows you to specify certain values in the Glicko-2 calculation.
let config = new;
// The glicko2 function will calculate the new ratings for both players and return them.
let = glicko2;
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.
use ;
// Initialise a new player rating.
let player_one = new;
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let = ;
let player_two = TrueSkillRating;
// The outcome of the match is from the perspective of player one.
let outcome = WIN;
// The config allows you to specify certain values in the TrueSkill calculation.
let config = new;
// The trueskill function will calculate the new ratings for both players and return them.
let = trueskill;
Weng-Lin rating system
(A Bayesian Approximation Method for Online Ranking)
use ;
// Initialise a new player rating.
let player_one = new;
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let = ;
let player_two = WengLinRating;
// The outcome of the match is from the perspective of player one.
let outcome = WIN;
// The config allows you to specify certain values in the Weng-Lin calculation.
let config = new;
// The weng_lin function will calculate the new ratings for both players and return them.
let = weng_lin;
DWZ (Deutsche Wertungszahl) rating system
use ;
// 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 = new;
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let = ;
let player_two = DWZRating;
// The outcome of the match is from the perspective of player one.
let outcome = WIN;
// The dwz function will calculate the new ratings for both players and return them.
let = dwz;
Ingo rating system
use ;
// 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 = new;
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let = ;
let player_two = IngoRating;
// The outcome of the match is from the perspective of player one.
let outcome = WIN;
// The ingo function will calculate the new ratings for both players and return them.
let = ingo;
License
This project is licensed under the MIT License.