Struct minimax::strategies::mcts::MonteCarloTreeSearch
source · pub struct MonteCarloTreeSearch<G: Game> { /* private fields */ }
Expand description
A strategy that uses random playouts to explore the game tree to decide on the best move. This can be used without an Evaluator, just using the rules of the game.
Implementations§
source§impl<G: Game> MonteCarloTreeSearch<G>
impl<G: Game> MonteCarloTreeSearch<G>
pub fn new(options: MCTSOptions) -> Self
sourcepub fn new_with_policy(
options: MCTSOptions,
policy: Box<dyn RolloutPolicy<G = G> + Sync>
) -> Self
pub fn new_with_policy( options: MCTSOptions, policy: Box<dyn RolloutPolicy<G = G> + Sync> ) -> Self
Create a searcher with a custom rollout policy. You could bias the random move generation to prefer certain kinds of moves, always choose winning moves, etc.
sourcepub fn set_max_rollouts(&mut self, rollouts: u32)
pub fn set_max_rollouts(&mut self, rollouts: u32)
Instead of a timeout, run this many rollouts to choose a move.
Trait Implementations§
source§impl<G> Strategy<G> for MonteCarloTreeSearch<G>where
G: Sync + Game,
G::S: Clone + Send,
G::M: Copy + Sync,
impl<G> Strategy<G> for MonteCarloTreeSearch<G>where G: Sync + Game, G::S: Clone + Send, G::M: Copy + Sync,
fn choose_move(&mut self, s: &G::S) -> Option<G::M>
source§fn set_timeout(&mut self, timeout: Duration)
fn set_timeout(&mut self, timeout: Duration)
For strategies that can ponder indefinitely, set the timeout.
This can be changed between calls to choose_move.
source§fn set_max_depth(&mut self, depth: u8)
fn set_max_depth(&mut self, depth: u8)
Set the maximum depth to evaluate (instead of the timeout).
This can be changed between calls to choose_move.
source§fn principal_variation(&self) -> Vec<G::M>
fn principal_variation(&self) -> Vec<G::M>
From the last choose_move call, return the principal variation,
i.e. the best sequence of moves for both players.
Auto Trait Implementations§
impl<G> !RefUnwindSafe for MonteCarloTreeSearch<G>
impl<G> !Send for MonteCarloTreeSearch<G>
impl<G> Sync for MonteCarloTreeSearch<G>where G: Sync, <G as Game>::M: Sync,
impl<G> Unpin for MonteCarloTreeSearch<G>where G: Unpin, <G as Game>::M: Unpin,
impl<G> !UnwindSafe for MonteCarloTreeSearch<G>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more