Make more readability refactorings

This commit is contained in:
stefiosif
2024-08-28 23:27:40 +03:00
parent 46cf0f0d1f
commit e61d247411
6 changed files with 42 additions and 60 deletions

View File

@@ -83,25 +83,19 @@ impl Board {
Color::White => (&self.white_pieces, Color::Black),
};
have_common_bit(
opponent[PieceType::Pawn].bitboard,
fetch_pawn_attacks(square, own_color),
) || have_common_bit(
opponent[PieceType::Knight].bitboard,
fetch_knight_attacks(square),
) || have_common_bit(
opponent[PieceType::Bishop].bitboard,
fetch_bishop_attacks(all_occupancies, square),
) || have_common_bit(
opponent[PieceType::Rook].bitboard,
fetch_rook_attacks(all_occupancies, square),
) || have_common_bit(
opponent[PieceType::Queen].bitboard,
fetch_queen_attacks(all_occupancies, square),
) || have_common_bit(
opponent[PieceType::King].bitboard,
fetch_king_attacks(square),
)
let pawns = opponent[PieceType::Pawn].bitboard;
let knights = opponent[PieceType::Knight].bitboard;
let bishops = opponent[PieceType::Bishop].bitboard;
let rooks = opponent[PieceType::Rook].bitboard;
let queens = opponent[PieceType::Queen].bitboard;
let king = opponent[PieceType::King].bitboard;
have_common_bit(pawns, fetch_pawn_attacks(square, own_color))
|| have_common_bit(knights, fetch_knight_attacks(square))
|| have_common_bit(bishops, fetch_bishop_attacks(all_occupancies, square))
|| have_common_bit(rooks, fetch_rook_attacks(all_occupancies, square))
|| have_common_bit(queens, fetch_queen_attacks(all_occupancies, square))
|| have_common_bit(king, fetch_king_attacks(square))
}
pub fn king_under_check(&self, color: Color) -> bool {
@@ -144,7 +138,7 @@ impl Board {
pieces,
all_occupancies,
opponent_occupancies,
self.state.en_passant_target_square(),
self.state.en_passant_square(),
color,
),
PieceType::Knight => knight_pseudo_moves(pieces, all_occupancies, own_occupancies),
@@ -284,16 +278,4 @@ mod tests {
Ok(())
}
#[test]
fn test_fifty_move_draw() -> Result<(), String> {
//TODO: make a MoveHistory/BoardHistory/GameHistory struct
Ok(())
}
#[test]
fn test_threefold_repetition() -> Result<(), String> {
//TODO: make a MoveHistory/BoardHistory/GameHistory struct
Ok(())
}
}