Skip to content

Commit 091aff0

Browse files
ceebomcostalba
authored andcommitted
Evaluate mobility of pinned pieces exactly
Previously some squares could be "incorrectly" awarded to a pinned piece. e.g. in 3k4/1q6/3b4/3Q4/8/5K2/B7/8 b - - 0 1 the black bishop get 4 squares too many and the white queen gets 6. Passed both short TC. LLR: 2.97 (-2.94,2.94) [-1.50,4.50] Total: 4871 W: 934 L: 817 D: 3120 And long TC: LLR: 2.96 (-2.94,2.94) [0.00,6.00] Total: 38968 W: 6113 L: 5837 D: 27018 bench: 9282549
1 parent 3ed86ed commit 091aff0

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/bitboard.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Bitboard AdjacentFilesBB[FILE_NB];
4545
Bitboard InFrontBB[COLOR_NB][RANK_NB];
4646
Bitboard StepAttacksBB[PIECE_NB][SQUARE_NB];
4747
Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
48+
Bitboard LineBB[SQUARE_NB][SQUARE_NB];
4849
Bitboard DistanceRingsBB[SQUARE_NB][8];
4950
Bitboard ForwardBB[COLOR_NB][SQUARE_NB];
5051
Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
@@ -225,6 +226,9 @@ void Bitboards::init() {
225226

226227
for (Square s = s1 + delta; s != s2; s += delta)
227228
BetweenBB[s1][s2] |= s;
229+
230+
PieceType pc = (PseudoAttacks[BISHOP][s1] & s2) ? BISHOP : ROOK;
231+
LineBB[s1][s2] = (PseudoAttacks[pc][s1] & PseudoAttacks[pc][s2]) | s1 | s2;
228232
}
229233
}
230234

src/bitboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ extern Bitboard AdjacentFilesBB[FILE_NB];
7474
extern Bitboard InFrontBB[COLOR_NB][RANK_NB];
7575
extern Bitboard StepAttacksBB[PIECE_NB][SQUARE_NB];
7676
extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
77+
extern Bitboard LineBB[SQUARE_NB][SQUARE_NB];
7778
extern Bitboard DistanceRingsBB[SQUARE_NB][8];
7879
extern Bitboard ForwardBB[COLOR_NB][SQUARE_NB];
7980
extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];

src/evaluate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ Value do_evaluate(const Position& pos) {
492492
: pos.attacks_from<Piece>(s);
493493

494494
if (ei.pinnedPieces[Us] & s)
495-
b &= PseudoAttacks[QUEEN][pos.king_square(Us)];
495+
b &= LineBB[pos.king_square(Us)][s];
496496

497497
ei.attackedBy[Us][Piece] |= b;
498498

0 commit comments

Comments
 (0)