pub trait TreePolicy<Spec: MCTS<TreePolicy = Self>>: Sync + Sized {
type MoveEvaluation: Sync + Send + Default;
type ThreadLocalData: Default;
// Required method
fn choose_child<'a, MoveIter>(
&self,
moves: MoveIter,
handle: SearchHandle<'_, Spec>,
) -> &'a MoveInfo<Spec>
where MoveIter: Iterator<Item = &'a MoveInfo<Spec>> + Clone;
// Provided methods
fn validate_evaluations(&self, _evalns: &[Self::MoveEvaluation]) { ... }
fn seed_thread_data(&self, _tld: &mut Self::ThreadLocalData, _seed: u64) { ... }
fn compare_move_evaluations(
&self,
_a: &Self::MoveEvaluation,
_b: &Self::MoveEvaluation,
) -> Ordering { ... }
fn apply_dirichlet_noise(
&self,
_moves: &mut [MoveInfo<Spec>],
_epsilon: f64,
_alpha: f64,
_rng: &mut Rng64,
) { ... }
}Expand description
Selects which child to explore during MCTS tree traversal.
Two built-in policies are provided:
UCTPolicy— classic UCB1 (Upper Confidence Bound). Move evaluations are().AlphaGoPolicy— PUCT with prior probabilities. Move evaluations aref64priors.
Required Associated Types§
Sourcetype MoveEvaluation: Sync + Send + Default
type MoveEvaluation: Sync + Send + Default
Per-move evaluation produced by the evaluator (e.g., () for UCT, f64 prior for PUCT).
Sourcetype ThreadLocalData: Default
type ThreadLocalData: Default
Thread-local data for the policy (e.g., an RNG for tie-breaking).
Required Methods§
Sourcefn choose_child<'a, MoveIter>(
&self,
moves: MoveIter,
handle: SearchHandle<'_, Spec>,
) -> &'a MoveInfo<Spec>
fn choose_child<'a, MoveIter>( &self, moves: MoveIter, handle: SearchHandle<'_, Spec>, ) -> &'a MoveInfo<Spec>
Select the most promising child to explore during a playout.
Provided Methods§
Sourcefn validate_evaluations(&self, _evalns: &[Self::MoveEvaluation])
fn validate_evaluations(&self, _evalns: &[Self::MoveEvaluation])
Validate move evaluations after node creation (e.g., check priors sum to 1).
Sourcefn seed_thread_data(&self, _tld: &mut Self::ThreadLocalData, _seed: u64)
fn seed_thread_data(&self, _tld: &mut Self::ThreadLocalData, _seed: u64)
Seed the thread-local data for deterministic search.
Called when the MCTS config provides an rng_seed().
Sourcefn compare_move_evaluations(
&self,
_a: &Self::MoveEvaluation,
_b: &Self::MoveEvaluation,
) -> Ordering
fn compare_move_evaluations( &self, _a: &Self::MoveEvaluation, _b: &Self::MoveEvaluation, ) -> Ordering
Compare two move evaluations for ordering during progressive widening.
Higher-priority moves should sort first (return Greater for higher priority a).
Default: Equal (no reordering).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.