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