[board] Implement ply and full move counters on Position
Pipe these numbers through the Builders
This commit is contained in:
parent
829d9af52c
commit
dbbf2d4c46
3 changed files with 63 additions and 2 deletions
|
@ -18,6 +18,9 @@ pub struct Position {
|
|||
pieces: PieceBitBoards,
|
||||
en_passant_square: Option<Square>,
|
||||
sight: [OnceCell<BitBoard>; 2],
|
||||
|
||||
half_move_counter: u16,
|
||||
full_move_number: u16,
|
||||
}
|
||||
|
||||
impl Position {
|
||||
|
@ -28,6 +31,8 @@ impl Position {
|
|||
pieces: PieceBitBoards::default(),
|
||||
en_passant_square: None,
|
||||
sight: [OnceCell::new(), OnceCell::new()],
|
||||
half_move_counter: 0,
|
||||
full_move_number: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +62,8 @@ impl Position {
|
|||
pieces: PieceBitBoards::new([white_pieces, black_pieces]),
|
||||
en_passant_square: None,
|
||||
sight: [OnceCell::new(), OnceCell::new()],
|
||||
half_move_counter: 0,
|
||||
full_move_number: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +71,14 @@ impl Position {
|
|||
self.color_to_move
|
||||
}
|
||||
|
||||
pub fn move_number(&self) -> u16 {
|
||||
self.full_move_number
|
||||
}
|
||||
|
||||
pub fn ply_counter(&self) -> u16 {
|
||||
self.half_move_counter
|
||||
}
|
||||
|
||||
/// Returns true if the player has the right to castle on the given side of
|
||||
/// the board.
|
||||
///
|
||||
|
@ -191,6 +206,8 @@ impl Position {
|
|||
flags: Flags,
|
||||
pieces: PieceBitBoards,
|
||||
en_passant_square: Option<Square>,
|
||||
half_move_counter: u16,
|
||||
full_move_number: u16,
|
||||
) -> Self {
|
||||
Self {
|
||||
color_to_move: player_to_move,
|
||||
|
@ -198,6 +215,8 @@ impl Position {
|
|||
en_passant_square,
|
||||
pieces,
|
||||
sight: [OnceCell::new(), OnceCell::new()],
|
||||
half_move_counter: 0,
|
||||
full_move_number: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue