From 3bc75f843f867dafedbfd23d2597e5a27b426197 Mon Sep 17 00:00:00 2001 From: rektdie Date: Tue, 26 Mar 2024 08:15:34 +0100 Subject: [PATCH] added getQueenAttack function --- source/movegen.cpp | 15 +++++++++++++++ source/movegen.h | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/movegen.cpp b/source/movegen.cpp index 0c36390..8ea7109 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -256,4 +256,19 @@ Bitboard getRookAttack(int square, U64 occupancy) { occupancy >>= (64 - rookRelevantBits[square]); return rookAttacks[square][occupancy]; +} + +Bitboard getQueenAttack(int square, U64 occupancy) { + U64 bishopOccupancy = occupancy; + U64 rookOccupancy = occupancy; + + bishopOccupancy &= bishopMasks[square].GetBoard(); + bishopOccupancy *= bishopMagicNumbers[square]; + bishopOccupancy >>= (64 - bishopRelevantBits[square]); + + rookOccupancy &= rookMasks[square].GetBoard(); + rookOccupancy *= rookMagicNumbers[square]; + rookOccupancy >>= (64 - rookRelevantBits[square]); + + return rookAttacks[square][rookOccupancy] | bishopAttacks[square][bishopOccupancy]; } \ No newline at end of file diff --git a/source/movegen.h b/source/movegen.h index 1d8b74d..c5886ff 100644 --- a/source/movegen.h +++ b/source/movegen.h @@ -212,4 +212,5 @@ void initLeaperAttacks(); void initSliderAttacks(); Bitboard getBishopAttack(int square, U64 occupancy); -Bitboard getRookAttack(int square, U64 occupancy); \ No newline at end of file +Bitboard getRookAttack(int square, U64 occupancy); +Bitboard getQueenAttack(int square, U64 occupancy); \ No newline at end of file