Struct minimax_alpha_beta::games::TicTacToe
source · [−]pub struct TicTacToe {
pub board: Vec<char>,
pub size: usize,
pub default_char: char,
pub maximizer: char,
pub minimizer: char,
}
Fields
board: Vec<char>
size: usize
default_char: char
maximizer: char
minimizer: char
Implementations
sourceimpl TicTacToe
impl TicTacToe
Implements all necessary methods to operate a TicTacToe game.
pub fn new(size: usize) -> Self
pub fn with_player_1(self, character: char) -> Self
pub fn with_player_2(self, character: char) -> Self
pub fn with_default_char(self, character: char) -> Self
sourcepub fn check_diagonals(&self) -> char
pub fn check_diagonals(&self) -> char
Check the main and anti-diagonals for a winner.
sourcepub fn check_rows(&self) -> char
pub fn check_rows(&self) -> char
Check the rows of the grid for a winner.
sourcepub fn check_cols(&self) -> char
pub fn check_cols(&self) -> char
Check the columns of the grid for a winner.
Trait Implementations
sourceimpl GameStrategy for TicTacToe
impl GameStrategy for TicTacToe
Endow upon TicTacToe the ability to play games.
type Move = usize
type Move = usize
The Move is a single number representing an
index of the Board vector, i.e. in range
[0, (size * size) - 1]
.
sourcefn get_winner(&self) -> Option<Self::Player>
fn get_winner(&self) -> Option<Self::Player>
Identify a winner, if exists.
sourcefn is_game_tied(&self) -> bool
fn is_game_tied(&self) -> bool
Identify if the game is tied.
sourcefn is_game_complete(&self) -> bool
fn is_game_complete(&self) -> bool
Identify if the game is in a completed state.
sourcefn get_available_moves(&self) -> Vec<Self::Move>
fn get_available_moves(&self) -> Vec<Self::Move>
Ability to produce a collection of playable legal moves in the current position. Read more
sourcefn play(&mut self, mv: &Self::Move, maximizer: bool)
fn play(&mut self, mv: &Self::Move, maximizer: bool)
Modify the game state by playing a given move.
sourcefn is_a_valid_move(&self, mv: &Self::Move) -> bool
fn is_a_valid_move(&self, mv: &Self::Move) -> bool
Determine if a given move is valid.
sourcefn get_a_sentinel_move(&self) -> Self::Move
fn get_a_sentinel_move(&self) -> Self::Move
Ability to produce a sentinel (not-playable) move.
Auto Trait Implementations
impl RefUnwindSafe for TicTacToe
impl Send for TicTacToe
impl Sync for TicTacToe
impl Unpin for TicTacToe
impl UnwindSafe for TicTacToe
Blanket Implementations
sourceimpl<T> AlphaBetaMiniMaxStrategy for T where
T: GameStrategy,
impl<T> AlphaBetaMiniMaxStrategy for T where
T: GameStrategy,
sourcefn get_best_move(
&mut self,
max_depth: i64,
is_maximizing: bool
) -> <T as GameStrategy>::Move
fn get_best_move(
&mut self,
max_depth: i64,
is_maximizing: bool
) -> <T as GameStrategy>::Move
The ability to get the best move in the current state and for the current player. Read more
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