Initialize SearchStack only once at RootMoveList c'tor
authorJoona Kiiski <joona.kiiski@gmail.com>
Sun, 18 Jul 2010 21:01:58 +0000 (00:01 +0300)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 19 Jul 2010 02:53:37 +0000 (03:53 +0100)
Just fix current ugly behaviour :-)

No functional change

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

index ae64c4830d183e3d47c91e354269f68f1b7922b5..20beb23a11c44e0f75bcd99a08c506d7373e1658 100644 (file)
@@ -2730,6 +2730,11 @@ namespace {
     StateInfo st;
     bool includeAllMoves = (searchMoves[0] == MOVE_NONE);
 
+    // Initialize search stack
+    init_ss_array(ss, PLY_MAX_PLUS_2);
+    ss[0].init();
+    ss[0].eval = VALUE_NONE;
+
     // Generate all legal moves
     MoveStack* last = generate_moves(pos, mlist);
 
@@ -2745,11 +2750,8 @@ namespace {
             continue;
 
         // Find a quick score for the move
-        init_ss_array(ss, PLY_MAX_PLUS_2);
-        ss[0].init();
-        ss[0].eval = VALUE_NONE;
-        ss[0].currentMove = cur->move;
         pos.do_move(cur->move, st);
+        ss[0].currentMove = cur->move;
         moves[count].move = cur->move;
         moves[count].score = -qsearch<PV>(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1);
         moves[count].pv[0] = cur->move;