]> git.sesse.net Git - stockfish/blobdiff - src/movepick.cpp
Cache evaluation score in qsearch
[stockfish] / src / movepick.cpp
index c90f8df1e6d398e2cf7f7ab3a4ae63be7c4f3dc1..eb686f7938837d23acb86e0812ea52e1f442d72d 100644 (file)
@@ -66,7 +66,7 @@ namespace {
 /// move ordering is at the current node.
 
 MovePicker::MovePicker(const Position& p, bool pv, Move ttm,
-                       const SearchStack& ss, Depth d, EvalInfo* ei) : pos(p) {
+                       const SearchStack& ss, Depth d) : pos(p) {
   pvNode = pv;
   ttMove = ttm;
   mateKiller = (ss.mateKiller == ttm)? MOVE_NONE : ss.mateKiller;
@@ -81,23 +81,18 @@ MovePicker::MovePicker(const Position& p, bool pv, Move ttm,
   // generating them. So avoid generating in case we know are zero.
   Color us = pos.side_to_move();
   Color them = opposite_color(us);
-  bool noCaptures =    ei
-                   && (ei->attackedBy[us][0] & pos.pieces_of_color(them)) == 0
-                   && !ei->mi->specialized_eval_exists()
-                   && (pos.ep_square() == SQ_NONE)
-                   && !pos.has_pawn_on_7th(us);
 
   if (p.is_check())
       phaseIndex = EvasionsPhaseIndex;
   else if (depth > Depth(0))
       phaseIndex = MainSearchPhaseIndex;
   else if (depth == Depth(0))
-      phaseIndex = (noCaptures ? QsearchNoCapturesPhaseIndex : QsearchWithChecksPhaseIndex);
+      phaseIndex = QsearchWithChecksPhaseIndex;
   else
-      phaseIndex = (noCaptures ? NoMovesPhaseIndex : QsearchWithoutChecksPhaseIndex);
+      phaseIndex = QsearchWithoutChecksPhaseIndex;
 
   dc = p.discovered_check_candidates(us);
-  pinned = p.pinned_pieces(p.side_to_move());
+  pinned = p.pinned_pieces(us);
 
   finished = false;
 }
@@ -130,7 +125,7 @@ Move MovePicker::get_next_move() {
         if (ttMove != MOVE_NONE)
         {
             assert(move_is_ok(ttMove));
-            if (move_is_legal(pos, ttMove))
+            if (move_is_legal(pos, ttMove, pinned))
                 return ttMove;
         }
         break;
@@ -139,10 +134,10 @@ Move MovePicker::get_next_move() {
         if (mateKiller != MOVE_NONE)
         {
             assert(move_is_ok(mateKiller));
-            if (move_is_legal(pos, mateKiller))
+            if (move_is_legal(pos, mateKiller, pinned))
                 return mateKiller;
-       }
-       break;
+        }
+        break;
 
     case PH_GOOD_CAPTURES:
         numOfMoves = generate_captures(pos, moves);
@@ -162,7 +157,7 @@ Move MovePicker::get_next_move() {
 
     case PH_EVASIONS:
         assert(pos.is_check());
-        numOfMoves = generate_evasions(pos, moves);
+        numOfMoves = generate_evasions(pos, moves, pinned);
         score_evasions();
         movesPicked = 0;
         break;
@@ -174,7 +169,7 @@ Move MovePicker::get_next_move() {
         break;
 
     case PH_QCHECKS:
-        numOfMoves = generate_checks(pos, moves);
+        numOfMoves = generate_checks(pos, moves, dc);
         movesPicked = 0;
         break;