Added test for 2 vs 2. It fails... need to figure out why.
This commit is contained in:
33
src/lib.rs
33
src/lib.rs
@@ -174,19 +174,22 @@ where
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let epsilon = draw_margin(DRAW_PROBABILITY, BETA, 2.0);
|
|
||||||
|
|
||||||
let trunc_layer = team_diff_vars
|
let trunc_layer = team_diff_vars
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, variable)| {
|
.map(|(i, variable)| {
|
||||||
factor_id += 1;
|
factor_id += 1;
|
||||||
|
|
||||||
|
let player_count = perf_vars
|
||||||
|
.iter()
|
||||||
|
.filter(|(_, team)| *team as usize == i || *team as usize == i + 1)
|
||||||
|
.count();
|
||||||
|
|
||||||
TruncateFactor::new(
|
TruncateFactor::new(
|
||||||
&mut variable_arena,
|
&mut variable_arena,
|
||||||
factor_id,
|
factor_id,
|
||||||
*variable,
|
*variable,
|
||||||
epsilon,
|
draw_margin(DRAW_PROBABILITY, BETA, player_count as f64),
|
||||||
ranks[i] == ranks[i + 1],
|
ranks[i] == ranks[i + 1],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -350,7 +353,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rate_4vs4() {
|
fn test_rate_4_free_for_all() {
|
||||||
let alice = Rating::new(MU, SIGMA);
|
let alice = Rating::new(MU, SIGMA);
|
||||||
let bob = Rating::new(MU, SIGMA);
|
let bob = Rating::new(MU, SIGMA);
|
||||||
let chris = Rating::new(MU, SIGMA);
|
let chris = Rating::new(MU, SIGMA);
|
||||||
@@ -387,4 +390,26 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rate_2vs2() {
|
||||||
|
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 expected_ratings = vec![
|
||||||
|
Rating::new(28.108322399069035, 7.77436345109384),
|
||||||
|
Rating::new(28.108322399069035, 7.77436345109384),
|
||||||
|
Rating::new(21.891677600930958, 7.77436345109384),
|
||||||
|
Rating::new(21.891677600930958, 7.77436345109384),
|
||||||
|
];
|
||||||
|
|
||||||
|
let ratings = rate(&[(alice, 0), (bob, 0), (chris, 1), (darren, 1)], &[0, 1]);
|
||||||
|
|
||||||
|
for (rating, expected) in ratings.iter().zip(expected_ratings.iter()) {
|
||||||
|
assert_relative_eq!(rating, expected, epsilon = EPSILON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user