X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=d8ab68e76aab3719aee7e29749071b5edf7f1841;hp=3bc56751f94c3710ddc1051362fc1ac87a1f1c56;hb=8df1cd10df0869f05916d1eb19e33b66127fcb86;hpb=33d95482182e459eb033de47a31f142880aa9afb diff --git a/src/movepick.cpp b/src/movepick.cpp index 3bc56751..d8ab68e7 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -31,9 +31,6 @@ namespace { QSEARCH_TT, QCAPTURE_INIT, QCAPTURE, QCHECK_INIT, QCHECK }; - // Helper filter used with select() - const auto Any = [](){ return true; }; - // partial_insertion_sort() sorts moves in descending order up to and including // a given limit. The order of moves smaller than the limit is left unspecified. void partial_insertion_sort(ExtMove* begin, ExtMove* end, int limit) { @@ -67,7 +64,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 +76,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 +90,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 +191,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; @@ -222,7 +222,7 @@ top: /* fallthrough */ case BAD_CAPTURE: - return select(Any); + return select([](){ return true; }); case EVASION_INIT: cur = moves; @@ -233,7 +233,7 @@ top: /* fallthrough */ case EVASION: - return select(Any); + return select([](){ return true; }); case PROBCUT: return select([&](){ return pos.see_ge(move, threshold); }); @@ -258,7 +258,7 @@ top: /* fallthrough */ case QCHECK: - return select(Any); + return select([](){ return true; }); } assert(false);