[board] Pass a Color to Position::king_square

Now it can return either color's king.
This commit is contained in:
Eryn Wells 2024-01-24 17:09:15 -08:00
parent 3c71687838
commit 1b5319c702

View file

@ -189,12 +189,12 @@ impl Position {
pub(crate) fn is_king_in_check(&self) -> bool { pub(crate) fn is_king_in_check(&self) -> bool {
let sight_of_opposing_player = self.sight_of_player(self.color_to_move.other()); 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 self.pieces
.bitboard_for_piece(&Piece::king(self.color_to_move)) .bitboard_for_piece(&Piece::king(player))
.occupied_squares() .occupied_squares()
.next() .next()
.unwrap() .unwrap()