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§

source§

impl<B: Board> MaxMovesBoard<B>

source

pub fn new(inner: B, max_moves: u64) -> Self

source

pub fn inner(&self) -> &B

source

pub fn into_inner(self) -> B

Trait Implementations§

source§

impl<B: Board> Board for MaxMovesBoard<B>

§

type Move = <B as Board>::Move

The type used to represent moves on this board.
source§

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>

Return whether the given move is available.
source§

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>

Play the move mv, modifying this board.
source§

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

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>

Clone this board, play mv on it and return the new board. Can be overridden for better performance.
source§

fn is_done(&self) -> bool

Whether this games is done.
source§

fn check_done(&self) -> Result<(), BoardDone>

Returns Read more
source§

fn check_can_play(&self, mv: Self::Move) -> Result<(), PlayError>

Returns Read more
source§

fn play_random_available_move( &mut self, rng: &mut impl Rng ) -> Result<(), BoardDone>

The same as self.play(self.random_available_move(rng)), but needs less error handling. Can be overridden for better performance by skipping the valid move check.
source§

fn children(&self) -> Result<BoardChildrenIterator<'_, Self>, BoardDone>

The same as self.available_moves().map(|mv| self.clone_and_play(mv)), but needs less error handling. Can be overridden for better performance by skipping the valid move check.
source§

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

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>

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>

§

type Symmetry = <B as BoardSymmetry<B>>::Symmetry

The type used to represent symmetries.
§

type CanonicalKey = <B as BoardSymmetry<B>>::CanonicalKey

The type used by Self::canonical_key.
source§

fn map(&self, sym: Self::Symmetry) -> Self

Map this board under the given symmetry.
source§

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

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

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>

source§

fn clone(&self) -> MaxMovesBoard<B>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<B: Debug + Board> Debug for MaxMovesBoard<B>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<B: Board> Display for MaxMovesBoard<B>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<B: Hash + Board> Hash for MaxMovesBoard<B>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<B: PartialEq + Board> PartialEq<MaxMovesBoard<B>> for MaxMovesBoard<B>

source§

fn eq(&self, other: &MaxMovesBoard<B>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<B: Eq + Board> Eq for MaxMovesBoard<B>

source§

impl<B: Board> StructuralEq for MaxMovesBoard<B>

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V