X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsearch.cpp;h=218ce1aa2ec577962279cb3377429c5519968f1d;hb=7902d6089eddba7f2e3be922bf069fdb19242516;hp=0fa5290616861f0f32cf8dea39d9f79e6ea9296b;hpb=1036cadcecc43737a1234eec00960a5a81073971;p=stockfish diff --git a/src/search.cpp b/src/search.cpp index 0fa52906..218ce1aa 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -197,7 +197,7 @@ namespace { bool connected_moves(const Position& pos, Move m1, Move m2); Value value_to_tt(Value v, int ply); Value value_from_tt(Value v, int ply); - bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply); + bool can_return_tt(const TTEntry* tte, Depth depth, Value beta, int ply); bool connected_threat(const Position& pos, Move m, Move threat); Value refine_eval(const TTEntry* tte, Value defaultEval, int ply); void update_history(const Position& pos, Move move, Depth depth, Move movesSearched[], int moveCount); @@ -593,8 +593,7 @@ namespace { // Send full PV info to GUI if we are going to leave the loop or // if we have a fail high/low and we are deep in the search. if ((value > alpha && value < beta) || current_search_time() > 2000) - for (int i = 0; i < Min(UCIMultiPV, MultiPVIteration); i++) - { + for (int i = 0; i < Min(UCIMultiPV, MultiPVIteration + 1); i++) cout << "info" << depth_to_uci(depth * ONE_PLY) << (i == MultiPVIteration ? score_to_uci(Rml[i].score, alpha, beta) : @@ -602,7 +601,6 @@ namespace { << speed_to_uci(pos.nodes_searched()) << pv_to_uci(&Rml[i].pv[0], i + 1, pos.is_chess960()) << endl; - } // In case of failing high/low increase aspiration window and research, // otherwise exit the fail high/low loop. @@ -777,14 +775,14 @@ namespace { excludedMove = ss->excludedMove; posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key(); tte = TT.probe(posKey); - ttMove = tte ? tte->move() : MOVE_NONE; + ttMove = RootNode ? Rml[MultiPVIteration].pv[0] : tte ? tte->move() : MOVE_NONE; // At PV nodes we check for exact scores, while at non-PV nodes we check for // a fail high/low. Biggest advantage at probing at PV nodes is to have a // smooth experience in analysis mode. We don't probe at Root nodes otherwise // we should also update RootMoveList to avoid bogus output. if (!RootNode && tte && (PvNode ? tte->depth() >= depth && tte->type() == VALUE_TYPE_EXACT - : ok_to_use_TT(tte, depth, beta, ss->ply))) + : can_return_tt(tte, depth, beta, ss->ply))) { TT.refresh(tte); ss->bestMove = ttMove; // Can be MOVE_NONE @@ -948,7 +946,7 @@ namespace { split_point_start: // At split points actual search starts from here // Initialize a MovePicker object for the current position - MovePickerExt mp(pos, RootNode ? Rml[MultiPVIteration].pv[0] : ttMove, depth, H, ss, PvNode ? -VALUE_INFINITE : beta); + MovePickerExt mp(pos, ttMove, depth, H, ss, PvNode ? -VALUE_INFINITE : beta); CheckInfo ci(pos); ss->bestMove = MOVE_NONE; futilityBase = ss->eval + ss->evalMargin; @@ -978,7 +976,7 @@ split_point_start: // At split points actual search starts from here // At root obey the "searchmoves" option and skip moves not listed in Root Move List. // Also in MultiPV mode we skip moves which already have got an exact score - // in previous MultiPV Iteration. + // in previous MultiPV Iteration. Finally any illegal move is skipped here. if (RootNode && !Rml.find(move, MultiPVIteration)) continue; @@ -1013,11 +1011,12 @@ split_point_start: // At split points actual search starts from here // For long searches send current move info to GUI if (current_search_time() > 2000) cout << "info" << depth_to_uci(depth) - << " currmove " << move << " currmovenumber " << moveCount + MultiPVIteration << endl; + << " currmove " << move + << " currmovenumber " << moveCount + MultiPVIteration << endl; } // At Root and at first iteration do a PV search on all the moves to score root moves - isPvMove = (PvNode && moveCount <= ((RootNode && depth <= ONE_PLY) ? MAX_MOVES : 1)); + isPvMove = (PvNode && moveCount <= (RootNode && depth <= ONE_PLY ? MAX_MOVES : 1)); givesCheck = pos.move_gives_check(move, ci); captureOrPromotion = pos.move_is_capture_or_promotion(move); @@ -1224,7 +1223,7 @@ split_point_start: // At split points actual search starts from here if (!isPvMove && MultiPV == 1) Rml.bestMoveChanges++; - // Update alpha. + // Update alpha if (value > alpha) alpha = value; } @@ -1334,7 +1333,7 @@ split_point_start: // At split points actual search starts from here tte = TT.probe(pos.get_key()); ttMove = (tte ? tte->move() : MOVE_NONE); - if (!PvNode && tte && ok_to_use_TT(tte, ttDepth, beta, ss->ply)) + if (!PvNode && tte && can_return_tt(tte, ttDepth, beta, ss->ply)) { ss->bestMove = ttMove; // Can be MOVE_NONE return value_from_tt(tte->value(), ss->ply); @@ -1669,10 +1668,10 @@ split_point_start: // At split points actual search starts from here } - // ok_to_use_TT() returns true if a transposition table score - // can be used at a given point in search. + // can_return_tt() returns true if a transposition table score + // can be used to cut-off at a given point in search. - bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply) { + bool can_return_tt(const TTEntry* tte, Depth depth, Value beta, int ply) { Value v = value_from_tt(tte->value(), ply);