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 { ... }
}
Expand description
A not necessarily legal position.
Required Methods
sourcefn castling_rights(&self) -> Bitboard
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);
sourcefn remaining_checks(&self) -> Option<&RemainingChecks>
fn remaining_checks(&self) -> Option<&RemainingChecks>
Remaining checks in chess variants like Three-Check.
sourcefn halfmoves(&self) -> u32
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);
Provided Methods
sourcefn us(&self) -> Bitboard
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));
sourcefn our(&self, role: Role) -> Bitboard
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));
sourcefn them(&self) -> Bitboard
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));
sourcefn their(&self, role: Role) -> Bitboard
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));