pub fn sample_action(&self) -> Move {
        if let Some(PositionData::Internal(data)) = self.positions.get(&self.root) {
            let visit_counts: Vec<i32> = data.actions.iter().map(|action| action.visits).collect();
            let total_visit_count: i32 = visit_counts.iter().sum();

            let mut visits_left = rand::random::<f32>() * (total_visit_count as f32);
            let mut action_idx: i32 = -1;

            while visits_left > 0f32 {
                action_idx += 1;
                visits_left -= (data.actions[action_idx as usize].visits) as f32;
            }

            data.actions[action_idx as usize].action
        } else {
            panic!("Tried to select an action at a leaf or without expanding the root.")
        }
    }
/// Select an action out of the root proportionally to its visit count.
Select an action out of the root proportionally to its visit count.
Select an action out of the root proportionally to its visit count .
pub fn sample_action(&self) -> Move {
        if let Some(PositionData::Internal(data)) = self.positions.get(&self.root) {
            let visit_counts: Vec<i32> = data.actions.iter().map(|action| action.visits).collect();
            let total_visit_count: i32 = visit_counts.iter().sum();
            let mut visits_left = rand::random::<f32>() * (total_visit_count as f32);
            let mut action_idx: i32 = -1;
            while visits_left > 0f32 {
                action_idx += 1;
                visits_left -= (data.actions[action_idx as usize].visits) as f32;
            }
            data.actions[action_idx as usize].action
        } else {
            panic!("Tried to select an action at a leaf or without expanding the root.")
        }
    }
pub fn sample_action ( & self ) -> Move { if let Some ( PositionData :: Internal ( data ) ) = self . positions . get ( & self . root ) { let visit_counts : Vec < i32 > = data . actions . iter ( ) . map ( | action | action . visits ) . collect ( ) ; let total_visit_count : i32 = visit_counts . iter ( ) . sum ( ) ; let mut visits_left = rand :: random :: < f32 > ( ) * ( total_visit_count as f32 ) ; let mut action_idx : i32 = - 1 ; while visits_left > 0f32 { action_idx += 1 ; visits_left -= ( data . actions [ action_idx as usize ] . visits ) as f32 ; } data . actions [ action_idx as usize ] . action } else { panic ! ( " " ) } }
Select an action out of the root proportionally to its visit count.
Select an action out of the root proportionally to its visit count .
&self
&self