]> git.sesse.net Git - stockfish/commitdiff
Fix assignment of pv[0] when creating root move list
authorMarco Costalba <mcostalba@gmail.com>
Wed, 29 Apr 2009 13:53:37 +0000 (15:53 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 29 Apr 2009 14:01:57 +0000 (16:01 +0200)
It is bogusly assigned from moves[i].move instead of mlist[i].move
or equivalently to moves[count].move that it seem more clear to me.

Bug is hidden while all the moves are included, in this default case
moves[i].move and mlist[i].move are the same variable.

Also a bit of cleanup while there.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index 3ad5423d9d41a7f4600dc97cce32bed306514b2c..67369ad5655d37656b869b23e1f0cbfa12781479 100644 (file)
@@ -1921,7 +1921,7 @@ namespace {
   // Constructor
 
   RootMove::RootMove() {
-    nodes = cumulativeNodes = 0ULL;
+    nodes = cumulativeNodes = ourBeta = theirBeta = 0ULL;
   }
 
   // RootMove::operator<() is the comparison function used when
@@ -1957,22 +1957,20 @@ namespace {
         for (int k = 0; !includeMove && searchMoves[k] != MOVE_NONE; k++)
             includeMove = (searchMoves[k] == mlist[i].move);
 
-        if (includeMove)
-        {
-            // Find a quick score for the move
-            StateInfo st;
-            SearchStack ss[PLY_MAX_PLUS_2];
-
-            moves[count].move = mlist[i].move;
-            moves[count].nodes = 0ULL;
-            pos.do_move(moves[count].move, st);
-            moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE,
-                                          Depth(0), 1, 0);
-            pos.undo_move(moves[count].move);
-            moves[count].pv[0] = moves[i].move;
-            moves[count].pv[1] = MOVE_NONE; // FIXME
-            count++;
-        }
+        if (!includeMove)
+            continue;
+
+        // Find a quick score for the move
+        StateInfo st;
+        SearchStack ss[PLY_MAX_PLUS_2];
+
+        moves[count].move = mlist[i].move;
+        pos.do_move(moves[count].move, st);
+        moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1, 0);
+        pos.undo_move(moves[count].move);
+        moves[count].pv[0] = moves[count].move;
+        moves[count].pv[1] = MOVE_NONE; // FIXME
+        count++;
     }
     sort();
   }