pub enum Piece {
WP,
WN,
WB,
WR,
WQ,
WK,
BP,
BN,
BB,
BR,
BQ,
BK,
}
Expand description
Value type wrapping a single integer representing one of the 12 different pieces in a game of chess.
Variants§
Implementations§
Source§impl Piece
impl Piece
Sourcepub fn all() -> impl Iterator<Item = Piece>
pub fn all() -> impl Iterator<Item = Piece>
Create an iterator traversing over all pieces in order.
Sourcepub fn whites() -> impl Iterator<Item = Piece>
pub fn whites() -> impl Iterator<Item = Piece>
Create an iterator traversing over all white pieces in order.
Sourcepub fn blacks() -> impl Iterator<Item = Piece>
pub fn blacks() -> impl Iterator<Item = Piece>
Create an iterator traversing over all black pieces in order.
Sourcepub fn of(side: Side) -> impl Iterator<Item = Piece>
pub fn of(side: Side) -> impl Iterator<Item = Piece>
Returns a slice containing all pieces belonging to the given side.
Sourcepub fn control(
self,
loc: Square,
whites: BitBoard,
blacks: BitBoard,
) -> BitBoard
pub fn control( self, loc: Square, whites: BitBoard, blacks: BitBoard, ) -> BitBoard
Computes the control set for this piece given it’s location and the locations of all the white and black pieces on the board.
Sourcepub fn empty_control(self, loc: Square) -> BitBoard
pub fn empty_control(self, loc: Square) -> BitBoard
Computes the control set for this piece given it’s location on an empty board.
Sourcepub fn moves(self, loc: Square, whites: BitBoard, blacks: BitBoard) -> BitBoard
pub fn moves(self, loc: Square, whites: BitBoard, blacks: BitBoard) -> BitBoard
Computes the set of legal moves for this piece given it’s location and the locations of all the white and black pieces on the board. Note that this method does not take into account special restrictions for or due to the king, e.g. can’t move in such a way to put the king into check.
Trait Implementations§
Source§impl EnumSetTypePrivate for Piece
impl EnumSetTypePrivate for Piece
Source§const CONST_HELPER_INSTANCE: __EnumSetConstHelper = __EnumSetConstHelper
const CONST_HELPER_INSTANCE: __EnumSetConstHelper = __EnumSetConstHelper
ConstHelper
.Source§const ALL_BITS: Self::Repr = {transmute(0x0fff): <pieces::Piece as enumset::__internal::EnumSetTypePrivate>::Repr}
const ALL_BITS: Self::Repr = {transmute(0x0fff): <pieces::Piece as enumset::__internal::EnumSetTypePrivate>::Repr}
Source§const VARIANT_COUNT: u32 = 12u32
const VARIANT_COUNT: u32 = 12u32
Source§type ConstHelper = __EnumSetConstHelper
type ConstHelper = __EnumSetConstHelper
enum_set!
macro among other things.Source§fn enum_into_u32(self) -> u32
fn enum_into_u32(self) -> u32
Source§unsafe fn enum_from_u32(val: u32) -> Self
unsafe fn enum_from_u32(val: u32) -> Self
Source§impl Ord for Piece
impl Ord for Piece
Source§impl PartialOrd for Piece
impl PartialOrd for Piece
Source§impl Reflectable for Piece
We reflect a piece to it’s correspondent on the opposite side.
impl Reflectable for Piece
We reflect a piece to it’s correspondent on the opposite side.
impl Copy for Piece
impl EnumSetType for Piece
impl Eq for Piece
Auto Trait Implementations§
impl Freeze for Piece
impl RefUnwindSafe for Piece
impl Send for Piece
impl Sync for Piece
impl Unpin for Piece
impl UnwindSafe for Piece
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
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>
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>
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