]> git.sesse.net Git - stockfish/commitdiff
Implement PEXT based attacks
authorMarco Costalba <mcostalba@gmail.com>
Mon, 7 Apr 2014 14:27:14 +0000 (16:27 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 12 Apr 2014 06:55:30 +0000 (08:55 +0200)
According to:

https://chessprogramming.wikispaces.com/BMI2#PEXTBitboards

No functional change.

src/bitboard.cpp
src/bitboard.h
src/types.h

index 27ba65747d6faf05cf4cdb3e2442aa0f0b7cdbe6..b7fce20d9206a4fdab6716ef7158b08e27a5b12f 100644 (file)
@@ -296,7 +296,12 @@ namespace {
         b = size = 0;
         do {
             occupancy[size] = b;
-            reference[size++] = sliding_attack(deltas, s, b);
+            reference[size] = sliding_attack(deltas, s, b);
+
+            if (HasPext)
+                attacks[s][pext(occupancy[size], masks[s])] = reference[size];
+
+            size++;
             b = (b - masks[s]) & masks[s];
         } while (b);
 
@@ -305,6 +310,9 @@ namespace {
         if (s < SQ_H8)
             attacks[s + 1] = attacks[s] + size;
 
+        if (HasPext)
+            continue;
+
         booster = MagicBoosters[Is64Bit][rank_of(s)];
 
         // Find a magic for square 's' picking up an (almost) random number
index 140867fa94a466272d55be020451b0eb8b012f77..cd6c280c8c444d9e349c1895b4c792ef8325d77d 100644 (file)
@@ -243,6 +243,9 @@ FORCE_INLINE unsigned magic_index(Square s, Bitboard occ) {
   Bitboard* const Magics = Pt == ROOK ? RMagics : BMagics;
   unsigned* const Shifts = Pt == ROOK ? RShifts : BShifts;
 
+  if (HasPext)
+      return unsigned(pext(occ, Masks[s]));
+
   if (Is64Bit)
       return unsigned(((occ & Masks[s]) * Magics[s]) >> Shifts[s]);
 
index 7ebe3f61f8580b0b241a9c0580b8f83768a57fc0..5dcfe51e82185884cfa610dc15df15b5df55b20e 100644 (file)
@@ -79,6 +79,12 @@ const bool HasPopCnt = true;
 const bool HasPopCnt = false;
 #endif
 
+#ifdef USE_PEXT
+const bool HasPext = true;
+#else
+const bool HasPext = false;
+#endif
+
 #ifdef IS_64BIT
 const bool Is64Bit = true;
 #else