From 4d2057d45143ada574e2351824e5d0a77172eca1 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Wed, 24 Oct 2018 16:15:34 +0200 Subject: [PATCH] Clean up. --- src/lib.rs | 26 +++++++++++--------------- src/main.rs | 15 --------------- 2 files changed, 11 insertions(+), 30 deletions(-) delete mode 100644 src/main.rs diff --git a/src/lib.rs b/src/lib.rs index 911d1bb..26acc2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ mod math; mod matrix; use factor_graph::*; -pub use gaussian::Gaussian; +use gaussian::Gaussian; use matrix::Matrix; /// Default initial mean of ratings. @@ -68,13 +68,6 @@ fn draw_margin(p: f64, beta: f64, total_players: f64) -> f64 { math::icdf((p + 1.0) / 2.0) * total_players.sqrt() * beta } -/* -pub fn calculate_ratings(team_players: &[R], team_ranks: &[u16]) -> Vec -where - R: Rateable, -{ -*/ - pub fn rate(rating_groups: &[&[R]]) -> Vec where R: Rateable, @@ -235,7 +228,10 @@ where ratings } -pub fn quality(rating_groups: &[&[Gaussian]]) -> f64 { +pub fn quality(rating_groups: &[&[R]]) -> f64 +where + R: Rateable, +{ let flatten_ratings = rating_groups .iter() .flat_map(|group| group.iter()) @@ -298,18 +294,18 @@ mod tests { #[test] fn test_quality_1vs1() { - let alice = Gaussian::from_mu_sigma(MU, SIGMA); - let bob = Gaussian::from_mu_sigma(MU, SIGMA); + let alice = Rating::new(MU, SIGMA); + let bob = Rating::new(MU, SIGMA); assert_eq!(quality(&[&[alice], &[bob]]), 0.4472135954999579); } #[test] fn test_rate_1vs1() { - let alice = Gaussian::from_mu_sigma(MU, SIGMA); - let bob = Gaussian::from_mu_sigma(MU, SIGMA); - let chris = Gaussian::from_mu_sigma(MU, SIGMA); - let darren = Gaussian::from_mu_sigma(MU, SIGMA); + let alice = Rating::new(MU, SIGMA); + let bob = Rating::new(MU, SIGMA); + let chris = Rating::new(MU, SIGMA); + let darren = Rating::new(MU, SIGMA); let new_ratings = rate(&[&[alice], &[bob], &[chris], &[darren]]); diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 9991c5a..0000000 --- a/src/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -extern crate trueskill; - -use trueskill::{rate, Gaussian, MU, SIGMA}; - -fn main() { - let alice = Gaussian::from_mu_sigma(MU, SIGMA); - let bob = Gaussian::from_mu_sigma(MU, SIGMA); - let chris = Gaussian::from_mu_sigma(MU, SIGMA); - let darren = Gaussian::from_mu_sigma(MU, SIGMA); - - // println!("alice: {:?}", alice); - // println!("bob: {:?}", alice); - - rate(&[&[alice], &[bob], &[chris], &[darren]]); -}