Function skillratings::egf::egf

source ·
pub fn egf(
    player_one: &EGFRating,
    player_two: &EGFRating,
    outcome: &Outcomes,
    config: &EGFConfig
) -> (EGFRating, EGFRating)
Expand description

Calculates the EGFRatings of two players based on their old ratings and the outcome of the game.

Takes in two players as EGFRatings, an Outcome and an EGFConfig, where you can set up handicaps.

The outcome of the match is in the perspective of player_one. This means Outcomes::WIN is a win for player_one and Outcomes::LOSS is a win for player_two.

Examples

use skillratings::{
    egf::{egf, EGFConfig, EGFRating},
    Outcomes,
};

let player_one = EGFRating { rating: 950.0 };
let player_two = EGFRating { rating: 1200.0 };

let outcome = Outcomes::WIN;

let config = EGFConfig::new();

let (new_one, new_two) = egf(&player_one, &player_two, &outcome, &config);

assert!((new_one.rating.round() - 989.0).abs() < f64::EPSILON);
assert!((new_two.rating.round() - 1173.0).abs() < f64::EPSILON);