Struct fen::BoardState
[−]
[src]
pub struct BoardState { pub pieces: Vec<Option<Piece>>, pub side_to_play: Color, pub white_can_oo: bool, pub white_can_ooo: bool, pub black_can_oo: bool, pub black_can_ooo: bool, pub en_passant_square: Option<u8>, pub halfmove_clock: u64, pub fullmove_number: u64, }
The state of a board. You can convert this to and from FEN.
Fields
pieces: Vec<Option<Piece>>
The locations of pieces on the board. This vector must be guaranteed to contain 64 elements.
Indices start at the bottom left of the board, going from left to right then down to up. Index 0 represents a1, index 1 represents b1, index 8 represents a2, ..., index 63 represents h8.
If pieces[n]
is None
, then that means there is no piece on the n
th
square.
side_to_play: Color
The side that will play next. Since white goes first in standard chess,
this should be Color::White
in the initial position.
white_can_oo: bool
Whether white can still castle kingside at some time.
white_can_ooo: bool
Whether white can still castle queenside at some time.
black_can_oo: bool
Whether black can still castle kingside at some time.
black_can_ooo: bool
Whether black can still castle queenside at some time.
en_passant_square: Option<u8>
The en passant target square. If the last move was a two-square pawn
move, this will be the position "behind" the pawn. Otherwise, this will
be None
.
See the documentation for BoardState.pieces
for how squares on the
board are indexed.
halfmove_clock: u64
Number of half-moves (aka "ply") since the last capture or pawn move. If this number is greater than or equal to 50, then either side may claim draw by the fifty-move rule.
fullmove_number: u64
Number of full moves since the beginning of the game. This value begins at 1 and is incremented after black makes a move.
Methods
impl BoardState
[src]
fn from_fen<'a>(fen: &'a str) -> FenResult<'a, BoardState>
Create a BoardState
from a string in Forsyth-Edwards notation.
// this represents the board after the move 1. e4 let fen = "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1"; let board = fen::BoardState::from_fen(fen).unwrap(); // 'e' is the fourth file, '3' is the second rank (due to zero-indexing) // // See docs for BoardState.pieces for information about indexing assert_eq!(board.en_passant_square, Some(4 + 2 * 8));
fn to_fen(&self) -> String
Convert a BoardState into a string in Forsyth-Edwards notation.
let fen = "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1"; let board = fen::BoardState::from_fen(fen).unwrap(); assert_eq!(fen, board.to_fen());
Trait Implementations
impl Debug for BoardState
[src]
impl Eq for BoardState
[src]
impl PartialEq for BoardState
[src]
fn eq(&self, __arg_0: &BoardState) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BoardState) -> bool
This method tests for !=
.