X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=35f9d25e5cc0cdf1cea5d0ea4ac804e0b4306b4c;hp=9882960d9fda66475be430842ab847e801ad30d6;hb=ebb3e7df65b48b8c66c9853983865aefa02e6b59;hpb=d93baae2205c6adc023b474b852af03f139f792a diff --git a/src/movepick.cpp b/src/movepick.cpp index 9882960d..35f9d25e 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -25,9 +25,9 @@ namespace { enum Stages { - MAIN_SEARCH, CAPTURES_INIT, GOOD_CAPTURES, KILLERS, COUNTERMOVE, QUIET_INIT, QUIET, BAD_CAPTURES, + MAIN_SEARCH, CAPTURES_INIT, GOOD_CAPTURES, KILLER0, KILLER1, COUNTERMOVE, QUIET_INIT, QUIET, BAD_CAPTURES, EVASION, EVASIONS_INIT, ALL_EVASIONS, - PROBCUT, PROBCUT_INIT, PROBCUT_CAPTURES, + PROBCUT, PROBCUT_CAPTURES_INIT, PROBCUT_CAPTURES, QSEARCH, QCAPTURES_INIT, QCAPTURES, QCHECKS, QSEARCH_RECAPTURES, QRECAPTURES }; @@ -161,11 +161,16 @@ Move MovePicker::next_move(bool skipQuiets) { return ttMove; case CAPTURES_INIT: + case PROBCUT_CAPTURES_INIT: + case QCAPTURES_INIT: + case QSEARCH_RECAPTURES: endBadCaptures = cur = moves; endMoves = generate(pos, cur); score(); ++stage; - /* fallthrough */ + + // Rebranch at the top of the switch via a recursive call + return next_move(skipQuiets); case GOOD_CAPTURES: while (cur < endMoves) @@ -180,24 +185,20 @@ Move MovePicker::next_move(bool skipQuiets) { *endBadCaptures++ = move; } } - ++stage; - move = killers[0]; // First killer move - if ( move != MOVE_NONE - && move != ttMove - && pos.pseudo_legal(move) - && !pos.capture(move)) - return move; /* fallthrough */ - case KILLERS: - ++stage; - move = killers[1]; // Second killer move - if ( move != MOVE_NONE - && move != ttMove - && pos.pseudo_legal(move) - && !pos.capture(move)) - return move; + case KILLER0: + case KILLER1: + do + { + move = killers[++stage - KILLER1]; + if ( move != MOVE_NONE + && move != ttMove + && pos.pseudo_legal(move) + && !pos.capture(move)) + return move; + } while (stage <= KILLER1); /* fallthrough */ case COUNTERMOVE: @@ -221,17 +222,17 @@ Move MovePicker::next_move(bool skipQuiets) { /* fallthrough */ case QUIET: - while ( cur < endMoves - && (!skipQuiets || cur->value >= VALUE_ZERO)) - { - move = *cur++; - - if ( move != ttMove - && move != killers[0] - && move != killers[1] - && move != countermove) - return move; - } + if (!skipQuiets) + while (cur < endMoves) + { + move = *cur++; + + if ( move != ttMove + && move != killers[0] + && move != killers[1] + && move != countermove) + return move; + } ++stage; cur = moves; // Point to beginning of bad captures /* fallthrough */ @@ -257,13 +258,6 @@ Move MovePicker::next_move(bool skipQuiets) { } break; - case PROBCUT_INIT: - cur = moves; - endMoves = generate(pos, cur); - score(); - ++stage; - /* fallthrough */ - case PROBCUT_CAPTURES: while (cur < endMoves) { @@ -274,13 +268,6 @@ Move MovePicker::next_move(bool skipQuiets) { } break; - case QCAPTURES_INIT: - cur = moves; - endMoves = generate(pos, cur); - score(); - ++stage; - /* fallthrough */ - case QCAPTURES: while (cur < endMoves) { @@ -304,17 +291,10 @@ Move MovePicker::next_move(bool skipQuiets) { } break; - case QSEARCH_RECAPTURES: - cur = moves; - endMoves = generate(pos, cur); - score(); - ++stage; - /* fallthrough */ - case QRECAPTURES: while (cur < endMoves) { - move = pick_best(cur++, endMoves); + move = *cur++; if (to_sq(move) == recaptureSquare) return move; }