From dec11a7580ee5e92880288dc85c4aa2825108a72 Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Fri, 26 Feb 2021 17:31:15 +0100 Subject: [PATCH] Speed up slider blockers standard STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 1370 W: 361 L: 280 D: 729 http://www.variantfishtest.org:6543/tests/view/603423e96e23db669974e95c seirawan STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 2789 W: 1023 L: 908 D: 858 http://www.variantfishtest.org:6543/tests/view/603423f56e23db669974e95e --- src/position.cpp | 32 ++++++++++++++++++-------------- 1 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 42d955a..f01aec4 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -743,26 +743,30 @@ Bitboard Position::slider_blockers(Bitboard sliders, Square s, Bitboard& pinners // Snipers are sliders that attack 's' when a piece and other snipers are removed Bitboard snipers = 0; - for (PieceType pt : piece_types()) - { - Bitboard b = sliders & (PseudoAttacks[~c][pt][s] ^ LeaperAttacks[~c][pt][s]) & pieces(c, pt); - if (b) + if (var->fastAttacks) + snipers = ( (attacks_bb< ROOK>(s) & pieces(c, QUEEN, ROOK, CHANCELLOR)) + | (attacks_bb(s) & pieces(c, QUEEN, BISHOP, ARCHBISHOP))) & sliders; + else + for (PieceType pt : piece_types()) { - // Consider asymmetrical moves (e.g., horse) - if (AttackRiderTypes[pt] & ASYMMETRICAL_RIDERS) + Bitboard b = sliders & (PseudoAttacks[~c][pt][s] ^ LeaperAttacks[~c][pt][s]) & pieces(c, pt); + if (b) { - Bitboard asymmetricals = PseudoAttacks[~c][pt][s] & pieces(c, pt); - while (asymmetricals) + // Consider asymmetrical moves (e.g., horse) + if (AttackRiderTypes[pt] & ASYMMETRICAL_RIDERS) { - Square s2 = pop_lsb(&asymmetricals); - if (!(attacks_from(c, pt, s2) & s)) - snipers |= s2; + Bitboard asymmetricals = PseudoAttacks[~c][pt][s] & pieces(c, pt); + while (asymmetricals) + { + Square s2 = pop_lsb(&asymmetricals); + if (!(attacks_from(c, pt, s2) & s)) + snipers |= s2; + } } + else + snipers |= b & ~attacks_bb(~c, pt, s, pieces()); } - else - snipers |= b & ~attacks_bb(~c, pt, s, pieces()); } - } Bitboard occupancy = pieces() ^ snipers; while (snipers) -- 1.7.0.4