X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=97ab5918ae808090ca181aab078e35f15f8399d4;hp=995204f34aab2bf4cca090eb3e66c41f1c857c8a;hb=ade3bb9a4e774aa9b760235f3b0ee42e0a0420d9;hpb=ca14345ba26fc40e1039029659f57028f510502f diff --git a/src/search.cpp b/src/search.cpp index 995204f3..97ab5918 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -413,11 +413,6 @@ void Thread::search() { // search the already searched PV lines are preserved. std::stable_sort(rootMoves.begin() + PVIdx, rootMoves.end()); - // Write PV back to the transposition table in case the relevant - // entries have been overwritten during the search. - for (size_t i = 0; i <= PVIdx; ++i) - rootMoves[i].insert_pv_in_tt(rootPos); - // If search has been stopped, break immediately. Sorting and // writing PV back to TT is safe because RootMoves is still // valid, although it refers to the previous iteration. @@ -554,6 +549,7 @@ namespace { assert(-VALUE_INFINITE <= alpha && alpha < beta && beta <= VALUE_INFINITE); assert(PvNode || (alpha == beta - 1)); assert(DEPTH_ZERO < depth && depth < DEPTH_MAX); + assert(!(PvNode && cutNode)); Move pv[MAX_PLY+1], quietsSearched[64]; StateInfo st; @@ -735,6 +731,7 @@ namespace { if ( !PvNode && depth >= 2 * ONE_PLY && eval >= beta + && (ss->staticEval >= beta || depth >= 12 * ONE_PLY) && pos.non_pawn_material(pos.side_to_move())) { ss->currentMove = MOVE_NULL; @@ -810,7 +807,7 @@ namespace { { Depth d = depth - 2 * ONE_PLY - (PvNode ? DEPTH_ZERO : depth / 4); ss->skipEarlyPruning = true; - search(pos, ss, alpha, beta, d, true); + search(pos, ss, alpha, beta, d, cutNode); ss->skipEarlyPruning = false; tte = TT.probe(posKey, ttHit); @@ -819,7 +816,6 @@ namespace { moves_loop: // When in check search starts from here - Square prevSq = to_sq((ss-1)->currentMove); const CounterMoveStats* cmh = (ss-1)->counterMoves; const CounterMoveStats* fmh = (ss-2)->counterMoves; const CounterMoveStats* fmh2 = (ss-4)->counterMoves; @@ -828,7 +824,7 @@ moves_loop: // When in check search starts from here CheckInfo ci(pos); value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc improving = ss->staticEval >= (ss-2)->staticEval - || ss->staticEval == VALUE_NONE + /* || ss->staticEval == VALUE_NONE Already implicit in the previous condition */ ||(ss-2)->staticEval == VALUE_NONE; singularExtensionNode = !rootNode @@ -878,9 +874,9 @@ moves_loop: // When in check search starts from here && moveCount >= FutilityMoveCounts[improving][depth]; // Step 12. Extend checks - if ( givesCheck - && ( moveCount == 1 - || (!moveCountPruning && pos.see_sign(move) >= VALUE_ZERO))) + if ( givesCheck + && !moveCountPruning + && pos.see_sign(move) >= VALUE_ZERO) extension = ONE_PLY; // Singular extension search. If all moves but one fail low on a search of @@ -968,7 +964,7 @@ moves_loop: // When in check search starts from here + (fmh2 ? (*fmh2)[moved_piece][to_sq(move)] : VALUE_ZERO); // Increase reduction for cut nodes - if (!PvNode && cutNode) + if (cutNode) r += 2 * ONE_PLY; // Decrease reduction for moves that escape a capture. Filter out @@ -1110,10 +1106,10 @@ moves_loop: // When in check search starts from here // Bonus for prior countermove that caused the fail low else if ( depth >= 3 * ONE_PLY && !bestMove - && !inCheck && !pos.captured_piece_type() && is_ok((ss-1)->currentMove)) { + Square prevSq = to_sq((ss-1)->currentMove); Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY) + 2 * depth / ONE_PLY - 2); if ((ss-2)->counterMoves) (ss-2)->counterMoves->update(pos.piece_on(prevSq), prevSq, bonus); @@ -1564,33 +1560,6 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) { } -/// RootMove::insert_pv_in_tt() is called at the end of a search iteration, and -/// inserts the PV back into the TT. This makes sure the old PV moves are searched -/// first, even if the old TT entries have been overwritten. - -void RootMove::insert_pv_in_tt(Position& pos) { - - StateInfo state[MAX_PLY], *st = state; - bool ttHit; - - for (Move m : pv) - { - assert(MoveList(pos).contains(m)); - - TTEntry* tte = TT.probe(pos.key(), ttHit); - - if (!ttHit || tte->move() != m) // Don't overwrite correct entries - tte->save(pos.key(), VALUE_NONE, BOUND_NONE, DEPTH_NONE, - m, VALUE_NONE, TT.generation()); - - pos.do_move(m, *st++, pos.gives_check(m, CheckInfo(pos))); - } - - for (size_t i = pv.size(); i > 0; ) - pos.undo_move(pv[--i]); -} - - /// RootMove::extract_ponder_from_tt() is called in case we have no ponder move /// before exiting the search, for instance, in case we stop the search during a /// fail high at root. We try hard to have a ponder move to return to the GUI,