Struct board_game::games::max_length::MaxMovesBoard
source · pub struct MaxMovesBoard<B: Board> { /* private fields */ }
Expand description
A wrapper around an existing board that has the same behaviour, except that the outcome is a draw after a fixed number of moves has been played.
Implementations§
Trait Implementations§
source§impl<B: Board> Board for MaxMovesBoard<B>
impl<B: Board> Board for MaxMovesBoard<B>
source§fn next_player(&self) -> Player
fn next_player(&self) -> Player
Return the next player to make a move.
If the board is done this is the player that did not play the last move for consistency.
source§fn is_available_move(&self, mv: Self::Move) -> Result<bool, BoardDone>
fn is_available_move(&self, mv: Self::Move) -> Result<bool, BoardDone>
Return whether the given move is available.
source§fn random_available_move(
&self,
rng: &mut impl Rng
) -> Result<Self::Move, BoardDone>
fn random_available_move( &self, rng: &mut impl Rng ) -> Result<Self::Move, BoardDone>
Pick a random move from the
available_moves
with a uniform distribution.
Can be overridden for better performance.source§fn play(&mut self, mv: Self::Move) -> Result<(), PlayError>
fn play(&mut self, mv: Self::Move) -> Result<(), PlayError>
Play the move
mv
, modifying this board.source§fn outcome(&self) -> Option<Outcome>
fn outcome(&self) -> Option<Outcome>
The outcome of this board, is
None
when this games is not done yet.source§fn can_lose_after_move() -> bool
fn can_lose_after_move() -> bool
Whether the player who plays a move can lose by playing that move.
Symbolically whether
b.won_by() == Some(Winner::Player(b.next_player()))
can ever be true.
This may be pessimistic, returning true
is always correct.source§fn clone_and_play(&self, mv: Self::Move) -> Result<Self, PlayError>
fn clone_and_play(&self, mv: Self::Move) -> Result<Self, PlayError>
Clone this board, play
mv
on it and return the new board.
Can be overridden for better performance.source§impl<'a, B: Board> BoardMoves<'a, MaxMovesBoard<B>> for MaxMovesBoard<B>
impl<'a, B: Board> BoardMoves<'a, MaxMovesBoard<B>> for MaxMovesBoard<B>
type AllMovesIterator = <B as BoardMoves<'a, B>>::AllMovesIterator
type AvailableMovesIterator = <B as BoardMoves<'a, B>>::AvailableMovesIterator
source§fn all_possible_moves() -> Self::AllMovesIterator
fn all_possible_moves() -> Self::AllMovesIterator
All theoretically possible moves, for any possible board.
Moves returned by
available_moves
will always be a subset of these moves.
The order of these moves does not need to match the order from available_moves
.source§fn available_moves(&'a self) -> Result<Self::AvailableMovesIterator, BoardDone>
fn available_moves(&'a self) -> Result<Self::AvailableMovesIterator, BoardDone>
Return an iterator over available moves, is always nonempty. No guarantees are made about the ordering except
that it stays consistent when the board is not modified.
Panics if this board is done.
source§impl<B: Board> BoardSymmetry<MaxMovesBoard<B>> for MaxMovesBoard<B>
impl<B: Board> BoardSymmetry<MaxMovesBoard<B>> for MaxMovesBoard<B>
§type Symmetry = <B as BoardSymmetry<B>>::Symmetry
type Symmetry = <B as BoardSymmetry<B>>::Symmetry
The type used to represent symmetries.
§type CanonicalKey = <B as BoardSymmetry<B>>::CanonicalKey
type CanonicalKey = <B as BoardSymmetry<B>>::CanonicalKey
The type used by Self::canonical_key.
source§fn map_move(&self, sym: Self::Symmetry, mv: B::Move) -> B::Move
fn map_move(&self, sym: Self::Symmetry, mv: B::Move) -> B::Move
Map a move under the given symmetry.
source§fn canonical_key(&self) -> Self::CanonicalKey
fn canonical_key(&self) -> Self::CanonicalKey
Extract all of the state from this board that can potentially change when calling Self::map.
This is used by Self::canonicalize to determine which symmetry ends up as the canonical one for the given board.
source§fn canonicalize(&self) -> Self
fn canonicalize(&self) -> Self
Convert this board to a canonical version,
by mapping it with the symmetry that results in the smallest Self::canonical_key. Read more
source§impl<B: Clone + Board> Clone for MaxMovesBoard<B>
impl<B: Clone + Board> Clone for MaxMovesBoard<B>
source§fn clone(&self) -> MaxMovesBoard<B>
fn clone(&self) -> MaxMovesBoard<B>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<B: Board> Display for MaxMovesBoard<B>
impl<B: Board> Display for MaxMovesBoard<B>
source§impl<B: PartialEq + Board> PartialEq<MaxMovesBoard<B>> for MaxMovesBoard<B>
impl<B: PartialEq + Board> PartialEq<MaxMovesBoard<B>> for MaxMovesBoard<B>
source§fn eq(&self, other: &MaxMovesBoard<B>) -> bool
fn eq(&self, other: &MaxMovesBoard<B>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<B: Eq + Board> Eq for MaxMovesBoard<B>
impl<B: Board> StructuralEq for MaxMovesBoard<B>
impl<B: Board> StructuralPartialEq for MaxMovesBoard<B>
Auto Trait Implementations§
impl<B> RefUnwindSafe for MaxMovesBoard<B>where B: RefUnwindSafe,
impl<B> Send for MaxMovesBoard<B>
impl<B> Sync for MaxMovesBoard<B>
impl<B> Unpin for MaxMovesBoard<B>where B: Unpin,
impl<B> UnwindSafe for MaxMovesBoard<B>where B: UnwindSafe,
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