From 5c2fbcd09b43bd6867780a3ace303ffb1e09d763 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ste=CC=81phane=20Nicolet?= Date: Thu, 6 Dec 2018 15:00:38 +0100 Subject: [PATCH] Revert "pseudo_legal() and MOVE_NONE" 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 | 13 ++++++++----- src/position.cpp | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 3bc56751..883135d4 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -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; - ttMove = pos.pseudo_legal(ttm) ? ttm : MOVE_NONE; + ttMove = ttm && pos.pseudo_legal(ttm) ? ttm : 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; - 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); } @@ -92,7 +93,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePiece 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); @@ -192,7 +194,8 @@ top: /* fallthrough */ case REFUTATION: - if (select([&](){ return !pos.capture(move) + if (select([&](){ return move != MOVE_NONE + && !pos.capture(move) && pos.pseudo_legal(move); })) return move; ++stage; diff --git a/src/position.cpp b/src/position.cpp index 8e7a5aa5..c915a1f9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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. -/// MOVE_NONE is represented as SQ_A1 to SQ_A1 which is never pseudo_legal. bool Position::pseudo_legal(const Move m) const { -- 2.39.2