Struct tic_tac_toe::board::Board
source · pub struct Board { /* private fields */ }
Expand description
A Tic Tac Toe board
Implementations§
source§impl Board
impl Board
sourcepub fn has_won(self, team: Team) -> bool
pub fn has_won(self, team: Team) -> bool
Check if the given team won.
This is designed to be fast.
sourcepub fn get_winner(self) -> Option<Team>
pub fn get_winner(self) -> Option<Team>
Get the winner if they exist
sourcepub fn get_winner_info(self) -> Option<WinnerInfo>
pub fn get_winner_info(self) -> Option<WinnerInfo>
Get the winner info, if there is a winner
This is much slower than Self::get_winner
.
sourcepub fn iter_children(self) -> ChildrenIter ⓘ
pub fn iter_children(self) -> ChildrenIter ⓘ
Get an iterator over child board states.
Returns
Returns an Iterator where Items are tuples. The first item is the index of the placed tile. The second is the resulting board state.
sourcepub fn iter(self) -> impl Iterator<Item = (u8, Option<Team>)>
pub fn iter(self) -> impl Iterator<Item = (u8, Option<Team>)>
Get an iterator over the tiles.
The iterator starts at 0 at the top left and ends at 8 at the bottom right.
Returns
Returns a tuple pair, where the first element is the index and the second is the tile value.
sourcepub fn encode_u16(self) -> u16
pub fn encode_u16(self) -> u16
Encode this board as a u16
.
sourcepub fn decode_u16(data: u16) -> Self
pub fn decode_u16(data: u16) -> Self
Decode a u16
into a board
Trait Implementations§
source§impl PartialEq for Board
impl PartialEq for Board
impl Copy for Board
impl Eq for Board
impl StructuralEq for Board
impl StructuralPartialEq for Board
Auto Trait Implementations§
impl RefUnwindSafe for Board
impl Send for Board
impl Sync for Board
impl Unpin for Board
impl UnwindSafe for Board
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
Mutably borrows from an owned value. Read more