pub fn probability_table(&self) -> Vec<Result<(f64, f64, f64), Faction>> {
        (0..self.num_players()).into_iter().map(|player_idx| {
            if self.alive().contains(&player_idx) {
                let village_universes = self.iter()
                    .filter(|universe| universe.factions[player_idx] == Faction::Village)
                    .count();
                let village_ratio = (village_universes as f64) / (self.0.len() as f64);
                let werewolves_universes = self.iter()
                    .filter(|universe| universe.factions[player_idx] == Faction::Werewolves)
                    .count();
                let werewolves_ratio = (werewolves_universes as f64) / (self.0.len() as f64);
                let dead_universes = self.iter()
                    .filter(|universe| !universe.alive[player_idx])
                    .count();
                let dead_ratio = (dead_universes as f64) / (self.0.len() as f64);
                Ok((village_ratio, werewolves_ratio, dead_ratio))
            } else {
                Err(self.faction(player_idx).expect("player is dead but does not have a determined faction"))
            }
        }).collect()
    }
/// Produces the anonymized probability table shown to players at the start of the day.
Produces the anonymized probability table shown to players at the start of the day.
Produces the anonymized probability table shown to players at the start of the day .
pub fn probability_table(&self) -> Vec<Result<(f64, f64, f64), Faction>> {
        (0..self.num_players()).into_iter().map(|player_idx| {
            if self.alive().contains(&player_idx) {
                let village_universes = self.iter()
                    .filter(|universe| universe.factions[player_idx] == Faction::Village)
                    .count();
                let village_ratio = (village_universes as f64) / (self.0.len() as f64);
                let werewolves_universes = self.iter()
                    .filter(|universe| universe.factions[player_idx] == Faction::Werewolves)
                    .count();
                let werewolves_ratio = (werewolves_universes as f64) / (self.0.len() as f64);
                let dead_universes = self.iter()
                    .filter(|universe| !universe.alive[player_idx])
                    .count();
                let dead_ratio = (dead_universes as f64) / (self.0.len() as f64);
                Ok((village_ratio, werewolves_ratio, dead_ratio))
            } else {
                Err(self.faction(player_idx).expect("player is dead but does not have a determined faction"))
            }
        }).collect()
    }
pub fn probability_table ( & self ) -> Vec < Result < ( f64 , f64 , f64 ) , Faction > > { ( 0 .. self . num_players ( ) ) . into_iter ( ) . map ( | player_idx | { if self . alive ( ) . contains ( & player_idx ) { let village_universes = self . iter ( ) . filter ( | universe | universe . factions [ player_idx ] == Faction :: Village ) . count ( ) ; let village_ratio = ( village_universes as f64 ) / ( self . 0 . len ( ) as f64 ) ; let werewolves_universes = self . iter ( ) . filter ( | universe | universe . factions [ player_idx ] == Faction :: Werewolves ) . count ( ) ; let werewolves_ratio = ( werewolves_universes as f64 ) / ( self . 0 . len ( ) as f64 ) ; let dead_universes = self . iter ( ) . filter ( | universe | ! universe . alive [ player_idx ] ) . count ( ) ; let dead_ratio = ( dead_universes as f64 ) / ( self . 0 . len ( ) as f64 ) ; Ok ( ( village_ratio , werewolves_ratio , dead_ratio ) ) } else { Err ( self . faction ( player_idx ) . expect ( " " ) ) } } ) . collect ( ) }
Produces the anonymized probability table shown to players at the start of the day.
Produces the anonymized probability table shown to players at the start of the day .
&self
&self