Improve readability and remove redundant code
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user