Expand description
This struct is the main launch point for this crate. It holds the state of execution for the MCTS algorithm. Use it’s associated methods to operate the search and tune performance.
Fields
info: Info
Provides metrics about the shape and size of the game tree. For informational purposes only.
Implementations
sourceimpl<P: Player, A: Action, S: GameState<P, A>> MCTS<P, A, S>
impl<P: Player, A: Action, S: GameState<P, A>> MCTS<P, A, S>
sourcepub fn new(root: S) -> Self
pub fn new(root: S) -> Self
Call this method to instantiate a new search with default parameters. The root game state from which to search is passed as a value to be owned by the MCTS struct.
sourcepub fn best(&self) -> Option<A>
pub fn best(&self) -> Option<A>
Pick the best move after some time spent pondering. Returns None if ponder has not yet been called.
sourcepub fn ply<F>(&self, f: &mut F) where
F: FnMut((A, f32, f32)),
pub fn ply<F>(&self, f: &mut F) where
F: FnMut((A, f32, f32)),
Iterate through the actions in the first ply. The callback f is called for each action in the first ply with a tuple of (a, w, s) where a is the action, w is the expected value of the action, and s is the confidence in the value of the action. s is similar to standard deviation where closer to zero is more confident.
sourceimpl<P: Player, A: Action, S: GameState<P, A>> MCTS<P, A, S>
impl<P: Player, A: Action, S: GameState<P, A>> MCTS<P, A, S>
sourcepub fn with_exploration(self, exploration: f32) -> Self
pub fn with_exploration(self, exploration: f32) -> Self
Sets the exploration parameter. This sets the balance between exploration and exploitation when MCTS determines which action to choose. Set to a value > 0.
sourcepub fn with_expansion_minimum(self, expansion: u32) -> Self
pub fn with_expansion_minimum(self, expansion: u32) -> Self
Sets the expansion parameter. This is the minimum number of times a leaf node should be visited before expanding it into a branch node.
sourcepub fn with_custom_evaluation(self) -> Self
pub fn with_custom_evaluation(self) -> Self
Enables the custom evaluation method.
sourcepub fn with_transposition(self) -> Self
pub fn with_transposition(self) -> Self
Enables transposition detection. Experimental.
sourcepub fn with_entropy(self) -> Self
pub fn with_entropy(self) -> Self
Seeds the internal random number generator from entropy. This is inteneded to produce non-deterministic search results.
Auto Trait Implementations
impl<P, A, S> RefUnwindSafe for MCTS<P, A, S> where
A: RefUnwindSafe,
P: RefUnwindSafe,
S: RefUnwindSafe,
impl<P, A, S> Send for MCTS<P, A, S> where
A: Send,
P: Send,
S: Send,
impl<P, A, S> Sync for MCTS<P, A, S> where
A: Sync,
P: Sync,
S: Sync,
impl<P, A, S> Unpin for MCTS<P, A, S> where
A: Unpin,
P: Unpin,
S: Unpin,
impl<P, A, S> UnwindSafe for MCTS<P, A, S> where
A: UnwindSafe,
P: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more