Struct shakmaty::Setup

source ·
pub struct Setup {
    pub board: Board,
    pub promoted: Bitboard,
    pub pockets: Option<ByColor<ByRole<u8>>>,
    pub turn: Color,
    pub castling_rights: Bitboard,
    pub ep_square: Option<Square>,
    pub remaining_checks: Option<ByColor<RemainingChecks>>,
    pub halfmoves: u32,
    pub fullmoves: NonZeroU32,
}
Expand description

A not necessarily legal position.

§Equality

Hash, PartialEq, and Eq are implemented in terms of structural equality.

Fields§

§board: Board

Piece positions on the board.

§promoted: Bitboard

Positions of tracked promoted pieces. Used only for Crazyhouse.

§pockets: Option<ByColor<ByRole<u8>>>

Pockets in chess variants like Crazyhouse.

§turn: Color

Side to move.

§castling_rights: Bitboard

Castling rights in terms of corresponding rook positions.

§Examples

use shakmaty::{Bitboard, Setup};

let setup = Setup::default();
let rooks = setup.castling_rights;
// 1 . . . . . . 1
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// 1 . . . . . . 1

assert_eq!(rooks, Bitboard::CORNERS);
§ep_square: Option<Square>

En passant target square. Valid target squares are on the third or sixth rank.

§remaining_checks: Option<ByColor<RemainingChecks>>

Remaining checks in chess variants like Three-Check.

§halfmoves: u32

Number of half-moves since the last capture or pawn move.

§Examples

use shakmaty::Setup;

let setup = Setup::default();
assert_eq!(setup.halfmoves, 0);
§fullmoves: NonZeroU32

Current move number.

Starts at 1 and is increased after every black move.

§Examples

use shakmaty::Setup;

let setup = Setup::default();
assert_eq!(setup.fullmoves.get(), 1);

Implementations§

source§

impl Setup

source

pub const fn empty() -> Setup

Plain, empty board. No pieces. White to play.

source

pub const fn initial() -> Setup

Default board setup.

source

pub fn swap_turn(&mut self)

source

pub fn position<P: FromSetup>( self, mode: CastlingMode ) -> Result<P, PositionError<P>>

Trait Implementations§

source§

impl Clone for Setup

source§

fn clone(&self) -> Setup

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Setup

source§

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

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

impl Default for Setup

source§

fn default() -> Setup

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

impl From<Epd> for Setup

source§

fn from(epd: Epd) -> Setup

Converts to this type from the input type.
source§

impl From<Fen> for Setup

source§

fn from(fen: Fen) -> Setup

Converts to this type from the input type.
source§

impl From<Setup> for Epd

source§

fn from(setup: Setup) -> Epd

Converts to this type from the input type.
source§

impl From<Setup> for Fen

source§

fn from(setup: Setup) -> Fen

Converts to this type from the input type.
source§

impl Hash for Setup

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Setup

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Setup

source§

impl StructuralPartialEq for Setup

Auto Trait Implementations§

§

impl Freeze for Setup

§

impl RefUnwindSafe for Setup

§

impl Send for Setup

§

impl Sync for Setup

§

impl Unpin for Setup

§

impl UnwindSafe for Setup

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> 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,

§

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>,

§

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>,

§

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.