pub struct Castles { /* private fields */ }
Expand description
Castling paths and unmoved rooks.
Implementations§
source§impl Castles
impl Castles
pub const fn empty(mode: CastlingMode) -> Castles
pub fn from_setup(setup: &Setup, mode: CastlingMode) -> Result<Castles, Castles>
pub const fn any(&self) -> bool
pub const fn is_empty(&self) -> bool
pub fn has(&self, color: Color, side: CastlingSide) -> bool
pub const fn has_side(&self, color: Color) -> bool
👎Deprecated: renamed to Castles::has_color()
pub const fn has_color(&self, color: Color) -> bool
pub fn discard_rook(&mut self, square: Square)
pub fn discard_side(&mut self, color: Color)
👎Deprecated: renamed to Castles::discard_color()
pub fn discard_color(&mut self, color: Color)
pub const fn rook(&self, color: Color, side: CastlingSide) -> Option<Square>
sourcepub const fn path(&self, color: Color, side: CastlingSide) -> Bitboard
pub const fn path(&self, color: Color, side: CastlingSide) -> Bitboard
Gets the squares that need to be empty so that castling is possible on the given side, assuming the player still has the required castling rigths.
Examples
use shakmaty::{Castles, CastlingSide, Bitboard, Color, Square};
let castles = Castles::default();
let path = castles.path(Color::White, CastlingSide::QueenSide);
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// 0 1 1 1 0 . . .
assert_eq!(path, Bitboard::from(Square::B1) | Bitboard::from(Square::C1) | Bitboard::from(Square::D1));
sourcepub const fn castling_rights(&self) -> Bitboard
pub const fn castling_rights(&self) -> Bitboard
Castling rigths in terms of corresponding rook positions.