Speed up slider blockers
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 26 Feb 2021 16:31:15 +0000 (17:31 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 26 Feb 2021 16:31:15 +0000 (17:31 +0100)
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

index 42d955a..f01aec4 100644 (file)
@@ -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<BISHOP>(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)