Skip to content

Commit

Permalink
Bench: 22484322
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Sep 14, 2023
1 parent b2724dd commit 2ab9d41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "types.h"


#define QuietEntry(move) (&thread->history[thread->pos.stm][(bool)(BB(fromSq(move)) & threats)][fromSq(move)][toSq(move)])
#define QuietEntry(move) (&thread->history[thread->pos.stm][(bool)(BB(toSq(move)) & threats)][fromSq(move)][toSq(move)])
#define NoisyEntry(move) (&thread->captureHistory[piece(move)][toSq(move)][PieceTypeOf(capturing(move))])
#define ContEntry(offset, move) (&(*(ss-offset)->continuation)[piece(move)][toSq(move)])

Expand Down
21 changes: 4 additions & 17 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,14 @@ static Bitboard Threats(Position *pos, Color c) {
const Bitboard occ = pieceBB(ALL);

Bitboard threats = 0;
Bitboard vulnerable = colorBB(!c) & ~pieceBB(PAWN);

// Pawn threats
Bitboard pawn_attacks = PawnBBAttackBB(colorPieceBB(c, PAWN), c);
threats |= pawn_attacks & vulnerable;

// Knight and Bishop threats
vulnerable &= ~(pieceBB(KNIGHT) | pieceBB(BISHOP));
Bitboard minor_attacks = 0;
threats |= PawnBBAttackBB(colorPieceBB(c, PAWN), c);
Bitboard knights = colorPieceBB(c, KNIGHT);
while (knights) minor_attacks |= AttackBB(KNIGHT, PopLsb(&knights), occ);
while (knights) threats |= AttackBB(KNIGHT, PopLsb(&knights), occ);
Bitboard bishops = colorPieceBB(c, BISHOP);
while (bishops) minor_attacks |= AttackBB(BISHOP, PopLsb(&bishops), occ);
threats |= minor_attacks & vulnerable;

// Rook threats
vulnerable &= ~pieceBB(ROOK);
Bitboard rook_attacks = 0;
while (bishops) threats |= AttackBB(BISHOP, PopLsb(&bishops), occ);
Bitboard rooks = colorPieceBB(c, ROOK);
while (rooks) rook_attacks |= AttackBB(ROOK, PopLsb(&rooks), occ);
threats |= rook_attacks & vulnerable;
while (rooks) threats |= AttackBB(ROOK, PopLsb(&rooks), occ);

return threats;
}
Expand Down

0 comments on commit 2ab9d41

Please sign in to comment.