[][src]Trait shakmaty::Setup

pub trait Setup {
    pub fn board(&self) -> &Board;
pub fn pockets(&self) -> Option<&Material>;
pub fn turn(&self) -> Color;
pub fn castling_rights(&self) -> Bitboard;
pub fn ep_square(&self) -> Option<Square>;
pub fn remaining_checks(&self) -> Option<&RemainingChecks>;
pub fn halfmoves(&self) -> u32;
pub fn fullmoves(&self) -> NonZeroU32; pub fn us(&self) -> Bitboard { ... }
pub fn our(&self, role: Role) -> Bitboard { ... }
pub fn them(&self) -> Bitboard { ... }
pub fn their(&self, role: Role) -> Bitboard { ... } }

A not necessarily legal position.

Required methods

pub fn board(&self) -> &Board[src]

Piece positions on the board.

pub fn pockets(&self) -> Option<&Material>[src]

Pockets in chess variants like Crazyhouse.

pub fn turn(&self) -> Color[src]

Side to move.

pub fn castling_rights(&self) -> Bitboard[src]

Castling rights in terms of corresponding rook positions.

use shakmaty::{Bitboard, Chess, Setup};

let pos = Chess::default();
let rooks = pos.castling_rights();
// 1 . . . . . . 1
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// 1 . . . . . . 1

assert_eq!(rooks, Bitboard::CORNERS);

pub fn ep_square(&self) -> Option<Square>[src]

En passant target square on the third or sixth rank.

pub fn remaining_checks(&self) -> Option<&RemainingChecks>[src]

Remaining checks in chess variants like Three-Check.

pub fn halfmoves(&self) -> u32[src]

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

Examples

use shakmaty::{Chess, Setup};

let pos = Chess::default();
assert_eq!(pos.halfmoves(), 0);

pub fn fullmoves(&self) -> NonZeroU32[src]

Current move number.

Starts at 1 and is increased after every black move.

Examples

use shakmaty::{Chess, Setup};

let pos = Chess::default();
assert_eq!(pos.fullmoves().get(), 1);
Loading content...

Provided methods

pub fn us(&self) -> Bitboard[src]

Squares occupied by the side to move.

Examples

use shakmaty::{Bitboard, Chess, Rank, Setup};

let pos = Chess::default();
let mask = pos.us();
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1

assert_eq!(mask, Bitboard::from(Rank::First) | Bitboard::from(Rank::Second));

pub fn our(&self, role: Role) -> Bitboard[src]

Squares occupied by a given piece type of the side to move.

Examples

use shakmaty::{Bitboard, Chess, Role, Setup, Square};

let pos = Chess::default();
let mask = pos.our(Role::Queen);
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . 1 . . . .

assert_eq!(mask, Bitboard::from_square(Square::D1));

pub fn them(&self) -> Bitboard[src]

Squares occupied by the waiting player.

Examples

use shakmaty::{Bitboard, Chess, Rank, Setup};

let pos = Chess::default();
let mask = pos.them();
// 1 1 1 1 1 1 1 1
// 1 1 1 1 1 1 1 1
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .

assert_eq!(mask, Bitboard::from(Rank::Seventh) | Bitboard::from(Rank::Eighth));

pub fn their(&self, role: Role) -> Bitboard[src]

Squares occupied by a given piece type of the waiting player.

Examples

use shakmaty::{Bitboard, Chess, Role, Setup, Square};

let pos = Chess::default();
let mask = pos.their(Role::Queen);
// . . . 1 . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .
// . . . . . . . .

assert_eq!(mask, Bitboard::from_square(Square::D8));
Loading content...

Implementors

impl Setup for VariantPosition[src]

impl Setup for Fen[src]

impl Setup for Antichess[src]

impl Setup for Atomic[src]

impl Setup for Chess[src]

impl Setup for Crazyhouse[src]

impl Setup for Horde[src]

impl Setup for KingOfTheHill[src]

impl Setup for RacingKings[src]

impl Setup for ThreeCheck[src]

Loading content...