]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Rewrite some bitboard init code
[stockfish] / src / search.cpp
index 5ae2cf69f54dad439df37f5130245289b1fd0562..e235c3fc615733c6e68ae879381c6b48ba7bba2e 100644 (file)
@@ -499,7 +499,6 @@ namespace {
     // Step 1. Initialize node
     Thread* thisThread = pos.this_thread();
     inCheck = pos.checkers();
-    excludedMove = ss->excludedMove;
 
     if (SpNode)
     {
@@ -508,7 +507,7 @@ namespace {
         threatMove = splitPoint->threatMove;
         bestValue  = splitPoint->bestValue;
         tte = NULL;
-        ttMove = MOVE_NONE;
+        ttMove = excludedMove = MOVE_NONE;
         ttValue = VALUE_NONE;
 
         assert(splitPoint->bestValue > -VALUE_INFINITE && splitPoint->moveCount > 0);
@@ -548,6 +547,7 @@ namespace {
     // Step 4. Transposition table lookup
     // We don't want the score of a partial search to overwrite a previous full search
     // TT value, so we use a different position key in case of an excluded move.
+    excludedMove = ss->excludedMove;
     posKey = excludedMove ? pos.exclusion_key() : pos.key();
     tte = TT.probe(posKey);
     ttMove = RootNode ? RootMoves[PVIdx].pv[0] : tte ? tte->move() : MOVE_NONE;
@@ -1351,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;
 
@@ -1395,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