fn select_leaf(&self) -> (Game, Vec<usize>, bool) {
        let mut position = self.root;
        let mut trajectory: Vec<usize> = Vec::new();

        // Walk the tree of internal nodes by action until we hit a leaf or new node
        while let Some(position_data) = self.positions.get(&position) {
            if let PositionData::Internal(internal_data) = position_data {
                // Internal case: we've seen this node before and have actions out of it.
                let action_idx = self.ucb_action_index(internal_data);
                trajectory.push(action_idx);
                position = internal_data.actions[action_idx].result;
            } else {
                // Leaf case: UCB led us to a game-ending state and we can't continue.
                return (position, trajectory, true);
            }
        }

        // Board no longer in the tree: this is an unexplored node
        (position, trajectory, false)
    }
/// Pick a leaf node according to UCB tree traversal.
/// Leaves are typically unexplored states, but may also be game-ending states.
/// Returns: (leaf, trajectory, is_previously_visited).
Pick a leaf node according to UCB tree traversal.
Leaves are typically unexplored states, but may also be game-ending states.
Returns: (leaf, trajectory, is_previously_visited).
Pick a leaf node according to UCB tree traversal . Leaves are typically unexplored states but may also be game - ending states . Returns : ( leaf trajectory is_previously_visited ) .
fn select_leaf(&self) -> (Game, Vec<usize>, bool) {
        let mut position = self.root;
        let mut trajectory: Vec<usize> = Vec::new();
        // Walk the tree of internal nodes by action until we hit a leaf or new node
        while let Some(position_data) = self.positions.get(&position) {
            if let PositionData::Internal(internal_data) = position_data {
                // Internal case: we've seen this node before and have actions out of it.
                let action_idx = self.ucb_action_index(internal_data);
                trajectory.push(action_idx);
                position = internal_data.actions[action_idx].result;
            } else {
                // Leaf case: UCB led us to a game-ending state and we can't continue.
                return (position, trajectory, true);
            }
        }
        // Board no longer in the tree: this is an unexplored node
        (position, trajectory, false)
    }
fn select_leaf ( & self ) -> ( Game , Vec < usize > , bool ) { let mut position = self . root ; let mut trajectory : Vec < usize > = Vec :: new ( ) ; // Walk the tree of internal nodes by action until we hit a leaf or new node while let Some ( position_data ) = self . positions . get ( & position ) { if let PositionData :: Internal ( internal_data ) = position_data { // Internal case: we've seen this node before and have actions out of it. let action_idx = self . ucb_action_index ( internal_data ) ; trajectory . push ( action_idx ) ; position = internal_data . actions [ action_idx ] . result ; } else { // Leaf case: UCB led us to a game-ending state and we can't continue. return ( position , trajectory , true ) ; } } // Board no longer in the tree: this is an unexplored node ( position , trajectory , false ) }
Pick a leaf node according to UCB tree traversal.
Pick a leaf node according to UCB tree traversal .
&self
&self