Struct friendly_chess::chess::Chess

source ·
pub struct Chess {
    pub board: Board,
    pub turn: Color,
    pub kings: Kings,
    pub castling_rights: CastlingRights,
    pub history: MoveHistory,
    pub white_captures: Vec<Piece>,
    pub black_captures: Vec<Piece>,
    pub half_moves: u8,
    pub full_moves: u8,
    pub en_passant_sq: Option<SquareCoordinate>,
    /* private fields */
}

Fields§

§board: Board§turn: Color§kings: Kings

the kings’ positions on the board

§castling_rights: CastlingRights§history: MoveHistory§white_captures: Vec<Piece>§black_captures: Vec<Piece>§half_moves: u8§full_moves: u8§en_passant_sq: Option<SquareCoordinate>

Implementations§

source§

impl Chess

source

pub fn new() -> Self

source

pub fn play_move(&mut self, m: Move) -> Result<(), ChessError>

source

pub fn make_move(&mut self, m: Move) -> Result<(), ChessError>

source

pub fn undo_move(&mut self) -> Result<(), ChessError>

source

pub fn moves_for_piece_type()

Get all legal moves for a specific piece type

source

pub fn moves_for_square( &mut self, sq: SquareCoordinate ) -> Result<Vec<Move>, ChessError>

Get all legal moves for the piece on the specified square

source

pub fn moves(&mut self) -> Result<Vec<Move>, ChessError>

Get all legal moves for the player to move

source

pub fn in_check(&self) -> Result<bool, ChessError>

Return true if the current player to move is in check

source

pub fn is_checkmate(&mut self) -> Result<bool, ChessError>

source

pub fn is_draw(&mut self) -> Result<bool, ChessError>

source

pub fn is_stalemate(&mut self) -> Result<bool, ChessError>

source

pub fn is_insufficient_material(&self) -> Result<bool, ChessError>

source

pub fn is_50_moves(&self) -> Result<bool, ChessError>

source

pub fn is_threefold_repetition(&self) -> Result<bool, ChessError>

source

pub fn is_attacked(&self, from: SquareCoordinate) -> Result<bool, ChessError>

Check if a square is attacked by opponent pieces

source

pub fn change_turn(&mut self)

source

pub fn get(&self, sq: SquareCoordinate) -> Result<Option<Piece>, ChessError>

Return the PieceType and its associated value on a square. Return an ChessError if the index is out of range.

Some(t) means an occupied square, None means the square is empty.

source

pub fn set( &mut self, sq: SquareCoordinate, piece: PieceType, color: Color ) -> Result<(Piece, usize), ChessError>

Put a piece at specific index on the board. Return the piece and index if succeed, or an ChessError if not.

Note: this does not update castling rights

source

pub fn remove(&mut self, sq: SquareCoordinate) -> Result<(), ChessError>

source

pub fn get_fen(&self) -> Result<String, ChessError>

source

pub fn load_fen(&mut self, fen: String) -> Result<(), ChessError>

source

pub fn perft(&mut self, depth: u8, yah: bool) -> Result<u64, ChessError>

source

pub fn clear(&mut self)

Auto Trait Implementations§

§

impl RefUnwindSafe for Chess

§

impl Send for Chess

§

impl Sync for Chess

§

impl Unpin for Chess

§

impl UnwindSafe for Chess

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.