]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Rename CASTLE to CASTLING
[stockfish] / src / search.cpp
index 5aeb9a87b71059e2097e5890bc5ea9ea19977862..a4e2309e2ea404031fe10689eee2ec07cf434b16 100644 (file)
@@ -484,6 +484,7 @@ namespace {
     assert(PvNode || (alpha == beta - 1));
     assert(depth > DEPTH_ZERO);
 
+    Move quietsSearched[64];
     StateInfo st;
     const TTEntry *tte;
     SplitPoint* splitPoint;
@@ -493,7 +494,7 @@ namespace {
     Value bestValue, value, ttValue, eval, nullValue, futilityValue;
     bool inCheck, givesCheck, pvMove, singularExtensionNode, improving;
     bool captureOrPromotion, dangerous, doFullDepthSearch;
-    int moveCount;
+    int moveCount, quietCount;
 
     // Step 1. Initialize node
     Thread* thisThread = pos.this_thread();
@@ -514,7 +515,7 @@ namespace {
         goto moves_loop;
     }
 
-    moveCount = 0;
+    moveCount = quietCount = 0;
     bestValue = -VALUE_INFINITE;
     ss->currentMove = threatMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
     ss->ply = (ss-1)->ply + 1;
@@ -806,7 +807,7 @@ moves_loop: // When in check and at SpNode search starts from here
       givesCheck = pos.gives_check(move, ci);
       dangerous =   givesCheck
                  || pos.passed_pawn_push(move)
-                 || type_of(move) == CASTLE;
+                 || type_of(move) == CASTLING;
 
       // Step 12. Extend checks
       if (givesCheck && pos.see_sign(move) >= 0)
@@ -900,6 +901,8 @@ moves_loop: // When in check and at SpNode search starts from here
 
       pvMove = PvNode && moveCount == 1;
       ss->currentMove = move;
+      if (!SpNode && !captureOrPromotion && quietCount < 64)
+          quietsSearched[quietCount++] = move;
 
       // Step 14. Make the move
       pos.do_move(move, st, ci, givesCheck);
@@ -1074,10 +1077,11 @@ moves_loop: // When in check and at SpNode search starts from here
         // played non-capture moves.
         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 (int i = 0; i < quietCount - 1; ++i)
+        {
+            Move m = quietsSearched[i];
+            History.update(pos.moved_piece(m), to_sq(m), -bonus);
+        }
 
         if (is_ok((ss-1)->currentMove))
             Countermoves.update(pos.piece_on(prevMoveSq), prevMoveSq, bestMove);
@@ -1328,7 +1332,7 @@ moves_loop: // When in check and at SpNode search starts from here
     assert(is_ok(first));
     assert(is_ok(second));
     assert(color_of(pos.piece_on(from_sq(second))) == ~pos.side_to_move());
-    assert(type_of(first) == CASTLE || color_of(pos.piece_on(to_sq(first))) == ~pos.side_to_move());
+    assert(type_of(first) == CASTLING || color_of(pos.piece_on(to_sq(first))) == ~pos.side_to_move());
 
     Square m1from = from_sq(first);
     Square m2from = from_sq(second);
@@ -1347,7 +1351,7 @@ moves_loop: // When in check and at SpNode search starts from here
       return true;
 
     // Second's destination is defended by the first move's piece
-    Bitboard m1att = pos.attacks_from(pos.piece_on(m1to), m1to, pos.pieces() ^ m2from);
+    Bitboard m1att = attacks_bb(pos.piece_on(m1to), m1to, pos.pieces() ^ m2from);
     if (m1att & m2to)
         return true;
 
@@ -1391,7 +1395,7 @@ moves_loop: // When in check and at SpNode search starts from here
         Piece pc = pos.piece_on(m1from);
 
         // The moved piece attacks the square 'tto' ?
-        if (pos.attacks_from(pc, m1to, occ) & m2to)
+        if (attacks_bb(pc, m1to, occ) & m2to)
             return true;
 
         // Scan for possible X-ray attackers behind the moved piece