fn update_statistics(&mut self, trajectory: Vec<usize>, black_value: f64) {
        let mut position = self.root;

        for move_idx in trajectory {
            let node_data = self.positions.get_mut(&position).unwrap();

            // Compute the value of the leaf for the active player
            let value = if position.active_player == Player::Black {
                black_value
            } else {
                -1.0 * black_value
            };

            // Update the action-value toward the leaf value (for the active player)
            if let PositionData::Internal(internal) = node_data {
                let action = &mut internal.actions[move_idx];
                action.visits += 1;
                action.total_value += value;

                // Proceed to next position
                position = action.result;
            } else {
                panic!("Leaf node reached during backup!")
            }
        }
    }
/// Walk along the actions in `trajectory` and update statistics for each,
/// based on the simulation result at its end.
Walk along the actions in `trajectory` and update statistics for each,
based on the simulation result at its end.
Walk along the actions in ` trajectory ` and update statistics for each based on the simulation result at its end .
fn update_statistics(&mut self, trajectory: Vec<usize>, black_value: f64) {
        let mut position = self.root;
        for move_idx in trajectory {
            let node_data = self.positions.get_mut(&position).unwrap();
            // Compute the value of the leaf for the active player
            let value = if position.active_player == Player::Black {
                black_value
            } else {
                -1.0 * black_value
            };
            // Update the action-value toward the leaf value (for the active player)
            if let PositionData::Internal(internal) = node_data {
                let action = &mut internal.actions[move_idx];
                action.visits += 1;
                action.total_value += value;
                // Proceed to next position
                position = action.result;
            } else {
                panic!("Leaf node reached during backup!")
            }
        }
    }
fn update_statistics ( & mut self , trajectory : Vec < usize > , black_value : f64 ) { let mut position = self . root ; for move_idx in trajectory { let node_data = self . positions . get_mut ( & position ) . unwrap ( ) ; // Compute the value of the leaf for the active player let value = if position . active_player == Player :: Black { black_value } else { - 1.0 * black_value } ; // Update the action-value toward the leaf value (for the active player) if let PositionData :: Internal ( internal ) = node_data { let action = & mut internal . actions [ move_idx ] ; action . visits += 1 ; action . total_value += value ; // Proceed to next position position = action . result ; } else { panic ! ( " " ) } } }
Walk along the actions in `trajectory` and update statistics for each,
based on the simulation result at its end.
Walk along the actions in ` trajectory ` and update statistics for each based on the simulation result at its end .
&mut self
trajectory
Vec<usize>
black_value
f64
&mut self
trajectory
Vec<usize>
black_value
f64