X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=51d85192a7c4df8b9c0cfdd0ea0c3adfb7b9ff13;hp=74da3205b3f5265e790b13abe1fabe568ffcbec9;hb=8dd6875240e05dbcc1fb6467ffb11ad360aa474c;hpb=414a3e6ee3ab38215f9eba69939773ba62a9766e diff --git a/src/movepick.cpp b/src/movepick.cpp index 74da3205..51d85192 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -27,7 +27,7 @@ namespace { enum Stages { MAIN_SEARCH, CAPTURES_INIT, GOOD_CAPTURES, KILLERS, 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) @@ -221,17 +226,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 +262,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 +272,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,12 +295,6 @@ Move MovePicker::next_move(bool skipQuiets) { } break; - case QSEARCH_RECAPTURES: - cur = moves; - endMoves = generate(pos, cur); - ++stage; - /* fallthrough */ - case QRECAPTURES: while (cur < endMoves) {