search

Function search 

Source
pub fn search<S, G, R>(
    s0: &S,
    rg: &G,
    roll: &R,
    c: f32,
    max_iterations: u32,
) -> Option<S::Action>
where S: State + Clone, G: ResponseGenerator<State = S>, R: Rollout<State = S, ResponseGenerator = G>,
Expand description

Searches for the best action using the MCTS algorithm

Performs the four phases of MCTS (Selection, Expansion, Rollout, Back Propagation) for the given number of iterations, building up statistics in the search tree.

§Arguments

  • s0 - Initial game state to serve as the root of the search tree
  • rg - Response generator that returns all possible actions from a state
  • roll - Rollout implementation for simulating games
  • c - Exploration constant for UCT calculation
  • max_iterations - Number of MCTS iterations to perform

§Returns

Some(best_action) containing the action leading to the child of the root node with the most visits (most promising move), or None if the root state has no possible actions.

§Panics

This function will panic if the UCT function ever returns NaN.