[board] Remove some dead code from Board

This commit is contained in:
Eryn Wells 2025-05-23 14:14:49 -07:00
parent a9268ad194
commit 5c5d9d5018

View file

@ -117,59 +117,6 @@ impl Board {
}
}
/*
impl Board {
/// The rook to use for a castling move.
#[must_use]
pub fn rook_for_castle(&self, player: Color, castle: Castle) -> Option<PlacedPiece> {
let square = castle.parameters(player).rook_origin_square();
self.piece_on_square(square)
}
/// Returns `true` if the player is able to castle on the given side of the board.
///
/// The following requirements must be met:
///
/// 1. The player must still have the right to castle on that side of the
/// board. The king and rook involved in the castle must not have moved.
/// 1. The spaces between the king and rook must be clear
/// 2. The king must not be in check
/// 3. In the course of castling on that side, the king must not pass
/// through a square that an enemy piece can see
#[must_use]
pub fn player_can_castle(&self, player: Color, castle: Castle) -> bool {
if !self.castling_rights.is_set(player, castle) {
return false;
}
let castling_parameters = castle.parameters(player);
let all_pieces = self.pieces.all_pieces();
if !(all_pieces & castling_parameters.clear_squares()).is_empty() {
return false;
}
// TODO: Reimplement king_danger here or in Position.
// let danger_squares = self.king_danger(player);
// if !(danger_squares & castling_parameters.check_squares()).is_empty() {
// return false;
// }
true
}
pub fn iter_all_pieces(&self) -> impl Iterator<Item = PlacedPiece> + '_ {
self.pieces.iter()
}
pub fn iter_pieces_of_color(&self, color: Color) -> impl Iterator<Item = PlacedPiece> + '_ {
self.pieces
.iter()
.filter(move |piece| piece.color() == color)
}
}
*/
#[cfg(test)]
mod tests {
use super::*;