]> git.sesse.net Git - stockfish/commitdiff
Combine killer moves
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 25 Feb 2018 21:33:40 +0000 (22:33 +0100)
committerStéphane Nicolet <cassio@free.fr>
Sun, 25 Feb 2018 22:11:56 +0000 (23:11 +0100)
Move the first killer move out of the capture stage, combining treatment
of first and second killer move.

passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 55777 W: 12367 L: 12313 D: 31097
http://tests.stockfishchess.org/tests/view/5a88617e0ebc590297cc8351

Similar to an earlier proposition of Günther Demetz, see pull request #1075.
I think it is more robust and readable than master, why hand-unroll the loop
over the killer array, and duplicate code ?

This version includes review comments from Marco Costalba.

Bench: 5227124

src/movepick.cpp

index 51d85192a7c4df8b9c0cfdd0ea0c3adfb7b9ff13..35f9d25e5cc0cdf1cea5d0ea4ac804e0b4306b4c 100644 (file)
@@ -25,7 +25,7 @@
 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_CAPTURES_INIT, PROBCUT_CAPTURES,
     QSEARCH, QCAPTURES_INIT, QCAPTURES, QCHECKS, QSEARCH_RECAPTURES, QRECAPTURES
@@ -185,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: