From 33d95482182e459eb033de47a31f142880aa9afb Mon Sep 17 00:00:00 2001 From: protonspring Date: Thu, 6 Dec 2018 14:02:11 +0100 Subject: [PATCH] pseudo_legal() and MOVE_NONE MOVE_NONE is represented as SQ_A1 to SQ_A1 which is never pseudo_legal. STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 38807 W: 8363 L: 8275 D: 22169 http://tests.stockfishchess.org/tests/view/5c05f11d0ebc5902bcee4c86 No functional change --- src/movepick.cpp | 13 +++++-------- src/position.cpp | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 883135d4..3bc56751 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 = ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE; + ttMove = pos.pseudo_legal(ttm) ? ttm : MOVE_NONE; stage += (ttMove == MOVE_NONE); } @@ -79,9 +79,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist assert(d <= DEPTH_ZERO); stage = pos.checkers() ? EVASION_TT : QSEARCH_TT; - ttMove = ttm - && pos.pseudo_legal(ttm) - && (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare) ? ttm : MOVE_NONE; + ttMove = pos.pseudo_legal(ttm) + && (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare) ? ttm : MOVE_NONE; stage += (ttMove == MOVE_NONE); } @@ -93,8 +92,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePiece assert(!pos.checkers()); stage = PROBCUT_TT; - ttMove = ttm - && pos.pseudo_legal(ttm) + ttMove = pos.pseudo_legal(ttm) && pos.capture(ttm) && pos.see_ge(ttm, threshold) ? ttm : MOVE_NONE; stage += (ttMove == MOVE_NONE); @@ -194,8 +192,7 @@ top: /* fallthrough */ case REFUTATION: - if (select([&](){ return move != MOVE_NONE - && !pos.capture(move) + if (select([&](){ return !pos.capture(move) && pos.pseudo_legal(move); })) return move; ++stage; diff --git a/src/position.cpp b/src/position.cpp index c915a1f9..8e7a5aa5 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -579,6 +579,7 @@ 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