X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=8d6ddb8d33708c7443c6c8fb8b8a02d893c21b2a;hp=549f19e211caecc575a10eb6fda327a6986e1d06;hb=0ff3bf34cda9479d6c0d40d11ed0496329462edf;hpb=ca4e78db8db1288eb5c8deecb9bdf402f53fdc98 diff --git a/src/search.cpp b/src/search.cpp index 549f19e2..8d6ddb8d 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -193,7 +193,6 @@ namespace { // Iteration counters int Iteration; - bool LastIterations; BetaCounterType BetaCounter; // Scores and number of times the best move changed for each iteration: @@ -207,7 +206,7 @@ namespace { int SearchStartTime; int MaxNodes, MaxDepth; int MaxSearchTime, AbsoluteMaxSearchTime, ExtraSearchTime; - Move BestRootMove, PonderMove, EasyMove; + Move EasyMove; int RootMoveNumber; bool InfiniteSearch; bool PonderSearch; @@ -369,8 +368,6 @@ void think(const Position &pos, bool infinite, bool ponder, int side_to_move, // Initialize global search variables Idle = false; SearchStartTime = get_system_time(); - BestRootMove = MOVE_NONE; - PonderMove = MOVE_NONE; EasyMove = MOVE_NONE; for (int i = 0; i < THREAD_MAX; i++) { @@ -661,7 +658,6 @@ namespace { ValueByIteration[0] = Value(0); ValueByIteration[1] = rml.get_move_score(0); Iteration = 1; - LastIterations = false; EasyMove = rml.scan_for_easy_move(); @@ -716,9 +712,6 @@ namespace { ExtraSearchTime = BestMoveChangesByIteration[Iteration] * (MaxSearchTime / 2) + BestMoveChangesByIteration[Iteration-1] * (MaxSearchTime / 3); - // Try to guess if the current iteration is the last one or the last two - LastIterations = (current_search_time() > ((MaxSearchTime + ExtraSearchTime)*58) / 128); - // Stop search if most of MaxSearchTime is consumed at the end of the // iteration. We probably don't have enough time to search the first // move at the next iteration anyway. @@ -755,6 +748,11 @@ namespace { << " hashfull " << TT.full() << std::endl; // Print the best move and the ponder move to the standard output + if (ss[0].pv[0] == MOVE_NONE) + { + ss[0].pv[0] = rml.get_move(0); + ss[0].pv[1] = MOVE_NONE; + } std::cout << "bestmove " << ss[0].pv[0]; if (ss[0].pv[1] != MOVE_NONE) std::cout << " ponder " << ss[0].pv[1]; @@ -1396,6 +1394,9 @@ namespace { } TT.store(pos, value_to_tt(bestValue, ply), depth, m, VALUE_TYPE_LOWER); } + + assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE); + return bestValue; } @@ -1424,10 +1425,14 @@ namespace { if (pos.is_draw()) return VALUE_DRAW; - // Transposition table lookup - const TTEntry* tte = TT.retrieve(pos); - if (tte && ok_to_use_TT(tte, depth, beta, ply)) - return value_from_tt(tte->value(), ply); + // Transposition table lookup, only when not in PV + bool pvNode = (beta - alpha != 1); + if (!pvNode) + { + const TTEntry* tte = TT.retrieve(pos); + if (tte && ok_to_use_TT(tte, depth, beta, ply)) + return value_from_tt(tte->value(), ply); + } // Evaluate the position statically EvalInfo ei; @@ -1450,7 +1455,6 @@ namespace { // Initialize a MovePicker object for the current position, and prepare // to search the moves. Because the depth is <= 0 here, only captures, // queen promotions and checks (only if depth == 0) will be generated. - bool pvNode = (beta - alpha != 1); MovePicker mp = MovePicker(pos, pvNode, MOVE_NONE, EmptySearchStack, depth, isCheck ? NULL : &ei); Move move; int moveCount = 0;