]> git.sesse.net Git - stockfish/commitdiff
MovePicker:find bad captures during scoring
authorMarco Costalba <mcostalba@gmail.com>
Fri, 14 Nov 2008 21:06:19 +0000 (22:06 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 16 Nov 2008 11:37:46 +0000 (12:37 +0100)
Instead of pospone until picking. No functional
change and probably no performance change but it is
needed for following patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movepick.cpp

index c51fe69f783baaa2385e07212ae374395867aa2f..1519f85d04388c1b24940a31c4babf65ea33f7e0 100644 (file)
@@ -212,6 +212,8 @@ void MovePicker::score_captures() {
   // where it is possible to recapture with the hanging piece). Exchanging
   // big pieces before capturing a hanging piece probably helps to reduce
   // the subtree size.
+  // While scoring captures it moves all captures with negative SEE values
+  // to the badCaptures[] array.
   Move m;
   int seeValue;
 
@@ -226,8 +228,15 @@ void MovePicker::score_captures() {
           else
               moves[i].score = int(pos.midgame_value_of_piece_on(move_to(m)))
                               -int(pos.type_of_piece_on(move_from(m)));
-      } else
+      }
+      else
+      {
+          // Losing capture, move it to the badCaptures[] array
+          assert(numOfBadCaptures < 63);
           moves[i].score = seeValue;
+          badCaptures[numOfBadCaptures++] = moves[i];
+          moves[i--] = moves[--numOfMoves];
+      }
   }
 }
 
@@ -350,9 +359,6 @@ int MovePicker::find_best_index(Bitboard* squares, int values[]) {
 /// from a list of generated moves (moves[] or badCaptures[], depending on
 /// the current move generation phase).  It takes care not to return the
 /// transposition table move if that has already been serched previously.
-/// While picking captures in the PH_GOOD_CAPTURES phase (i.e. while picking
-/// non-losing captures in the main search), it moves all captures with
-/// negative SEE values to the badCaptures[] array.
 
 Move MovePicker::pick_move_from_list() {
 
@@ -366,23 +372,8 @@ Move MovePicker::pick_move_from_list() {
 
       while (movesPicked < numOfMoves)
       {
-          int bestScore = -10000000;
-          bestIndex = -1;
-          for (int i = movesPicked; i < numOfMoves; i++)
-          {
-              if (moves[i].score < 0)
-              {
-                  // Losing capture, move it to the badCaptures[] array
-                  assert(numOfBadCaptures < 63);
-                  badCaptures[numOfBadCaptures++] = moves[i];
-                  moves[i--] = moves[--numOfMoves];
-              }
-              else if (moves[i].score > bestScore)
-              {
-                  bestIndex = i;
-                  bestScore = moves[i].score;
-              }
-          }
+          bestIndex = find_best_index();
+
           if (bestIndex != -1) // Found a good capture
           {
               move = moves[bestIndex].move;