Clean up.
This commit is contained in:
26
src/lib.rs
26
src/lib.rs
@@ -6,7 +6,7 @@ mod math;
|
|||||||
mod matrix;
|
mod matrix;
|
||||||
|
|
||||||
use factor_graph::*;
|
use factor_graph::*;
|
||||||
pub use gaussian::Gaussian;
|
use gaussian::Gaussian;
|
||||||
use matrix::Matrix;
|
use matrix::Matrix;
|
||||||
|
|
||||||
/// Default initial mean of ratings.
|
/// 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
|
math::icdf((p + 1.0) / 2.0) * total_players.sqrt() * beta
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
pub fn calculate_ratings<R>(team_players: &[R], team_ranks: &[u16]) -> Vec<Rating>
|
|
||||||
where
|
|
||||||
R: Rateable,
|
|
||||||
{
|
|
||||||
*/
|
|
||||||
|
|
||||||
pub fn rate<R>(rating_groups: &[&[R]]) -> Vec<Rating>
|
pub fn rate<R>(rating_groups: &[&[R]]) -> Vec<Rating>
|
||||||
where
|
where
|
||||||
R: Rateable,
|
R: Rateable,
|
||||||
@@ -235,7 +228,10 @@ where
|
|||||||
ratings
|
ratings
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn quality(rating_groups: &[&[Gaussian]]) -> f64 {
|
pub fn quality<R>(rating_groups: &[&[R]]) -> f64
|
||||||
|
where
|
||||||
|
R: Rateable,
|
||||||
|
{
|
||||||
let flatten_ratings = rating_groups
|
let flatten_ratings = rating_groups
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|group| group.iter())
|
.flat_map(|group| group.iter())
|
||||||
@@ -298,18 +294,18 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_quality_1vs1() {
|
fn test_quality_1vs1() {
|
||||||
let alice = Gaussian::from_mu_sigma(MU, SIGMA);
|
let alice = Rating::new(MU, SIGMA);
|
||||||
let bob = Gaussian::from_mu_sigma(MU, SIGMA);
|
let bob = Rating::new(MU, SIGMA);
|
||||||
|
|
||||||
assert_eq!(quality(&[&[alice], &[bob]]), 0.4472135954999579);
|
assert_eq!(quality(&[&[alice], &[bob]]), 0.4472135954999579);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rate_1vs1() {
|
fn test_rate_1vs1() {
|
||||||
let alice = Gaussian::from_mu_sigma(MU, SIGMA);
|
let alice = Rating::new(MU, SIGMA);
|
||||||
let bob = Gaussian::from_mu_sigma(MU, SIGMA);
|
let bob = Rating::new(MU, SIGMA);
|
||||||
let chris = Gaussian::from_mu_sigma(MU, SIGMA);
|
let chris = Rating::new(MU, SIGMA);
|
||||||
let darren = Gaussian::from_mu_sigma(MU, SIGMA);
|
let darren = Rating::new(MU, SIGMA);
|
||||||
|
|
||||||
let new_ratings = rate(&[&[alice], &[bob], &[chris], &[darren]]);
|
let new_ratings = rate(&[&[alice], &[bob], &[chris], &[darren]]);
|
||||||
|
|
||||||
|
|||||||
15
src/main.rs
15
src/main.rs
@@ -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]]);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user