X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=d94128eb41c944bd34ec5d92432aad714e5efce5;hp=915e1af25d69ccee4e5faead5f68cf58b14ecd96;hb=09d217bff73d48c39f136c61383609315b0ae173;hpb=ce2845d3334520d07e38750ff481212f092a3ceb diff --git a/src/search.cpp b/src/search.cpp index 915e1af2..d94128eb 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -596,21 +596,21 @@ namespace { SearchStack ss[PLY_MAX_PLUS_2]; Value bestValues[PLY_MAX_PLUS_2]; int bestMoveChanges[PLY_MAX_PLUS_2]; - int depth, researchCountFL, researchCountFH, aspirationDelta; + int depth, aspirationDelta; Value value, alpha, beta; Move bestMove, easyMove; - // Moves to search are verified and copied - Rml.init(pos, searchMoves); - - // Initialize FIXME move before Rml.init() + // Initialize stuff before a new search + memset(ss, 0, 4 * sizeof(SearchStack)); TT.new_search(); H.clear(); - memset(ss, 0, 4 * sizeof(SearchStack)); *ponderMove = bestMove = easyMove = MOVE_NONE; depth = aspirationDelta = 0; - ss->currentMove = MOVE_NULL; // Hack to skip update_gains() alpha = -VALUE_INFINITE, beta = VALUE_INFINITE; + ss->currentMove = MOVE_NULL; // Hack to skip update_gains() + + // Moves to search are verified and copied + Rml.init(pos, searchMoves); // Handle special case of searching on a mate/stalemate position if (Rml.size() == 0) @@ -625,7 +625,7 @@ namespace { // Iterative deepening loop while (++depth <= PLY_MAX && (!MaxDepth || depth <= MaxDepth) && !StopRequest) { - Rml.bestMoveChanges = researchCountFL = researchCountFH = 0; + Rml.bestMoveChanges = 0; cout << "info depth " << depth << endl; // Calculate dynamic aspiration window based on previous iterations @@ -643,8 +643,7 @@ namespace { // Start with a small aspiration window and, in case of fail high/low, // research with bigger window until not failing high/low anymore. - while (true) - { + do { // Search starting from ss+1 to allow calling update_gains() value = search(pos, ss+1, alpha, beta, depth * ONE_PLY, 0); @@ -667,20 +666,21 @@ namespace { // otherwise exit the fail high/low loop. if (value >= beta) { - beta = Min(beta + aspirationDelta * (1 << researchCountFH), VALUE_INFINITE); - researchCountFH++; + beta = Min(beta + aspirationDelta, VALUE_INFINITE); + aspirationDelta += aspirationDelta / 2; } else if (value <= alpha) { AspirationFailLow = true; StopOnPonderhit = false; - alpha = Max(alpha - aspirationDelta * (1 << researchCountFL), -VALUE_INFINITE); - researchCountFL++; + alpha = Max(alpha - aspirationDelta, -VALUE_INFINITE); + aspirationDelta += aspirationDelta / 2; } else break; - } + + } while (abs(value) < VALUE_KNOWN_WIN); // Collect info about search result bestMove = Rml[0].pv[0];