bayes_elo

Crates.iobayes_elo
lib.rsbayes_elo
version0.1.1
sourcesrc
created_at2024-07-19 11:58:43.093123
updated_at2024-07-19 14:15:26.837156
descriptionA library for calculating Elo in balanced and unbalanced competitions or games.
homepagehttps://github.com/Joker2770/bayes_elo.git
repositoryhttps://github.com/Joker2770/bayes_elo.git
max_upload_size
id1308560
size50,956
(Joker2770)

documentation

README

bayes_elo

Rust

A library for calculating Elo in balanced and unbalanced competitions or games.

Usage

Assuming you have installed bayes_elo crate.

use bayes_elo::BayesElo;

let mut bayes_elo_instance = BayesElo::new();

/// @params winner_elo: f64 - winner's elo.
///         loser_elo: f64 - loser's elo.
///         is_winner_advantage:bool - if winner is advantage camp.
/// @return (new_winner_elo: f64, new_loser_elo: f64).
let result = bayes_elo_instance.calculate(1700.0_f64, 1200.0_f64, true);
println!("new result: {}, {}", result.0, result.1);
assert_eq!(result.0 > 1700.0_f64, true);
assert_eq!(result.1 < 1200.0_f64, true);

let new_k = bayes_elo_instance.set_k_factor(20.0f64);
println!("new k: {}", new_k);

/// @params first_player_elo: f64 - first-player's elo.
///         second_player_elo: f64 - second-player's elo.
///         is_first_player_advantage:bool - if first-player is advantage camp.
/// @return (new_first_elo: f64, new_second_elo: f64).
let result_4_draw = bayes_elo_instance.calculate_4_draw(1700.0_f64, 1200.0_f64, true);
println!("new result_4_draw: {}, {}", result_4_draw.0, result_4_draw.1);
assert_eq!(result_4_draw.0 < 1700.0_f64, true);
assert_eq!(result_4_draw.1 > 1200.0_f64, true);

License

  • GNU GENERAL PUBLIC LICENSE Version 3

Reference

  1. Bayesian-Elo.
Commit count: 0

cargo fmt