]> git.sesse.net Git - stockfish/commitdiff
Enable easy move detection only for recaptures
authorMarco Costalba <mcostalba@gmail.com>
Thu, 12 Jan 2012 20:26:25 +0000 (21:26 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 13 Jan 2012 06:27:01 +0000 (07:27 +0100)
It could lead to terrible mistakes otherwise, as
it happened during a game on playchess when on
this position (after white's f4):

2q4r/4b1k1/p3rpp1/3np2p/PpNpNP1P/1P1P2PQ/2P1R3/4R1K1 b - - 0 1

SF moves immediately e5xf4 instead of the correct f5.
In general during engine matches it is impossible the
opponent leaves a piece hanging or anyhow starts a
clear losing sequence. So avoid to fall in subtle traps.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/position.cpp
src/search.cpp

index 65bac1c88515768f204af9141d1e24352d7ed21b..ccc29acf20974d8a09c6a26ccdc209150c76ce1a 100644 (file)
@@ -1265,7 +1265,7 @@ int Position::see(Move m) const {
   {
       Square capQq = to - pawn_push(sideToMove);
 
-      assert(capturedType == NO_PIECE_TYPE);
+      assert(!capturedType);
       assert(type_of(piece_on(capQq)) == PAWN);
 
       // Remove the captured pawn
index 3dde96d8a0c893290124e980ad7c4bfff88129d5..86a8defd53898aa49de8ce1eefd1f9b12b64075d 100644 (file)
@@ -531,15 +531,15 @@ namespace {
                 stop = true;
 
             // Stop search early if one move seems to be much better than others
-            if (   depth >= 10
+            if (    depth >= 12
                 && !stop
-                && (   bestMoveNeverChanged
+                && (   (bestMoveNeverChanged &&  pos.captured_piece_type())
                     || elapsed_time() > (TimeMgr.available_time() * 40) / 100))
             {
                 Value rBeta = bestValue - EasyMoveMargin;
                 (ss+1)->excludedMove = RootMoves[0].pv[0];
                 (ss+1)->skipNullMove = true;
-                Value v = search<NonPV>(pos, ss+1, rBeta - 1, rBeta, (depth * ONE_PLY) / 2);
+                Value v = search<NonPV>(pos, ss+1, rBeta - 1, rBeta, (depth - 3) * ONE_PLY);
                 (ss+1)->skipNullMove = false;
                 (ss+1)->excludedMove = MOVE_NONE;
 
@@ -701,7 +701,7 @@ namespace {
     if (   (move = (ss-1)->currentMove) != MOVE_NULL
         && (ss-1)->eval != VALUE_NONE
         && ss->eval != VALUE_NONE
-        && pos.captured_piece_type() == NO_PIECE_TYPE
+        && !pos.captured_piece_type()
         && !is_special(move))
     {
         Square to = to_sq(move);