Module skillratings::elo

source ·
Expand description

The Elo algorithm, the most widespread rating system and the gold-standard in chess and other games.
Used in the official FIDE chess ratings, many online games, and the basis of even more rating systems.

The higher the Elo rating number, the stronger the player. Compared to other rating algorithms, Elo ratings are relatively static, but very transparent and simple to calculate.

Quickstart

This is the most basic example on how to use the Elo Module.
Please take a look at the functions below to see more advanced use cases.

use skillratings::{
    elo::{elo, EloConfig, EloRating},
    Outcomes,
};

// Initialise a new player rating with a rating of 1000.
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 some_rating = 1325.0;
let player_two = 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.
// Here we modify the k-value to be 20.0, instead of the usual 32.0.
// To simplify massively: This means the ratings will not change as much.
let config = EloConfig { k: 20.0 };

// The elo function will calculate the new ratings for both players and return them.
let (new_player_one, new_player_two) = elo(&player_one, &player_two, &outcome, &config);

More Information

Structs

Functions

  • Calculates the EloRatings of two players based on their old ratings and the outcome of the game.
  • Calculates an EloRating in a non-traditional way using a rating period, for compatibility with the other algorithms.
  • Calculates the expected score of two players based on their elo rating.
  • Calculates the expected outcome of a player in a rating period or tournament.