pub struct ChessBoard { /* private fields */ }
Implementations§
Source§impl ChessBoard
impl ChessBoard
pub fn default_with_rules(rules: Rules) -> Self
pub fn new_without_history_fen(fen: &str, rules: Rules) -> Self
Sourcepub fn new_without_history(inner: Board, rules: Rules) -> Self
pub fn new_without_history(inner: Board, rules: Rules) -> Self
Construct a new board from an inner chess board, without any history (including repetition and reset counters). To get a board with history start from the initial board and play the moves on it instead.
pub fn parse_move(&self, mv_str: &str) -> Result<ChessMove, Box<ParseMoveError>>
pub fn to_san(&self, mv: ChessMove) -> Result<String, PlayError>
Sourcepub fn repetitions_for(&self, board: &Board) -> usize
pub fn repetitions_for(&self, board: &Board) -> usize
Count how often the given position occurs in this boards history.
pub fn rules(&self) -> Rules
pub fn inner(&self) -> &Board
pub fn history(&self) -> &Vec<Board>
pub fn non_pawn_or_capture_moves(&self) -> u16
pub fn repetitions(&self) -> u16
Trait Implementations§
Source§impl Board for ChessBoard
impl Board for ChessBoard
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> BoardMoves<'a, ChessBoard> for ChessBoard
impl<'a> BoardMoves<'a, ChessBoard> for ChessBoard
type AllMovesIterator = AllMovesIterator<ChessBoard>
type AvailableMovesIterator = AvailableMovesIterator<'a, ChessBoard>
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 BoardSymmetry<ChessBoard> for ChessBoard
impl BoardSymmetry<ChessBoard> for ChessBoard
Source§type Symmetry = UnitSymmetry
type Symmetry = UnitSymmetry
The type used to represent symmetries.
Source§type CanonicalKey = ()
type CanonicalKey = ()
The type used by Self::canonical_key.
Source§fn map_move(
&self,
_: Self::Symmetry,
mv: <ChessBoard as Board>::Move,
) -> <ChessBoard as Board>::Move
fn map_move( &self, _: Self::Symmetry, mv: <ChessBoard as Board>::Move, ) -> <ChessBoard as Board>::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 Clone for ChessBoard
impl Clone for ChessBoard
Source§fn clone(&self) -> ChessBoard
fn clone(&self) -> ChessBoard
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ChessBoard
impl Debug for ChessBoard
Source§impl Default for ChessBoard
impl Default for ChessBoard
Source§impl Display for ChessBoard
impl Display for ChessBoard
Source§impl Hash for ChessBoard
impl Hash for ChessBoard
Source§impl Heuristic<ChessBoard> for ChessPieceValueHeuristic
impl Heuristic<ChessBoard> for ChessPieceValueHeuristic
Source§fn value(&self, board: &ChessBoard, length: u32) -> Self::V
fn value(&self, board: &ChessBoard, length: u32) -> Self::V
Return the heuristic value for the given board from the the next player POV.
depth
is the current depth, the number of moves played since the board the search was started on.
Can be used to prefer faster wins or slower losses.Source§impl PartialEq for ChessBoard
impl PartialEq for ChessBoard
impl Alternating for ChessBoard
impl Eq for ChessBoard
impl StructuralPartialEq for ChessBoard
Auto Trait Implementations§
impl Freeze for ChessBoard
impl RefUnwindSafe for ChessBoard
impl Send for ChessBoard
impl Sync for ChessBoard
impl Unpin for ChessBoard
impl UnwindSafe for ChessBoard
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more