From 091aff044516fcd8700a8a194f9e9ffaabed8bb4 Mon Sep 17 00:00:00 2001 From: Chris Caino Date: Sat, 9 Nov 2013 02:06:47 +0000 Subject: [PATCH] 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 --- src/bitboard.cpp | 4 ++++ src/bitboard.h | 1 + src/evaluate.cpp | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index ae653b1c..7687cbb4 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -45,6 +45,7 @@ Bitboard AdjacentFilesBB[FILE_NB]; Bitboard InFrontBB[COLOR_NB][RANK_NB]; Bitboard StepAttacksBB[PIECE_NB][SQUARE_NB]; Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; +Bitboard LineBB[SQUARE_NB][SQUARE_NB]; Bitboard DistanceRingsBB[SQUARE_NB][8]; Bitboard ForwardBB[COLOR_NB][SQUARE_NB]; Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB]; @@ -225,6 +226,9 @@ void Bitboards::init() { for (Square s = s1 + delta; s != s2; s += delta) BetweenBB[s1][s2] |= s; + + PieceType pc = (PseudoAttacks[BISHOP][s1] & s2) ? BISHOP : ROOK; + LineBB[s1][s2] = (PseudoAttacks[pc][s1] & PseudoAttacks[pc][s2]) | s1 | s2; } } diff --git a/src/bitboard.h b/src/bitboard.h index 3afbeedf..deba91d5 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -74,6 +74,7 @@ extern Bitboard AdjacentFilesBB[FILE_NB]; extern Bitboard InFrontBB[COLOR_NB][RANK_NB]; extern Bitboard StepAttacksBB[PIECE_NB][SQUARE_NB]; extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; +extern Bitboard LineBB[SQUARE_NB][SQUARE_NB]; extern Bitboard DistanceRingsBB[SQUARE_NB][8]; extern Bitboard ForwardBB[COLOR_NB][SQUARE_NB]; extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB]; diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 27980238..dd719554 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -492,7 +492,7 @@ Value do_evaluate(const Position& pos) { : pos.attacks_from(s); if (ei.pinnedPieces[Us] & s) - b &= PseudoAttacks[QUEEN][pos.king_square(Us)]; + b &= LineBB[pos.king_square(Us)][s]; ei.attackedBy[Us][Piece] |= b; -- 2.39.2