X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=fc94f4f79347dfc14dc6fe5e186c90ca3a1d0fac;hp=a1e1cea5c9c6a948977728575ee1ddb638e8a01c;hb=b88bc7b7667fc6ddbfc7412fb2c0bfc13e3bf11c;hpb=4fc773454759081c2cd921e460d542f2dfd4aa24 diff --git a/src/search.cpp b/src/search.cpp index a1e1cea5..fc94f4f7 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -296,9 +296,12 @@ namespace { Value bestValue, alpha, beta, delta; memset(ss-1, 0, 4 * sizeof(Stack)); - depth = BestMoveChanges = 0; - bestValue = delta = -VALUE_INFINITE; (ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains + + depth = BestMoveChanges = 0; + bestValue = delta = alpha = -VALUE_INFINITE; + beta = VALUE_INFINITE; + TT.new_search(); History.clear(); Gains.clear(); @@ -328,17 +331,12 @@ namespace { // MultiPV loop. We perform a full root search for each PV line for (PVIdx = 0; PVIdx < PVSize; PVIdx++) { - // Set aspiration window default width - if (depth >= 5 && abs(RootMoves[PVIdx].prevScore) < VALUE_KNOWN_WIN) + // Reset aspiration window starting size + if (depth >= 5) { delta = Value(16); - alpha = RootMoves[PVIdx].prevScore - delta; - beta = RootMoves[PVIdx].prevScore + delta; - } - else - { - alpha = -VALUE_INFINITE; - beta = VALUE_INFINITE; + alpha = std::max(RootMoves[PVIdx].prevScore - delta,-VALUE_INFINITE); + beta = std::min(RootMoves[PVIdx].prevScore + delta, VALUE_INFINITE); } // Start with a small aspiration window and, in case of fail high/low, @@ -366,35 +364,28 @@ namespace { if (Signals.stop) return; - // In case of failing high/low increase aspiration window and - // research, otherwise exit the loop. - if (bestValue > alpha && bestValue < beta) - break; + delta += delta / 2; - // Give some update (without cluttering the UI) before to research - if (Time::now() - SearchTime > 3000) - sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; - - if (abs(bestValue) >= VALUE_KNOWN_WIN) - { - alpha = -VALUE_INFINITE; - beta = VALUE_INFINITE; - } - else if (bestValue >= beta) - { - beta += delta; - delta += delta / 2; - } - else + // In case of failing low/high increase aspiration window and + // research, otherwise exit the loop. + if (bestValue <= alpha) { + alpha = std::max(bestValue - delta, -VALUE_INFINITE); + Signals.failedLowAtRoot = true; Signals.stopOnPonderhit = false; - - alpha -= delta; - delta += delta / 2; } + else if (bestValue >= beta) + beta = std::min(bestValue + delta, VALUE_INFINITE); + + else + break; assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE); + + // Give some update (without cluttering the UI) before to research + if (Time::now() - SearchTime > 3000) + sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; } // Sort the PV lines searched so far and update the GUI @@ -1156,8 +1147,7 @@ split_point_start: // At split points actual search starts from here ttDepth = InCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS; - // Transposition table lookup. At PV nodes, we don't use the TT for - // pruning, but only for move ordering. + // Transposition table lookup posKey = pos.key(); tte = TT.probe(posKey); ttMove = tte ? tte->move() : MOVE_NONE;