]> git.sesse.net Git - stockfish/blobdiff - src/movepick.cpp
Fix score_captures() for the case of capture promotions
[stockfish] / src / movepick.cpp
index 8f3f65b165d2c8d65031aecf6046001623a54f92..04fa40d625ba8212a4dceb2ed0278a966a5b7fe5 100644 (file)
@@ -56,7 +56,7 @@ namespace {
 /// move ordering is at the current node.
 
 MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
-                       SearchStack* ss, Value beta) : pos(p), H(h) {
+                       SearchStack* ss, Value beta) : pos(p), H(h), depth(d) {
   captureThreshold = 0;
   badCaptures = moves + MAX_MOVES;
 
@@ -162,7 +162,8 @@ void MovePicker::go_next_phase() {
   case PH_NONCAPTURES_2:
       curMove = lastMove;
       lastMove = lastNonCapture;
-      insertion_sort<MoveStack>(curMove, lastMove);
+      if (depth >= 3 * ONE_PLY)
+          insertion_sort<MoveStack>(curMove, lastMove);
       return;
 
   case PH_BAD_CAPTURES:
@@ -223,11 +224,11 @@ void MovePicker::score_captures() {
   for (MoveStack* cur = moves; cur != lastMove; cur++)
   {
       m = cur->move;
+      cur->score =  pos.midgame_value_of_piece_on(move_to(m))
+                  - pos.type_of_piece_on(move_from(m));
+
       if (move_is_promotion(m))
-          cur->score = QueenValueMidgame;
-      else
-          cur->score =  pos.midgame_value_of_piece_on(move_to(m))
-                      - pos.type_of_piece_on(move_from(m));
+          cur->score += QueenValueMidgame;
   }
 }