implemented AttacksTo function | bench 4333527
This commit is contained in:
1 parent
8fa390ed5f
commit
5e18083113
2 files changed
+31
No files matched your search
@@ -522,3 +522,32 @@ void Board::ResetAccPair() {
|
||||
blackPieces.PopBit(square);
|
||||
}
|
||||
}
|
||||
|
||||
Bitboard Board::AttacksTo(int square) {
|
||||
Bitboard attacks;
|
||||
|
||||
// Pawn attacks
|
||||
|
||||
// Opponent attacks
|
||||
attacks |= (MOVEGEN::pawnAttacks[sideToMove][square] & colors[!sideToMove] & pieces[Pawn]);
|
||||
|
||||
// Own piece attacks
|
||||
attacks |= (MOVEGEN::pawnAttacks[!sideToMove][square] & colors[sideToMove] & pieces[Pawn]);
|
||||
|
||||
// Knight
|
||||
attacks |= (MOVEGEN::knightAttacks[square] & pieces[Knight]);
|
||||
|
||||
// King
|
||||
attacks |= (MOVEGEN::kingAttacks[square] & pieces[King]);
|
||||
|
||||
Bitboard bishopAttacks = MOVEGEN::getBishopAttack(square, occupied);
|
||||
Bitboard rookAttacks = MOVEGEN::getRookAttack(square, occupied);
|
||||
|
||||
// Rook or queen
|
||||
attacks |= (rookAttacks & (pieces[Rook] | pieces[Queen]));
|
||||
|
||||
// Bishop or queen
|
||||
attacks |= (bishopAttacks & (pieces[Bishop] | pieces[Queen]));
|
||||
|
||||
return attacks;
|
||||
}
|
||||
Reference in new issue
Block a user