Add 'copy-on-make' 'ChessBoard::play_move'

This commit is contained in:
Bruno BELANYI 2024-04-06 12:19:10 +01:00
parent 29e50a65dc
commit b913f4673a

View file

@ -132,6 +132,14 @@ impl ChessBoard {
self.combined_occupancy ^= start_end; self.combined_occupancy ^= start_end;
} }
/// Play the given [Move], return a copy of the board with the resulting state.
#[inline(always)]
pub fn play_move(&self, chess_move: Move) -> Self {
let mut res = self.clone();
res.play_move_inplace(chess_move);
res
}
/// Play the given [Move] in place, returning all non-revertible state (e.g: en-passant, /// Play the given [Move] in place, returning all non-revertible state (e.g: en-passant,
/// etc...). /// etc...).
#[inline(always)] #[inline(always)]