From 1b5319c702b93f5614892caaf45bdd48b64322c5 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Wed, 24 Jan 2024 17:09:15 -0800 Subject: [PATCH] [board] Pass a Color to Position::king_square Now it can return either color's king. --- board/src/position/position.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/board/src/position/position.rs b/board/src/position/position.rs index 82ef1bd..b72becb 100644 --- a/board/src/position/position.rs +++ b/board/src/position/position.rs @@ -189,12 +189,12 @@ impl Position { pub(crate) fn is_king_in_check(&self) -> bool { let sight_of_opposing_player = self.sight_of_player(self.color_to_move.other()); - sight_of_opposing_player.is_set(self.king_square()) + sight_of_opposing_player.is_set(self.king_square(self.color_to_move)) } - fn king_square(&self) -> Square { + pub(crate) fn king_square(&self, player: Color) -> Square { self.pieces - .bitboard_for_piece(&Piece::king(self.color_to_move)) + .bitboard_for_piece(&Piece::king(player)) .occupied_squares() .next() .unwrap()