Struct minimax_alpha_beta::tictactoe::TicTacToe[][src]

pub struct TicTacToe {
    pub board: Vec<char>,
    pub size: usize,
    pub default_char: char,
    pub maximizer: char,
    pub minimizer: char,
}

Contains basic data about a TicTacToe game.

Fields

board: Vec<char>size: usizedefault_char: charmaximizer: charminimizer: char

Implementations

impl TicTacToe[src]

Implements all necessary methods to operate a TicTacToe game.

pub fn create_game(
    size: usize,
    default_char: Option<char>,
    maximizer: Option<char>,
    minimizer: Option<char>
) -> TicTacToe
[src]

Create a new game of TicTacToe with a fresh board.

pub fn print_board(&self)[src]

Pretty print a TicTacToe board for visualizing a game state.

pub fn check_diagonals(&self) -> char[src]

Check the main and anti-diagonals for a winner.

pub fn check_rows(&self) -> char[src]

Check the rows of the grid for a winner.

pub fn check_cols(&self) -> char[src]

Check the columns of the grid for a winner.

Trait Implementations

impl Strategy for TicTacToe[src]

Endow upon TicTacToe the ability to play games.

type Player = char

The Player is a char. Usually one of ‘o’, ‘O’, ‘x’, ‘X’, ‘-’.

type Move = usize

The Move is a single number representing an index of the Board vector, i.e. in range [0, (size * size) - 1].

type Board = Vec<char>

The Board is a single vector of length size * size.

fn evaluate(&self) -> f64[src]

Ability to statically evaluate the current game state.

fn get_winner(&self) -> Self::Player[src]

Identify a winner, if exists.

fn is_game_tied(&self) -> bool[src]

Identify if the game is tied.

fn is_game_complete(&self) -> bool[src]

Identify if the game is in a completed state.

fn get_available_moves(&self) -> Vec<Self::Move>[src]

Ability to produce a collection of playable legal moves in the current position. Read more

fn play(&mut self, mv: &Self::Move, maximizer: bool)[src]

Modify the game state by playing a given move.

fn clear(&mut self, mv: &Self::Move)[src]

Modify the game state by resetting a given move.

fn get_board(&self) -> &Self::Board[src]

Get the current state of the board.

fn is_a_valid_move(&self, mv: &Self::Move) -> bool[src]

Determine if a given move is valid.

fn get_a_sentinel_move(&self) -> Self::Move[src]

Ability to produce a sentinel (not-playable) move.

Auto Trait Implementations

Blanket Implementations

impl<T> AlphaBetaMiniMaxStrategy for T where
    T: Strategy
[src]

pub fn get_best_move(&mut Self, i64, bool) -> <T as Strategy>::Move[src]

The ability to get the best move in the current state and for the current player. Read more

pub fn minimax_score(&mut Self, i64, bool, f64, f64, i64) -> f64[src]

The ability to produce a best (good enough, sometimes) evaluation score possible over all possible moves at the current game state. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.