diff --git a/src/movepick.cpp b/src/movepick.cpp index 1c278147f..b0059bd31 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -208,8 +208,6 @@ Move MovePicker::select(Pred filter) { // picking the move with the highest score from a list of generated moves. Move MovePicker::next_move() { - auto quiet_threshold = [](Depth d) { return -3560 * d; }; - top: switch (stage) { @@ -250,24 +248,22 @@ top: case QUIET_INIT : if (!skipQuiets) { - endMoves = beginBadQuiets = endBadQuiets = generate(pos, cur); + cur = endBadQuiets = endBadCaptures; + endMoves = generate(pos, cur); score(); - partial_insertion_sort(cur, endMoves, quiet_threshold(depth)); + partial_insertion_sort(cur, endMoves, -3560 * depth); } ++stage; [[fallthrough]]; case GOOD_QUIET : - if (!skipQuiets && select([]() { return true; })) - { - if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth)) - return *(cur - 1); - - // Remaining quiets are bad - beginBadQuiets = cur - 1; - } + if (!skipQuiets && select([&]() { + return cur->value > -14000 ? true + : (*endBadQuiets++ = *cur, false); + })) + return *(cur - 1); // Prepare the pointers to loop over the bad captures cur = moves; @@ -281,7 +277,7 @@ top: return *(cur - 1); // Prepare the pointers to loop over the bad quiets - cur = beginBadQuiets; + cur = endBadCaptures; endMoves = endBadQuiets; ++stage; diff --git a/src/movepick.h b/src/movepick.h index 72a6f4e1c..7da7c3a7e 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -68,7 +68,7 @@ class MovePicker { const PieceToHistory** continuationHistory; const PawnHistory* pawnHistory; Move ttMove; - ExtMove * cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets; + ExtMove * cur, *endMoves, *endBadCaptures, *endBadQuiets; int stage; int threshold; Depth depth;