Improve readability and remove redundant code

This commit is contained in:
stefiosif
2024-09-06 20:07:10 +03:00
parent 2081ddac56
commit 6b9650a6f0
7 changed files with 65 additions and 59 deletions

View File

@@ -104,11 +104,13 @@ impl Board {
Color::Black => lsb(self.black_pieces[PieceType::King].bitboard),
};
self.is_attacked(own_king_square, Color::opponent_color(color))
self.is_attacked(own_king_square, color.opponent())
}
pub fn pseudo_moves_all(&self, color: Color) -> Vec<Move> {
pub fn pseudo_moves_all(&self) -> Vec<Move> {
let color = self.state.current_player();
let mut moves = vec![];
moves.extend(self.pseudo_moves(color, PieceType::Pawn));
moves.extend(self.pseudo_moves(color, PieceType::Knight));
moves.extend(self.pseudo_moves(color, PieceType::Bishop));
@@ -245,8 +247,8 @@ pub enum Color {
}
impl Color {
pub const fn opponent_color(color: Self) -> Self {
match color {
pub const fn opponent(&self) -> Self {
match self {
Self::White => Self::Black,
Self::Black => Self::White,
}