]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Swap mg and eg in internal representation of Score
[stockfish] / src / position.cpp
index e51c1ba70296a7149460da078c1032b1582a3b88..c193f26691660eebc00214fc9564b108b0eab3f0 100644 (file)
@@ -20,7 +20,8 @@
 
 #include <algorithm>
 #include <cassert>
-#include <cstring>   // For std::memset, std::memcmp
+#include <cstddef> // For offsetof()
+#include <cstring> // For std::memset, std::memcmp
 #include <iomanip>
 #include <sstream>
 
 
 using std::string;
 
+namespace PSQT {
+  extern Score psq[PIECE_NB][SQUARE_NB];
+}
+
 namespace Zobrist {
 
   Key psq[PIECE_NB][SQUARE_NB];
@@ -997,20 +1002,17 @@ Value Position::see(Move m) const {
   // If the opponent has no attackers we are finished
   stm = ~stm;
   stmAttackers = attackers & pieces(stm);
-  if (!stmAttackers)
-      return swapList[0];
+  occupied ^= to; // For the case when captured piece is a pinner
 
   // Don't allow pinned pieces to attack as long all pinners (this includes also
   // potential ones) are on their original square. When a pinner moves to the
   // exchange-square or get captured on it, we fall back to standard SEE behaviour.
-  else if (   (stmAttackers & st->blockersForKing[stm])
-           && ((st->pinnersForKing[stm] & (occupied ^ (occupied & to))) == st->pinnersForKing[stm]))
-  {
-      // Pinned pieces can't attack so remove them from attackers
-      stmAttackers ^= (stmAttackers & st->blockersForKing[stm]);
-      if (!stmAttackers)
-          return swapList[0];
-  }
+  if (   (stmAttackers & pinned_pieces(stm))
+      && (st->pinnersForKing[stm] & occupied) == st->pinnersForKing[stm])
+      stmAttackers &= ~pinned_pieces(stm);
+
+  if (!stmAttackers)
+        return swapList[0];
 
   // The destination square is defended, which makes things rather more
   // difficult to compute. We proceed by building up a "swap list" containing
@@ -1030,10 +1032,9 @@ Value Position::see(Move m) const {
       captured = min_attacker<PAWN>(byTypeBB, to, stmAttackers, occupied, attackers);
       stm = ~stm;
       stmAttackers = attackers & pieces(stm);
-      if (    stmAttackers
-          && (stmAttackers & st->blockersForKing[stm])
-          && ((st->pinnersForKing[stm] & (occupied ^ (occupied & to))) == st->pinnersForKing[stm]))
-          stmAttackers ^= (stmAttackers & st->blockersForKing[stm]);
+      if (   (stmAttackers & pinned_pieces(stm))
+          && (st->pinnersForKing[stm] & occupied) == st->pinnersForKing[stm])
+          stmAttackers &= ~pinned_pieces(stm);
 
       ++slIndex;