1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
mod bar;
mod codeforces_sys;
mod elo_mmr;
mod glicko;
mod topcoder_sys;
mod true_skill;
mod util;

pub use bar::BAR;
pub use codeforces_sys::CodeforcesSys;
pub use elo_mmr::{EloMMR, EloMMRVariant};
pub use glicko::Glicko;
pub use topcoder_sys::TopcoderSys;
pub use true_skill::TrueSkillSPb;
pub use util::{
    get_participant_ratings, outcome_free, simulate_contest, Player, PlayerEvent, PlayersByName,
    Rating, RatingSystem,
};

// TODO: add a version that can take parameters, like in experiment_config but polymorphic
pub fn get_rating_system_by_name(
    system_name: &str,
) -> Result<Box<dyn RatingSystem + Send>, String> {
    match system_name {
        "bar" => Ok(Box::new(BAR::default())),
        "glicko" => Ok(Box::new(Glicko::default())),
        "cf" => Ok(Box::new(CodeforcesSys::default())),
        "tc" => Ok(Box::new(TopcoderSys::default())),
        "ts" => Ok(Box::new(TrueSkillSPb::default())),
        "mmx" => Ok(Box::new(EloMMR::default_gaussian())),
        "mmx-fast" => Ok(Box::new(EloMMR::default_gaussian_fast())),
        "mmr" => Ok(Box::new(EloMMR::default())),
        "mmr-fast" => Ok(Box::new(EloMMR::default_fast())),
        name => Err(format!(
            "{} is not a valid rating system. Must be one of: bar, glicko, cf, tc, ts, mmx, mmx-fast, mmr, mmr-fast",
            name
        )),
    }
}