[][src]Trait shakmaty::Setup

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

A not necessarily legal position.

Required methods

fn board(&self) -> &Board

Piece positions on the board.

fn pockets(&self) -> Option<&Material>

Pockets in chess variants like Crazyhouse.

fn turn(&self) -> Color

Side to move.

fn castling_rights(&self) -> Bitboard

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);

fn ep_square(&self) -> Option<Square>

En passant target square on the third or sixth rank.

fn remaining_checks(&self) -> Option<&RemainingChecks>

Remaining checks in chess variants like Three-Check.

fn halfmoves(&self) -> u32

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);

fn fullmoves(&self) -> u32

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(), 1);
Loading content...

Provided methods

fn us(&self) -> Bitboard

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));

fn our(&self, role: Role) -> Bitboard

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));

fn them(&self) -> Bitboard

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));

fn their(&self, role: Role) -> Bitboard

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 Chess[src]

impl Setup for Atomic[src]

impl Setup for Crazyhouse[src]

impl Setup for Giveaway[src]

impl Setup for Horde[src]

impl Setup for KingOfTheHill[src]

impl Setup for RacingKings[src]

impl Setup for ThreeCheck[src]

Loading content...