From b913f4673a5ddb9111c6510e582c313a0d09caec Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 6 Apr 2024 12:19:10 +0100 Subject: [PATCH] Add 'copy-on-make' 'ChessBoard::play_move' --- src/board/chess_board/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/board/chess_board/mod.rs b/src/board/chess_board/mod.rs index 2f0f31b..2b1d5cb 100644 --- a/src/board/chess_board/mod.rs +++ b/src/board/chess_board/mod.rs @@ -132,6 +132,14 @@ impl ChessBoard { 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, /// etc...). #[inline(always)]