Enum candidate::CastleRights
source · pub enum CastleRights {
NoRights,
KingSide,
QueenSide,
Both,
}
Expand description
What castle rights does a particular player have?
Variants§
Implementations§
source§impl CastleRights
impl CastleRights
sourcepub fn has_kingside(&self) -> bool
pub fn has_kingside(&self) -> bool
Can I castle kingside?
sourcepub fn has_queenside(&self) -> bool
pub fn has_queenside(&self) -> bool
Can I castle queenside?
pub fn square_to_castle_rights(color: Color, sq: Square) -> CastleRights
sourcepub fn kingside_squares(&self, color: Color) -> BitBoard ⓘ
pub fn kingside_squares(&self, color: Color) -> BitBoard ⓘ
What squares need to be empty to castle kingside?
sourcepub fn queenside_squares(&self, color: Color) -> BitBoard ⓘ
pub fn queenside_squares(&self, color: Color) -> BitBoard ⓘ
What squares need to be empty to castle queenside?
sourcepub fn remove(&self, remove: CastleRights) -> CastleRights
pub fn remove(&self, remove: CastleRights) -> CastleRights
Remove castle rights, and return a new CastleRights
.
sourcepub fn add(&self, add: CastleRights) -> CastleRights
pub fn add(&self, add: CastleRights) -> CastleRights
Add some castle rights, and return a new CastleRights
.
sourcepub fn from_index(i: usize) -> CastleRights
pub fn from_index(i: usize) -> CastleRights
Convert usize
to CastleRights
. Panic if invalid number.
sourcepub fn unmoved_rooks(&self, color: Color) -> BitBoard ⓘ
pub fn unmoved_rooks(&self, color: Color) -> BitBoard ⓘ
Which rooks can we “guarantee” we haven’t moved yet?
sourcepub fn to_string(&self, color: Color) -> String
pub fn to_string(&self, color: Color) -> String
Convert the castle rights to an FEN compatible string.
use candidate::{CastleRights, Color};
assert_eq!(CastleRights::NoRights.to_string(Color::White), "");
assert_eq!(CastleRights::Both.to_string(Color::Black), "kq");
assert_eq!(CastleRights::KingSide.to_string(Color::White), "K");
assert_eq!(CastleRights::QueenSide.to_string(Color::Black), "q");
sourcepub fn rook_square_to_castle_rights(square: Square) -> CastleRights
pub fn rook_square_to_castle_rights(square: Square) -> CastleRights
Given a square of a rook, which side is it on? Note: It is invalid to pass in a non-rook square. The code may panic.
Trait Implementations§
source§impl Clone for CastleRights
impl Clone for CastleRights
source§fn clone(&self) -> CastleRights
fn clone(&self) -> CastleRights
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for CastleRights
impl Debug for CastleRights
source§impl Hash for CastleRights
impl Hash for CastleRights
source§impl PartialEq<CastleRights> for CastleRights
impl PartialEq<CastleRights> for CastleRights
source§fn eq(&self, other: &CastleRights) -> bool
fn eq(&self, other: &CastleRights) -> bool
source§impl PartialOrd<CastleRights> for CastleRights
impl PartialOrd<CastleRights> for CastleRights
source§fn partial_cmp(&self, other: &CastleRights) -> Option<Ordering>
fn partial_cmp(&self, other: &CastleRights) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more