Struct w_chess::Chessboard
source · pub struct Chessboard {
pub history: Vec<ChessMove>,
/* private fields */
}
Fields§
§history: Vec<ChessMove>
Implementations§
source§impl Chessboard
impl Chessboard
sourcepub fn new() -> Self
pub fn new() -> Self
Returns a chessboard with the starting position.
§Examples
use w_chess::Chessboard;
let mut board = Chessboard::new();
board.move_to("e4");
sourcepub fn from_fen(fen: &str) -> Self
pub fn from_fen(fen: &str) -> Self
Returns a chessboard with the position from the FEN string.
§Examples
use w_chess::Chessboard;
let mut board = Chessboard::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
board.move_to("e4");
sourcepub fn get_fen(&self) -> String
pub fn get_fen(&self) -> String
Returns the FEN string of the current position.
§Examples
use w_chess::Chessboard;
let board = Chessboard::new();
assert_eq!(board.get_fen(), "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
sourcepub fn is_checked(&self, color: bool) -> bool
pub fn is_checked(&self, color: bool) -> bool
Returns if the current position is checked.
§Examples
use w_chess::Chessboard;
let board = Chessboard::new();
assert_eq!(board.is_checked(true), false);
sourcepub fn is_mate(&self, color: bool) -> bool
pub fn is_mate(&self, color: bool) -> bool
Returns if the current position is a checkmate.
§Examples
use w_chess::Chessboard;
let board = Chessboard::new();
assert_eq!(board.is_mate(true), false);
sourcepub fn is_stalemate(&self, color: bool) -> bool
pub fn is_stalemate(&self, color: bool) -> bool
Returns if the current position is a stalemate.
§Examples
use w_chess::Chessboard;
let board = Chessboard::new();
assert_eq!(board.is_stalemate(true), false);
sourcepub fn is_fifty_moves(&self) -> bool
pub fn is_fifty_moves(&self) -> bool
Returns if the current position is a fifty moves rule.
§Examples
use w_chess::Chessboard;
let board = Chessboard::new();
assert_eq!(board.is_fifty_moves(), false);
sourcepub fn is_threefold_repetition(&self) -> bool
pub fn is_threefold_repetition(&self) -> bool
Returns if the current position is a threefold repetition.
§Examples
use w_chess::Chessboard;
let board = Chessboard::new();
assert_eq!(board.is_threefold_repetition(), false);
``
Trait Implementations§
source§impl Debug for Chessboard
impl Debug for Chessboard
Auto Trait Implementations§
impl Freeze for Chessboard
impl RefUnwindSafe for Chessboard
impl Send for Chessboard
impl Sync for Chessboard
impl Unpin for Chessboard
impl UnwindSafe for Chessboard
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more