]> git.sesse.net Git - stockfish/commitdiff
Fix an assert in SMP case
authorMarco Costalba <mcostalba@gmail.com>
Sun, 17 Nov 2013 09:15:45 +0000 (10:15 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 17 Nov 2013 09:24:25 +0000 (10:24 +0100)
SMP case is very tricky and raises an assert in stage_moves():

assert(stage == KILLERS_S1 || stage == QUIETS_1_S1 || stage == QUIETS_2_S1)

So rewrite the code to just return moves[] when we are sure
we are in quiet moves stages.

Also rename stage_moves to quiet_moves to reflect that.

No functional change (but needs testing in SMP case)

src/movepick.cpp
src/movepick.h
src/search.cpp

index 06ea5e25d2da257d57a1668e0ed3d2c10aa6384d..c4eaa902e292e64cdea5858f4f9ae3318f07ec92 100644 (file)
@@ -140,12 +140,12 @@ MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, Piece
 }
 
 
-/// stage_moves() returns a pointer to the beginning of moves array. It
+/// quiet_moves() returns a pointer to the beginning of moves array. It
 /// is used to access already tried quiet moves when updating history.
 
-const ExtMove* MovePicker::stage_moves() const {
-  assert(stage == KILLERS_S1 || stage == QUIETS_1_S1 || stage == QUIETS_2_S1);
-  return stage == KILLERS_S1 ? killers : moves;
+const ExtMove* MovePicker::quiet_moves() const {
+  return  stage == KILLERS_S1 ? killers
+        : stage == QUIETS_1_S1 || stage == QUIETS_2_S1 ? moves : NULL;
 }
 
 
index 0a48c82de92ad991cfc6447dd9d603ad4bf6ca33..3d4614cde0018a793f417a17470e0c655f88f468 100644 (file)
@@ -88,7 +88,7 @@ public:
   MovePicker(const Position&, Move, const HistoryStats&, PieceType);
   MovePicker(const Position&, Move, Depth, const HistoryStats&, Move*, Search::Stack*);
 
-  const ExtMove* stage_moves() const;
+  const ExtMove* quiet_moves() const;
   template<bool SpNode> Move next_move();
 
 private:
index 5aeb9a87b71059e2097e5890bc5ea9ea19977862..39e4be3d8ae0bb1f8958b8647704a4deb0875858 100644 (file)
@@ -1075,9 +1075,8 @@ moves_loop: // When in check and at SpNode search starts from here
         Value bonus = Value(int(depth) * int(depth));
         History.update(pos.moved_piece(bestMove), to_sq(bestMove), bonus);
 
-        if (bestMove != ttMove)
-            for (const ExtMove* em = mp.stage_moves(); em->move != bestMove; ++em)
-                History.update(pos.moved_piece(em->move), to_sq(em->move), -bonus);
+        for (const ExtMove* em = mp.quiet_moves(); em && em->move != bestMove; ++em)
+            History.update(pos.moved_piece(em->move), to_sq(em->move), -bonus);
 
         if (is_ok((ss-1)->currentMove))
             Countermoves.update(pos.piece_on(prevMoveSq), prevMoveSq, bestMove);