Function skillratings::uscf::uscf
source · pub fn uscf(
player_one: &USCFRating,
player_two: &USCFRating,
outcome: &Outcomes,
config: &USCFConfig
) -> (USCFRating, USCFRating)
Expand description
Calculates the USCFRating
s of two players based on their old ratings, deviations, and the outcome of the game.
Takes in two players as USCFRating
s, an Outcome
, and a USCFConfig
.
Instead of the traditional way of calculating the USCF Rating for only one player only using a list of results, we are calculating the USCF Rating for two players at once, like in the Elo calculation, to make it easier to see instant results.
For the traditional way of calculating a USCF Rating rating please see uscf_rating_period
.
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::{
uscf::{uscf, USCFConfig, USCFRating},
Outcomes,
};
let player_one = USCFRating {
rating: 1250.0,
games: 30,
};
let player_two = USCFRating {
rating: 1400.0,
games: 9,
};
let outcome = Outcomes::WIN;
let config = USCFConfig::new();
let (new_one, new_two) = uscf(&player_one, &player_two, &outcome, &config);
assert!((new_one.rating.round() - 1289.0).abs() < f64::EPSILON);
assert_eq!(new_one.games, 31);
assert!((new_two.rating.round() - 1344.0).abs() < f64::EPSILON);
assert_eq!(new_two.games, 10);