]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Spread usage of pos.piece_moved()
[stockfish] / src / search.cpp
index 8adbfd92ca240b418c09598f67847c2097a745d8..28e231dd98a0811529b165e14b1671e3d6e47fae 100644 (file)
@@ -307,11 +307,7 @@ void Search::think() {
           << endl;
   }
 
-  for (int i = 0; i < Threads.size(); i++)
-  {
-      Threads[i].maxPly = 0;
-      Threads[i].wake_up();
-  }
+  Threads.set_size(Options["Threads"]);
 
   // Set best timer interval to avoid lagging under time pressure. Timer is
   // used to check for remaining available thinking time.
@@ -1347,7 +1343,7 @@ split_point_start: // At split points actual search starts from here
     them = ~pos.side_to_move();
     ksq = pos.king_square(them);
     kingAtt = pos.attacks_from<KING>(ksq);
-    pc = pos.piece_on(from);
+    pc = pos.piece_moved(move);
 
     occ = pos.occupied_squares() & ~(1ULL << from) & ~(1ULL << ksq);
     oldAtt = pos.attacks_from(pc, from, occ);
@@ -1771,14 +1767,14 @@ void RootMove::extract_pv_from_tt(Position& pos) {
   pos.do_move(m, *st++);
 
   while (   (tte = TT.probe(pos.key())) != NULL
-         && tte->move() != MOVE_NONE
-         && pos.is_pseudo_legal(tte->move())
-         && pos.pl_move_is_legal(tte->move(), pos.pinned_pieces())
+         && (m = tte->move()) != MOVE_NONE // Local copy, TT entry could change
+         && pos.is_pseudo_legal(m)
+         && pos.pl_move_is_legal(m, pos.pinned_pieces())
          && ply < MAX_PLY
          && (!pos.is_draw<false>() || ply < 2))
   {
-      pv.push_back(tte->move());
-      pos.do_move(tte->move(), *st++);
+      pv.push_back(m);
+      pos.do_move(m, *st++);
       ply++;
   }
   pv.push_back(MOVE_NONE);
@@ -1869,7 +1865,7 @@ void Thread::idle_loop(SplitPoint* sp_master) {
           lock_grab(Threads.splitLock);
 
           assert(is_searching);
-          SplitPoint* sp = splitPoint;
+          SplitPoint* sp = curSplitPoint;
 
           lock_release(Threads.splitLock);
 
@@ -1910,9 +1906,6 @@ void Thread::idle_loop(SplitPoint* sp_master) {
               Threads[master].wake_up();
       }
   }
-  // In helpful master concept a master can help only a sub-tree of its split
-  // point, and because here is all finished is not possible master is booked.
-  assert(!is_searching);
 }