From: Marco Costalba Date: Sun, 1 Feb 2015 12:08:14 +0000 (+0100) Subject: Delay checking for duplicated killer moves X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=20d6a8e57f55e586f5ab8b3bcb60bfe17c5f2708 Delay checking for duplicated killer moves Follow the usual approach to delay computation as far as possible, in case an earlier killer cut-offs we avoid to do useless work. This also greatly simplifies the code. No functional change. --- diff --git a/src/movepick.cpp b/src/movepick.cpp index 1f4ef195..69d848d2 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -201,28 +201,13 @@ void MovePicker::generate_next_stage() { case KILLERS_S1: cur = killers; - endMoves = cur + 2; - + endMoves = cur + 6; killers[0].move = ss->killers[0]; killers[1].move = ss->killers[1]; - killers[2].move = killers[3].move = MOVE_NONE; - killers[4].move = killers[5].move = MOVE_NONE; - - // In SMP case countermoves[] and followupmoves[] could have duplicated entries - // in rare cases (less than 1 out of a million). This is harmless. - - // Be sure countermoves and followupmoves are different from killers - for (int i = 0; i < 2; ++i) - if ( countermoves[i] != killers[0].move - && countermoves[i] != killers[1].move) - (endMoves++)->move = countermoves[i]; - - for (int i = 0; i < 2; ++i) - if ( followupmoves[i] != killers[0].move - && followupmoves[i] != killers[1].move - && followupmoves[i] != killers[2].move - && followupmoves[i] != killers[3].move) - (endMoves++)->move = followupmoves[i]; + killers[2].move = countermoves[0]; + killers[3].move = countermoves[1]; + killers[4].move = followupmoves[0]; + killers[5].move = followupmoves[1]; break; case QUIETS_1_S1: @@ -307,18 +292,25 @@ Move MovePicker::next_move() { && move != ttMove && pos.pseudo_legal(move) && !pos.capture(move)) + { + // Check for duplicated entries + for (int i = 0; i < cur - 1 - killers; i++) + if (move == killers[i]) + goto skip; return move; + } + skip: break; case QUIETS_1_S1: case QUIETS_2_S1: move = *cur++; if ( move != ttMove - && move != killers[0].move - && move != killers[1].move - && move != killers[2].move - && move != killers[3].move - && move != killers[4].move - && move != killers[5].move) + && move != killers[0] + && move != killers[1] + && move != killers[2] + && move != killers[3] + && move != killers[4] + && move != killers[5]) return move; break;