pub fn collapse_roles(&mut self) {
        let mut start_size = self.0.len();
        let mut collapsed_roles = HashMap::<usize, Role>::default();
        loop {
            {
                let collapse_universe = self.iter().rand(&mut thread_rng()).expect("paradox created while collapsing roles");
                for player_idx in 0..self.num_players() {
                    if !self.alive().contains(&player_idx) {
                        collapsed_roles.insert(player_idx, collapse_universe.roles[player_idx]);
                    }
                }
            }
            let multiverse = mem::replace(&mut self.0, Vec::default());
            self.0 = multiverse
                .into_iter()
                .filter(|universe| collapsed_roles.iter().all(|(&id, &role)| universe.roles[id] == role))
                .collect();
            if self.0.len() == start_size {
                break;
            } else {
                start_size = self.0.len();
            }
        }
    }
/// Determines a single role for each dead player and removes all universes where that player doesn't have that role.
Determines a single role for each dead player and removes all universes where that player doesn't have that role.
Determines a single role for each dead player and removes all universes where that player doesn ' t have that role .
pub fn collapse_roles(&mut self) {
        let mut start_size = self.0.len();
        let mut collapsed_roles = HashMap::<usize, Role>::default();
        loop {
            {
                let collapse_universe = self.iter().rand(&mut thread_rng()).expect("paradox created while collapsing roles");
                for player_idx in 0..self.num_players() {
                    if !self.alive().contains(&player_idx) {
                        collapsed_roles.insert(player_idx, collapse_universe.roles[player_idx]);
                    }
                }
            }
            let multiverse = mem::replace(&mut self.0, Vec::default());
            self.0 = multiverse
                .into_iter()
                .filter(|universe| collapsed_roles.iter().all(|(&id, &role)| universe.roles[id] == role))
                .collect();
            if self.0.len() == start_size {
                break;
            } else {
                start_size = self.0.len();
            }
        }
    }
pub fn collapse_roles ( & mut self ) { let mut start_size = self . 0 . len ( ) ; let mut collapsed_roles = HashMap :: < usize , Role > :: default ( ) ; loop { { let collapse_universe = self . iter ( ) . rand ( & mut thread_rng ( ) ) . expect ( " " ) ; for player_idx in 0 .. self . num_players ( ) { if ! self . alive ( ) . contains ( & player_idx ) { collapsed_roles . insert ( player_idx , collapse_universe . roles [ player_idx ] ) ; } } } let multiverse = mem :: replace ( & mut self . 0 , Vec :: default ( ) ) ; self . 0 = multiverse . into_iter ( ) . filter ( | universe | collapsed_roles . iter ( ) . all ( | ( & id , & role ) | universe . roles [ id ] == role ) ) . collect ( ) ; if self . 0 . len ( ) == start_size { break ; } else { start_size = self . 0 . len ( ) ; } } }
Determines a single role for each dead player and removes all universes where that player doesn't have that role.
Determines a single role for each dead player and removes all universes where that player doesn ' t have that role .
&mut self
&mut self