]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Document asymmetric SEE pruning trick
[stockfish] / src / position.cpp
index ad699cc0e93423ef4112093b442da41c0466cb72..1b2defa54662a34718bb46c79e40ae9abffbe595 100644 (file)
@@ -1148,6 +1148,21 @@ int Position::see_sign(Move m) const {
 }
 
 int Position::see(Move m) const {
+  return do_see<false>(m, 0);
+}
+
+/// Position::see_asymm() takes tempi into account.
+/// If the side who initiated the capturing sequence does the last capture,
+/// he loses a tempo. In this case if the result is below asymmThreshold 
+/// the capturing sequence is considered bad.
+
+int Position::see_asymm(Move m, int asymmThreshold) const
+{
+  return do_see<true>(m, asymmThreshold);
+}
+
+template <bool Asymmetric>
+int Position::do_see(Move m, int asymmThreshold) const {
 
   Square from, to;
   Bitboard occupied, attackers, stmAttackers;
@@ -1224,6 +1239,18 @@ int Position::see(Move m) const {
 
   } while (stmAttackers);
 
+  // If we are doing asymmetric SEE evaluation and the same side does the first
+  // and the last capture, he loses a tempo and gain must be at least worth "asymmThreshold".
+  // If not, we replace the score with a very low value, before negamaxing.
+  if (Asymmetric)
+  {
+      for (int i = 0; i < slIndex ; i += 2)
+      {
+          if (swapList[i] < asymmThreshold)
+               swapList[i] = - QueenValueMg * 16;
+      }
+  }
+
   // Having built the swap list, we negamax through it to find the best
   // achievable score from the point of view of the side to move.
   while (--slIndex)