]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Revert "null move reorder" series
[stockfish] / src / search.cpp
index 704cf720008d76e300b512ad378c99a14c0900ca..0c5ead46754c20411fe6ab3de99953dceb884524 100644 (file)
@@ -1281,15 +1281,13 @@ namespace {
     bool mateThreat = false;
     bool isCheck = pos.is_check();
 
-    bool useNullMove = (    allowNullmove
-                        &&  depth > OnePly
-                        && !isCheck
-                        && !value_is_mate(beta)
-                        &&  ok_to_do_nullmove(pos)
-                        &&  approximateEval >= beta - NullMoveMargin);
-
     // Null move search
-    if (useNullMove)
+    if (    allowNullmove
+        &&  depth > OnePly
+        && !isCheck
+        && !value_is_mate(beta)
+        &&  ok_to_do_nullmove(pos)
+        &&  approximateEval >= beta - NullMoveMargin)
     {
         ss[ply].currentMove = MOVE_NULL;
 
@@ -1328,13 +1326,12 @@ namespace {
         }
     }
     // Null move search not allowed, try razoring
-    if (    !useNullMove
-         && !value_is_mate(beta)
-         && depth < RazorDepth
-         && approximateEval < beta - RazorApprMargins[int(depth) - 2]
-         && ss[ply - 1].currentMove != MOVE_NULL
-         && ttMove == MOVE_NONE
-         && !pos.has_pawn_on_7th(pos.side_to_move()))
+    else if (   !value_is_mate(beta)
+             && depth < RazorDepth
+             && approximateEval < beta - RazorApprMargins[int(depth) - 2]
+             && ss[ply - 1].currentMove != MOVE_NULL
+             && ttMove == MOVE_NONE
+             && !pos.has_pawn_on_7th(pos.side_to_move()))
     {
         Value v = qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID);
         if (v < beta - RazorMargins[int(depth) - 2])
@@ -1965,15 +1962,15 @@ namespace {
     bool includeAllMoves = (searchMoves[0] == MOVE_NONE);
 
     // Generate all legal moves
-    int lm_count = generate_legal_moves(pos, mlist);
+    MoveStack* last = generate_legal_moves(pos, mlist);
 
     // Add each move to the moves[] array
-    for (int i = 0; i < lm_count; i++)
+    for (MoveStack* cur = mlist; cur != last; cur++)
     {
         bool includeMove = includeAllMoves;
 
         for (int k = 0; !includeMove && searchMoves[k] != MOVE_NONE; k++)
-            includeMove = (searchMoves[k] == mlist[i].move);
+            includeMove = (searchMoves[k] == cur->move);
 
         if (!includeMove)
             continue;
@@ -1982,7 +1979,7 @@ namespace {
         StateInfo st;
         SearchStack ss[PLY_MAX_PLUS_2];
 
-        moves[count].move = mlist[i].move;
+        moves[count].move = cur->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);