Function project

Source
pub fn project(race: &Race, dice: &Dice) -> Chances
Expand description

Determines the win chances for each camel.

The Distribution returns for each camel present in the race, the chance of winning.

Examples found in repository?
examples/who.rs (line 9)
5fn main() {
6    let race = "r,,y".parse::<Race>().expect("to parse");
7    let dice = "ry".parse::<Dice>().expect("to parse");
8
9    let result = project(&race, &dice);
10    let mut ordered: Vec<(Camel, Fraction)> =
11        result.winner.values().map(|(k, v)| (*k, *v)).collect();
12    ordered.sort_by(|(_, left), (_, right)| right.cmp(&left));
13    for (camel, fraction) in ordered {
14        print!("({:?},{})", camel, fraction);
15    }
16    println!();
17}
More examples
Hide additional examples
examples/tower.rs (line 9)
5fn main() {
6    let race = "gyor,,,w".parse::<Race>().expect("to parse");
7    let dice = "gyorw".parse::<Dice>().expect("to parse");
8
9    let result = project(&race, &dice);
10    let mut ordered: Vec<(Camel, Fraction)> =
11        result.winner.values().map(|(k, v)| (*k, *v)).collect();
12    ordered.sort_by(|(_, left), (_, right)| right.cmp(&left));
13    for (camel, fraction) in ordered {
14        print!("({:?},{})", camel, fraction);
15    }
16    println!()
17}