X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=a4e2309e2ea404031fe10689eee2ec07cf434b16;hp=02aea53827f39eff2977258b10ef175bfe49b164;hb=f99cb3dc27719021e126690b7fd5aa5f43663ed8;hpb=1d18647e738951a7e94530fef231f4b4e13b1786 diff --git a/src/search.cpp b/src/search.cpp index 02aea538..a4e2309e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -82,6 +82,7 @@ namespace { double BestMoveChanges; Value DrawValue[COLOR_NB]; HistoryStats History; + GainsStats Gains; CountermovesStats Countermoves; template @@ -293,6 +294,7 @@ namespace { Value bestValue, alpha, beta, delta; std::memset(ss-2, 0, 5 * sizeof(Stack)); + (ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains depth = 0; BestMoveChanges = 0; @@ -301,6 +303,7 @@ namespace { TT.new_search(); History.clear(); + Gains.clear(); Countermoves.clear(); PVSize = Options["MultiPV"]; @@ -487,9 +490,8 @@ namespace { SplitPoint* splitPoint; Key posKey; Move ttMove, move, excludedMove, bestMove, threatMove; - Depth ext, newDepth; - Value bestValue, value, ttValue; - Value eval, nullValue; + Depth ext, newDepth, predictedDepth; + Value bestValue, value, ttValue, eval, nullValue, futilityValue; bool inCheck, givesCheck, pvMove, singularExtensionNode, improving; bool captureOrPromotion, dangerous, doFullDepthSearch; int moveCount, quietCount; @@ -601,6 +603,16 @@ namespace { TT.store(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, ss->staticEval); } + if ( !pos.captured_piece_type() + && ss->staticEval != VALUE_NONE + && (ss-1)->staticEval != VALUE_NONE + && (move = (ss-1)->currentMove) != MOVE_NULL + && type_of(move) == NORMAL) + { + Square to = to_sq(move); + Gains.update(pos.piece_on(to), to, -(ss-1)->staticEval - ss->staticEval); + } + // Step 6. Razoring (skipped when in check) if ( !PvNode && depth < 4 * ONE_PLY @@ -795,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) @@ -847,12 +859,13 @@ moves_loop: // When in check and at SpNode search starts from here continue; } - Depth predictedDepth = newDepth - reduction(improving, depth, moveCount); + predictedDepth = newDepth - reduction(improving, depth, moveCount); // Futility pruning: parent node if (predictedDepth < 7 * ONE_PLY) { - Value futilityValue = ss->staticEval + futility_margin(predictedDepth) + Value(128); + futilityValue = ss->staticEval + futility_margin(predictedDepth) + + Value(128) + Gains[pos.moved_piece(move)][to_sq(move)]; if (futilityValue <= alpha) { @@ -869,8 +882,7 @@ moves_loop: // When in check and at SpNode search starts from here } // Prune moves with negative SEE at low depths - if ( predictedDepth < 4 * ONE_PLY - && pos.see_sign(move) < 0) + if (predictedDepth < 4 * ONE_PLY && pos.see_sign(move) < 0) { if (SpNode) splitPoint->mutex.lock(); @@ -883,7 +895,7 @@ moves_loop: // When in check and at SpNode search starts from here // Check for legality only before to do the move if (!RootNode && !SpNode && !pos.legal(move, ci.pinned)) { - --moveCount; + moveCount--; continue; } @@ -1320,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); @@ -1339,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; @@ -1383,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