Skip to main content

Board

Struct Board 

Source
pub struct Board { /* private fields */ }
Expand description

Validated location of pieces on the board.

A board is structurally valid when:

  • the Black and White squares are disjoint;
  • the six role bitboards are pairwise disjoint;
  • the union of the player bitboards equals the union of the role bitboards; and
  • occupied is that shared union.

This does not imply that the board is a legal chess position.

Implementations§

Source§

impl Board

Board Move API.

Source

pub const fn attacks_on( self, square: Square, attacker: Player, occupied: Bitboard, ) -> Bitboard

Pieces of attacker on this board that attack square.

occupied is the occupancy view used for line-of-sight and for filtering attackers. This supports king-safety checks after the other player moves: removed pieces are ignored, and slider rays use the post-move blockers.

This is not a full hypothetical-board query for moves by attacker, because piece roles and players still come from self.

Source

pub const fn attacked_en_passant( self, en_passant: EnPassant, turn: Player, ) -> Option<EnPassant>

Source

pub const fn effective_en_passant( self, en_passant: Option<EnPassant>, turn: Player, ) -> Option<EnPassant>

Source

pub fn king_shields(self, player: Player) -> Bitboard

Source§

impl Board

Board Construction API.

Source

pub const EMPTY: Board

Source

pub const fn freestyle(i: Scharnagl) -> Board

Source

pub const fn new(parts: Parts) -> Result<Board>

Source

pub const fn parts(self) -> Parts

Source

pub const fn standard() -> Board

Source§

impl Board

Board Chess API.

Source

pub const fn bishops(self) -> Bitboard

Source

pub const fn bishops_and_queens(self) -> Bitboard

Source

pub const fn black(self) -> Bitboard

Source

pub const fn king_of(self, player: Player) -> Option<Square>

Source

pub const fn kings(self) -> Bitboard

Source

pub const fn knights(self) -> Bitboard

Source

pub const fn occupied(self) -> Bitboard

Source

pub const fn pawns(self) -> Bitboard

Source

pub const fn player(self, player: Player) -> Bitboard

Source

pub const fn player_at(self, square: Square) -> Option<Player>

Source

pub const fn queens(self) -> Bitboard

Source

pub const fn role(self, role: Role) -> Bitboard

Source

pub const fn role_at(self, square: Square) -> Option<Role>

Source

pub const fn rooks(self) -> Bitboard

Source

pub const fn rooks_and_queens(self) -> Bitboard

Source

pub const fn sliders(self) -> Bitboard

Bishops, rooks and queens.

Source

pub const fn steppers(self) -> Bitboard

Pawns, knights and kings.

Source

pub const fn unique_king_of(self, player: Player) -> Option<Square>

Source

pub const fn white(self) -> Bitboard

Source§

impl Board

Board Map API.

Source

pub const fn clear(&mut self)

Source

pub const fn get(self, square: Square) -> Option<Piece>

Source

pub const fn insert(&mut self, square: Square, piece: Piece) -> Option<Piece>

Source

pub const fn remove(&mut self, square: Square) -> Option<Piece>

Source§

impl Board

Source

pub fn fen(self) -> String

Source§

impl Board

Source

pub const fn polyglot_id(self) -> Id

Source

pub const fn standard_id(self) -> Id

Source

pub const fn id(self, basis: &Basis) -> Id

Trait Implementations§

Source§

impl Clone for Board

Source§

fn clone(&self) -> Board

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Board

Source§

impl Debug for Board

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Board

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Board

Source§

impl From<Board> for Parts

Source§

fn from(board: Board) -> Self

Converts to this type from the input type.
Source§

impl Ord for Board

Source§

fn cmp(&self, other: &Board) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Board

Source§

fn eq(&self, other: &Board) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Board

Source§

fn partial_cmp(&self, other: &Board) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Board

Source§

impl TryFrom<Parts> for Board

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(parts: Parts) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Board

§

impl RefUnwindSafe for Board

§

impl Send for Board

§

impl Sync for Board

§

impl Unpin for Board

§

impl UnsafeUnpin for Board

§

impl UnwindSafe for Board

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.