pub struct PieceSets { /* private fields */ }
Expand description
A Piece-Centric representation of pieces on a chessboard. A Bitboard is used to encode the squares of each chess piece. PieceSets indexes by piece to get squares, as opposed to Mailbox which indexes by square to get a piece.
Implementations§
Source§impl PieceSets
impl PieceSets
Sourcepub fn start_position() -> Self
pub fn start_position() -> Self
Returns PieceSets arranged in starting chess position.
Sourcepub fn occupied(&self) -> Bitboard
pub fn occupied(&self) -> Bitboard
Return a bitboard representing the set of squares occupied by any piece. Note: Compiler can auto-vectorize, however looking at assembly on godbolt may be limited to avx128. Does not seem to use avx512 on supported cpus.
Sourcepub fn color_occupied(&self, color: Color) -> Bitboard
pub fn color_occupied(&self, color: Color) -> Bitboard
Return a bitboard representing the set of squares occupied by piece of color.
Sourcepub fn on_square(&self, sq: Square) -> Option<Piece>
pub fn on_square(&self, sq: Square) -> Option<Piece>
Finds and returns the first piece found on target square, or None.
Sourcepub fn on_player_square(&self, player: Color, sq: Square) -> Option<PieceKind>
pub fn on_player_square(&self, player: Color, sq: Square) -> Option<PieceKind>
Finds and returns the first PieceKind found on target square of player’s pieces, or None.
Sourcepub fn pretty(&self) -> String
pub fn pretty(&self) -> String
Returns pretty-printed chess board representation of Self. Uses Mailbox pretty.
Sourcepub fn is_disjoint(&self) -> bool
pub fn is_disjoint(&self) -> bool
Returns true if all sets in self are disjoint (mutually exclusive). In other words, there is no more than 1 piece per square. If a square is in one set, it is in no other. PieceSets should be disjoint at all times.
Trait Implementations§
Source§impl FenComponent for PieceSets
Placement FenComponent.
impl FenComponent for PieceSets
Placement FenComponent.
type Error = ParseFenError
fn try_from_fen_str(s: &str) -> Result<Self, Self::Error>
fn to_fen_str(&self) -> String
Source§impl Index<Color> for PieceSets
Get a slice of all pieces of same color.
impl Index<Color> for PieceSets
Get a slice of all pieces of same color.
let ps = PieceSets::start_position();
let w_slice = &ps[Color::White];
let b_slice = &ps[Color::Black];
assert_eq!(b_slice.len(), w_slice.len());
assert_eq!(b_slice.len(), 6);