X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=c7bc8d1752f8c15e18ecf43baf1d3e0ae8f329d5;hp=653ef834418ae29881fbb252481245e347f890b9;hb=ad43ce143664953087b44dd3b4324f77c212bd46;hpb=750ac9ac5098f3423a753f56e86e7d5089771d21 diff --git a/src/search.cpp b/src/search.cpp index 653ef834..c7bc8d17 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -296,12 +296,12 @@ void Search::think() { || count(SearchMoves.begin(), SearchMoves.end(), ml.move())) RootMoves.push_back(RootMove(ml.move())); - if (Options["OwnBook"].value()) + if (Options["OwnBook"]) { - if (Options["Book File"].value() != book.name()) - book.open(Options["Book File"].value()); + if (book.name() != (string)Options["Book File"]) + book.open(Options["Book File"]); - Move bookMove = book.probe(pos, Options["Best Book Move"].value()); + Move bookMove = book.probe(pos, Options["Best Book Move"]); if ( bookMove != MOVE_NONE && count(RootMoves.begin(), RootMoves.end(), bookMove)) @@ -315,24 +315,24 @@ void Search::think() { read_evaluation_uci_options(pos.side_to_move()); Threads.read_uci_options(); - TT.set_size(Options["Hash"].value()); - if (Options["Clear Hash"].value()) + TT.set_size(Options["Hash"]); + if (Options["Clear Hash"]) { Options["Clear Hash"] = false; TT.clear(); } - UCIMultiPV = Options["MultiPV"].value(); - SkillLevel = Options["Skill Level"].value(); + UCIMultiPV = Options["MultiPV"]; + SkillLevel = Options["Skill Level"]; // Do we have to play with skill handicap? In this case enable MultiPV that // we will use behind the scenes to retrieve a set of possible moves. SkillLevelEnabled = (SkillLevel < 20); MultiPV = (SkillLevelEnabled ? std::max(UCIMultiPV, (size_t)4) : UCIMultiPV); - if (Options["Use Search Log"].value()) + if (Options["Use Search Log"]) { - Log log(Options["Search Log Filename"].value()); + Log log(Options["Search Log Filename"]); log << "\nSearching: " << pos.to_fen() << "\ninfinite: " << Limits.infinite << " ponder: " << Limits.ponder @@ -362,11 +362,11 @@ void Search::think() { Threads.set_timer(0); Threads.set_size(1); - if (Options["Use Search Log"].value()) + if (Options["Use Search Log"]) { int e = elapsed_time(); - Log log(Options["Search Log Filename"].value()); + Log log(Options["Search Log Filename"]); log << "Nodes: " << pos.nodes_searched() << "\nNodes/second: " << (e > 0 ? pos.nodes_searched() * 1000 / e : 0) << "\nBest move: " << move_to_san(pos, RootMoves[0].pv[0]); @@ -410,10 +410,10 @@ namespace { bestValue = delta = -VALUE_INFINITE; ss->currentMove = MOVE_NULL; // Hack to skip update gains - // Handle the special case of a mate/stalemate position + // Handle the special case of a mated/stalemate position if (RootMoves.empty()) { - cout << "info depth 0" + cout << "info depth 0 score " << score_to_uci(pos.in_check() ? -VALUE_MATE : VALUE_DRAW) << endl; RootMoves.push_back(MOVE_NONE); @@ -512,7 +512,7 @@ namespace { if (SkillLevelEnabled && depth == 1 + SkillLevel) skillBest = do_skill_level(); - if (Options["Use Search Log"].value()) + if (Options["Use Search Log"]) pv_info_to_log(pos, depth, bestValue, elapsed_time(), &RootMoves[0].pv[0]); // Filter out startup noise when monitoring best move stability @@ -706,7 +706,7 @@ namespace { if ( (move = (ss-1)->currentMove) != MOVE_NULL && (ss-1)->eval != VALUE_NONE && ss->eval != VALUE_NONE - && pos.captured_piece_type() == PIECE_TYPE_NONE + && pos.captured_piece_type() == NO_PIECE_TYPE && !is_special(move)) { Square to = move_to(move); @@ -1370,7 +1370,7 @@ split_point_start: // At split points actual search starts from here // All legal moves have been searched. A special case: If we're in check // and no legal moves were found, it is checkmate. if (inCheck && bestValue == -VALUE_INFINITE) - return mated_in(ss->ply); + return mated_in(ss->ply); // Plies to mate from the root // Update transposition table move = bestValue <= oldAlpha ? MOVE_NONE : ss->bestMove; @@ -1495,8 +1495,8 @@ split_point_start: // At split points actual search starts from here // value_to_tt() adjusts a mate score from "plies to mate from the root" to - // "plies to mate from the current ply". Non-mate scores are unchanged. The - // function is called before storing a value to the transposition table. + // "plies to mate from the current position". Non-mate scores are unchanged. + // The function is called before storing a value to the transposition table. Value value_to_tt(Value v, int ply) { @@ -1510,8 +1510,9 @@ split_point_start: // At split points actual search starts from here } - // value_from_tt() is the inverse of value_to_tt(): It adjusts a mate score from - // the transposition table to a mate score corrected for the current ply. + // value_from_tt() is the inverse of value_to_tt(): It adjusts a mate score + // from the transposition table (where refers to the plies to mate/be mated + // from current position) to "plies to mate/be mated from the root". Value value_from_tt(Value v, int ply) { @@ -1623,10 +1624,10 @@ split_point_start: // At split points actual search starts from here std::stringstream s; - if (abs(v) < VALUE_MATE - PLY_MAX * ONE_PLY) - s << " score cp " << int(v) * 100 / int(PawnValueMidgame); // Scale to centipawns + if (abs(v) < VALUE_MATE_IN_PLY_MAX) + s << "cp " << v * 100 / int(PawnValueMidgame); else - s << " score mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2; + s << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2; s << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : ""); @@ -1663,7 +1664,7 @@ split_point_start: // At split points actual search starts from here cout << "info depth " << d << " seldepth " << selDepth - << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v)) + << " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v)) << " nodes " << pos.nodes_searched() << " nps " << (t > 0 ? pos.nodes_searched() * 1000 / t : 0) << " time " << t @@ -1757,7 +1758,7 @@ split_point_start: // At split points actual search starts from here while (m != pv) pos.undo_move(*--m); - Log l(Options["Search Log Filename"].value()); + Log l(Options["Search Log Filename"]); l << s.str() << endl; }