]> git.sesse.net Git - stockfish/blobdiff - src/movepick.cpp
Razor at depth one, but do razoring only when not in check
[stockfish] / src / movepick.cpp
index 4479c321cbba8c8fd7b4ced8e716c434ffd7fbdc..f4f475fb18baa75d7cdb4535723d455daf14be4f 100644 (file)
@@ -74,9 +74,10 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d,
                        const History& h, SearchStack* ss) : pos(p), H(h) {
   int searchTT = ttm;
   ttMoves[0].move = ttm;
-  finished = false;
   lastBadCapture = badCaptures;
 
+  pinned = p.pinned_pieces(pos.side_to_move());
+
   if (ss && !p.is_check())
   {
       ttMoves[1].move = (ss->mateKiller == ttm)? MOVE_NONE : ss->mateKiller;
@@ -86,8 +87,6 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d,
   } else
       ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE;
 
-  pinned = p.pinned_pieces(pos.side_to_move());
-
   if (p.is_check())
       phasePtr = EvasionsPhaseTable;
   else if (d > Depth(0))
@@ -156,7 +155,7 @@ void MovePicker::go_next_phase() {
       return;
 
   case PH_STOP:
-      lastMove = curMove + 1; // hack to be friendly for get_next_move()
+      lastMove = curMove + 1; // Avoids another go_next_phase() call
       return;
 
   default:
@@ -221,7 +220,7 @@ void MovePicker::score_noncaptures() {
           hs += 1000;
 
       // pst based scoring
-      cur->score = hs + pos.pst_delta<Position::MidGame>(piece, from, to);
+      cur->score = hs + mg_value(pos.pst_delta(piece, from, to));
   }
 }
 
@@ -346,14 +345,10 @@ Move MovePicker::get_next_move() {
 Move MovePicker::get_next_move(Lock &lock) {
 
    lock_grab(&lock);
-   if (finished)
-   {
-       lock_release(&lock);
-       return MOVE_NONE;
-   }
+
+   // Note that it is safe to call many times
+   // get_next_move() when phase == PH_STOP
    Move m = get_next_move();
-   if (m == MOVE_NONE)
-       finished = true;
 
    lock_release(&lock);
    return m;