pub struct AIPlayer { /* private fields */ }
Expand description
An AI player that uses a solver to determine the best move to play in a Connect Four position.
The player’s skill level can be configured using the Difficulty
enum, which adjusts the
move selection strategy.
Implementations§
Source§impl AIPlayer
impl AIPlayer
Sourcepub fn new(difficulty: Difficulty) -> AIPlayer
pub fn new(difficulty: Difficulty) -> AIPlayer
Creates a new AI player with a default solver and specified difficulty.
Sourcepub fn load_opening_book(&mut self, path: &Path) -> bool
pub fn load_opening_book(&mut self, path: &Path) -> bool
Attempts to load an opening book from the given path for the AI player’s solver.
Returns whether the opening book was successfully loaded.
Sourcepub fn solve(&mut self, position: &Position) -> i8
pub fn solve(&mut self, position: &Position) -> i8
Solves a position to find its exact score using the AI player’s solver.
Sourcepub fn get_all_move_scores(&mut self, position: &Position) -> [Option<i8>; 7]
pub fn get_all_move_scores(&mut self, position: &Position) -> [Option<i8>; 7]
Calculates the scores for all possible next moves in the given position using the AI player’s solver.
Sourcepub fn get_move(&mut self, position: &Position) -> Option<usize>
pub fn get_move(&mut self, position: &Position) -> Option<usize>
Solves and selects the AI player’s move for the given position.
Sourcepub fn select_move(
&self,
position: &Position,
scores: &[Option<i8>; 7],
) -> Option<usize>
pub fn select_move( &self, position: &Position, scores: &[Option<i8>; 7], ) -> Option<usize>
Selects a move from a fixed-size array of scores using a Softmax distribution with a temperature defined by the AI player’s difficulty. Temperature values <= 0 will result in greedy selection (always picking the best move).
Returns an Option<usize>
containing the column index of the selected move, or None
if no moves are possible.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AIPlayer
impl RefUnwindSafe for AIPlayer
impl Send for AIPlayer
impl Sync for AIPlayer
impl Unpin for AIPlayer
impl UnwindSafe for AIPlayer
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more