pub struct Minimax { /* private fields */ }Expand description
Depth-limited alpha-beta minimax.
Assumes exactly one active player per node (sequential play) and two-player
zero-sum outcomes. Leaves are evaluated with Game::reward, so give the
search enough depth to reach terminals (or a game whose reward doubles as
a heuristic at non-terminal nodes).
Two search paths are offered and always agree: Minimax::best_action
clones state per node (needs State: Clone), and
Minimax::best_action_unmake uses a game’s Reversible make/unmake.
Implementations§
Source§impl Minimax
impl Minimax
Sourcepub const fn new(max_depth: u32) -> Self
pub const fn new(max_depth: u32) -> Self
Creates a search that looks up to max_depth plies ahead.
Sourcepub fn best_action<G>(
&self,
game: &G,
state: &G::State,
player: PlayerId,
) -> Option<G::Action>
pub fn best_action<G>( &self, game: &G, state: &G::State, player: PlayerId, ) -> Option<G::Action>
Returns the value-maximizing action for player using cloned search.
Trait Implementations§
Source§impl<G> RankedBot<G> for Minimax
impl<G> RankedBot<G> for Minimax
Source§fn rank(
&mut self,
game: &G,
state: &G::State,
player: PlayerId,
) -> Vec<(G::Action, f64)>
fn rank( &mut self, game: &G, state: &G::State, player: PlayerId, ) -> Vec<(G::Action, f64)>
Scores each root action with a full alpha-beta window (no cross-sibling
pruning), so every score is the move’s exact minimax value rather than a
bound. Costlier than Minimax::best_action; use it for analysis, not
hot self-play.