]> git.sesse.net Git - stockfish/commitdiff
Revert "pseudo_legal() and MOVE_NONE"
authorStéphane Nicolet <cassio@free.fr>
Thu, 6 Dec 2018 14:00:38 +0000 (15:00 +0100)
committerStéphane Nicolet <cassio@free.fr>
Thu, 6 Dec 2018 14:04:04 +0000 (15:04 +0100)
This reverts commit 33d95482182e459eb033de47a31f142880aa9afb ,
which crashed in DEBUG mode because of the following assert in position.h

````
Assertion failed: (is_ok(m)), function capture, file ./position.h, line 369.
````

No functional change

src/movepick.cpp
src/position.cpp

index 3bc56751f94c3710ddc1051362fc1ac87a1f1c56..883135d491798a292be297af44d66fbd0948d522 100644 (file)
@@ -67,7 +67,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
   assert(d > DEPTH_ZERO);
 
   stage = pos.checkers() ? EVASION_TT : MAIN_TT;
   assert(d > DEPTH_ZERO);
 
   stage = pos.checkers() ? EVASION_TT : MAIN_TT;
-  ttMove = pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
+  ttMove = ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
   stage += (ttMove == MOVE_NONE);
 }
 
   stage += (ttMove == MOVE_NONE);
 }
 
@@ -79,8 +79,9 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
   assert(d <= DEPTH_ZERO);
 
   stage = pos.checkers() ? EVASION_TT : QSEARCH_TT;
   assert(d <= DEPTH_ZERO);
 
   stage = pos.checkers() ? EVASION_TT : QSEARCH_TT;
-  ttMove =   pos.pseudo_legal(ttm)
-          && (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare) ? ttm : MOVE_NONE;
+  ttMove =    ttm
+           && pos.pseudo_legal(ttm)
+           && (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare) ? ttm : MOVE_NONE;
   stage += (ttMove == MOVE_NONE);
 }
 
   stage += (ttMove == MOVE_NONE);
 }
 
@@ -92,7 +93,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePiece
   assert(!pos.checkers());
 
   stage = PROBCUT_TT;
   assert(!pos.checkers());
 
   stage = PROBCUT_TT;
-  ttMove =   pos.pseudo_legal(ttm)
+  ttMove =   ttm
+          && pos.pseudo_legal(ttm)
           && pos.capture(ttm)
           && pos.see_ge(ttm, threshold) ? ttm : MOVE_NONE;
   stage += (ttMove == MOVE_NONE);
           && pos.capture(ttm)
           && pos.see_ge(ttm, threshold) ? ttm : MOVE_NONE;
   stage += (ttMove == MOVE_NONE);
@@ -192,7 +194,8 @@ top:
       /* fallthrough */
 
   case REFUTATION:
       /* fallthrough */
 
   case REFUTATION:
-      if (select<Next>([&](){ return   !pos.capture(move)
+      if (select<Next>([&](){ return    move != MOVE_NONE
+                                    && !pos.capture(move)
                                     &&  pos.pseudo_legal(move); }))
           return move;
       ++stage;
                                     &&  pos.pseudo_legal(move); }))
           return move;
       ++stage;
index 8e7a5aa5d24de004688134b12dbbe75d9c902697..c915a1f9f3cf7e466eb2ed9d754cc75cdd22cbd1 100644 (file)
@@ -579,7 +579,6 @@ bool Position::legal(Move m) const {
 /// Position::pseudo_legal() takes a random move and tests whether the move is
 /// pseudo legal. It is used to validate moves from TT that can be corrupted
 /// due to SMP concurrent access or hash position key aliasing.
 /// Position::pseudo_legal() takes a random move and tests whether the move is
 /// pseudo legal. It is used to validate moves from TT that can be corrupted
 /// due to SMP concurrent access or hash position key aliasing.
-/// MOVE_NONE is represented as SQ_A1 to SQ_A1 which is never pseudo_legal.
 
 bool Position::pseudo_legal(const Move m) const {
 
 
 bool Position::pseudo_legal(const Move m) const {