Struct alcibiades::CastlingRights
[−]
[src]
pub struct CastlingRights(_);
Holds information about which player can castle on which side.
The castling rights are held in a usize
value. The lowest 4 bits
of the value contain the whole needed information. It is laid out
in the following way:
usize 3 2 1 0
+----------------------+---+---+---+---+
| | | | | |
| Unused (zeros) |Castling flags |
| | | | | |
+----------------------+---+---+---+---+
bit 0 -- if set, white can castle on queen-side;
bit 1 -- if set, white can castle on king-side;
bit 2 -- if set, black can castle on queen-side;
bit 3 -- if set, black can castle on king-side.
Methods
impl CastlingRights
[src]
fn new(value: usize) -> CastlingRights
Creates a new instance.
The least significant 4 bits of value
are used as a raw
value for the new instance.
fn value(&self) -> usize
Returns the contained raw value (between 0 and 15).
fn grant(&mut self, player: Color, side: CastlingSide) -> bool
Grants a given player the right to castle on a given side.
This method returns true
if the player did not have the
right to castle on the given side before this method was
called, and false
otherwise.
fn update(&mut self, orig_square: Square, dest_square: Square)
Updates the castling rights after played move.
orig_square
and dest_square
describe the played move.
fn can_castle(&self, player: Color, side: CastlingSide) -> bool
Returns if a given player has the rights to castle on a given side.
Trait Implementations
impl Clone for CastlingRights
[src]
fn clone(&self) -> CastlingRights
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more