X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=b0d359d1955ee4f707c427207c8b2852499135f9;hp=d47fab1fea3564f3c944717b9c26295f2d9653bb;hb=5815718177817de90f98513b776bc04376440f0a;hpb=876ceb1feb466f4dd2e29d01433878b8cf29cd6f diff --git a/src/search.cpp b/src/search.cpp index d47fab1f..b0d359d1 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -129,7 +129,7 @@ namespace { void extract_pv_from_tt(Position& pos); void insert_pv_in_tt(Position& pos); - std::string pv_info_to_uci(Position& pos, int depth, Value alpha, Value beta, int pvLine = 0); + std::string pv_info_to_uci(Position& pos, int depth, Value alpha, Value beta, int pvLine); int64_t nodes; Value pv_score; @@ -209,7 +209,7 @@ namespace { // Minimum depth for use of singular extension const Depth SingularExtensionDepth[2] = { 8 * ONE_PLY /* non-PV */, 6 * ONE_PLY /* PV */}; - // If the TT move is at least SingularExtensionMargin better then the + // If the TT move is at least SingularExtensionMargin better than the // remaining ones we will extend it. const Value SingularExtensionMargin = Value(0x20); @@ -249,7 +249,7 @@ namespace { // MultiPV mode int MultiPV; - // Time managment variables + // Time management variables int SearchStartTime, MaxNodes, MaxDepth, ExactMaxTime; bool UseTimeManagement, InfiniteSearch, Pondering, StopOnPonderhit; bool FirstRootMove, StopRequest, QuitRequest, AspirationFailLow; @@ -331,7 +331,7 @@ namespace { Value score = VALUE_ZERO; // Score root moves using the standard way used in main search, the moves - // are scored according to the order in which are returned by MovePicker. + // are scored according to the order in which they are returned by MovePicker. // This is the second order score that is used to compare the moves when // the first order pv scores of both moves are equal. while ((move = MovePicker::get_next_move()) != MOVE_NONE) @@ -544,12 +544,13 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[ std::string name = Options["Search Log Filename"].value(); LogFile.open(name.c_str(), std::ios::out | std::ios::app); - LogFile << "Searching: " << pos.to_fen() - << "\ninfinite: " << infinite - << " ponder: " << ponder - << " time: " << myTime - << " increment: " << myIncrement - << " moves to go: " << movesToGo << endl; + LogFile << "\nSearching: " << pos.to_fen() + << "\ninfinite: " << infinite + << " ponder: " << ponder + << " time: " << myTime + << " increment: " << myIncrement + << " moves to go: " << movesToGo + << endl; } // We're ready to start thinking. Call the iterative deepening loop function @@ -563,19 +564,14 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[ if (UseLogFile) { - LogFile << "\nNodes: " << pos.nodes_searched() + LogFile << "Nodes: " << pos.nodes_searched() << "\nNodes/second: " << nps(pos) - << "\nBest move: " << move_to_san(pos, bestMove); + << "\nBest move: " << move_to_san(pos, bestMove); StateInfo st; pos.do_move(bestMove, st); - LogFile << "\nPonder move: " - << move_to_san(pos, ponderMove) // Works also with MOVE_NONE - << endl; - - // Return from think() with unchanged position - pos.undo_move(bestMove); - + LogFile << "\nPonder move: " << move_to_san(pos, ponderMove) << endl; + pos.undo_move(bestMove); // Return from think() with unchanged position LogFile.close(); } @@ -621,7 +617,7 @@ namespace { ss->currentMove = MOVE_NULL; // Hack to skip update_gains() alpha = -VALUE_INFINITE, beta = VALUE_INFINITE; - // Handle special case of searching on a mate/stale position + // Handle special case of searching on a mate/stalemate position if (Rml.size() == 0) { cout << "info depth 0 score " @@ -701,6 +697,9 @@ namespace { bestValues[depth] = value; bestMoveChanges[depth] = Rml.bestMoveChanges; + if (UseLogFile) + LogFile << pretty_pv(pos, depth, value, current_search_time(), Rml[0].pv) << endl; + // Drop the easy move if differs from the new best move if (bestMove != easyMove) easyMove = MOVE_NONE; @@ -826,7 +825,7 @@ namespace { // Step 4. Transposition table lookup // We don't want the score of a partial search to overwrite a previous full search - // TT value, so we use a different position key in case of an excluded move exists. + // TT value, so we use a different position key in case of an excluded move. excludedMove = ss->excludedMove; posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key(); @@ -1048,7 +1047,7 @@ split_point_start: // At split points actual search starts from here // Singular extension search. If all moves but one fail low on a search of (alpha-s, beta-s), // and just one fails high on (alpha, beta), then that move is singular and should be extended. // To verify this we do a reduced search on all the other moves but the ttMove, if result is - // lower then ttValue minus a margin then we extend ttMove. + // lower than ttValue minus a margin then we extend ttMove. if ( singularExtensionNode && move == tte->move() && ext < ONE_PLY) @@ -1154,8 +1153,7 @@ split_point_start: // At split points actual search starts from here && ss->killers[0] != move && ss->killers[1] != move) { - ss->reduction = Root ? reduction(depth, moveCount - MultiPV + 1) - : reduction(depth, moveCount); + ss->reduction = reduction(depth, moveCount); if (ss->reduction) { alpha = SpNode ? sp->alpha : alpha; @@ -1253,7 +1251,7 @@ split_point_start: // At split points actual search starts from here mp.rm->extract_pv_from_tt(pos); // We record how often the best move has been changed in each - // iteration. This information is used for time managment: When + // iteration. This information is used for time management: When // the best move changes frequently, we allocate some more time. if (!isPvMove && MultiPV == 1) Rml.bestMoveChanges++; @@ -1745,7 +1743,7 @@ split_point_start: // At split points actual search starts from here // connected_threat() tests whether it is safe to forward prune a move or if - // is somehow coonected to the threat move returned by null search. + // is somehow connected to the threat move returned by null search. bool connected_threat(const Position& pos, Move m, Move threat) { @@ -1767,7 +1765,7 @@ split_point_start: // At split points actual search starts from here return true; // Case 2: If the threatened piece has value less than or equal to the - // value of the threatening piece, don't prune move which defend it. + // value of the threatening piece, don't prune moves which defend it. if ( pos.move_is_capture(threat) && ( pos.midgame_value_of_piece_on(tfrom) >= pos.midgame_value_of_piece_on(tto) || pos.type_of_piece_on(tfrom) == KING) @@ -1880,7 +1878,7 @@ split_point_start: // At split points actual search starts from here if (abs(v) < VALUE_MATE - PLY_MAX * ONE_PLY) s << "cp " << int(v) * 100 / int(PawnValueMidgame); // Scale to centipawns else - s << "mate " << (v > 0 ? (VALUE_MATE - v + 1) / 2 : -(VALUE_MATE + v) / 2 ); + s << "mate " << (v > 0 ? (VALUE_MATE - v + 1) / 2 : -(VALUE_MATE + v) / 2); return s.str(); } @@ -2514,7 +2512,7 @@ split_point_start: // At split points actual search starts from here k = pos.get_key(); tte = TT.retrieve(k); - // Don't overwrite exsisting correct entries + // Don't overwrite existing correct entries if (!tte || tte->move() != pv[ply]) { v = (pos.is_check() ? VALUE_NONE : evaluate(pos, m)); @@ -2528,8 +2526,8 @@ split_point_start: // At split points actual search starts from here } // pv_info_to_uci() returns a string with information on the current PV line - // formatted according to UCI specification and eventually writes the info - // to a log file. It is called at each iteration or after a new pv is found. + // formatted according to UCI specification. It is called at each iteration + // or after a new pv is found. std::string RootMove::pv_info_to_uci(Position& pos, int depth, Value alpha, Value beta, int pvLine) { @@ -2549,13 +2547,6 @@ split_point_start: // At split points actual search starts from here << " nps " << nps(pos) << " pv " << l.str(); - if (UseLogFile && pvLine == 0) - { - ValueType t = pv_score >= beta ? VALUE_TYPE_LOWER : - pv_score <= alpha ? VALUE_TYPE_UPPER : VALUE_TYPE_EXACT; - - LogFile << pretty_pv(pos, current_search_time(), depth, pv_score, t, pv) << endl; - } return s.str(); }