X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=53a8bec9b15751981c22354e4a02525274c79887;hp=6ec051987d98663a775252e74f77e52f52f8575e;hb=22ede4442cd285d7365b9497c3be65fb2c66b4be;hpb=6df86fc9dadcd02fef82605027156dbea6832d29 diff --git a/src/search.cpp b/src/search.cpp index 6ec05198..53a8bec9 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -149,7 +149,7 @@ namespace { void set_non_pv_scores(const Position& pos); void sort() { insertion_sort(begin(), end()); } - void sort_multipv(int n) { insertion_sort(begin(), begin() + n); } + void sort_multipv(int n) { insertion_sort(begin(), begin() + n + 1); } }; @@ -484,7 +484,7 @@ 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() + LogFile << "Searching: " << pos.to_fen(Options["UCI_Chess960"].value()) << "\ninfinite: " << infinite << " ponder: " << ponder << " time: " << myTime @@ -513,6 +513,9 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[ << move_to_san(pos, ponderMove) // Works also with MOVE_NONE << endl; + // Return from think() with unchanged position + pos.undo_move(bestMove); + LogFile.close(); } @@ -567,7 +570,7 @@ namespace { Iteration = 1; // Send initial RootMoveList scoring (iteration 1) - cout << set960(pos.is_chess960()) // Is enough to set once at the beginning + cout << set960(Options["UCI_Chess960"].value()) // Is enough to set once at the beginning << "info depth " << Iteration << "\n" << rml[0].pv_info_to_uci(pos, alpha, beta) << endl; @@ -903,7 +906,7 @@ namespace { // Write PV lines to transposition table, in case the relevant entries // have been overwritten during the search. - for (int i = 0; i < MultiPV; i++) + for (int i = 0; i < Min(MultiPV, (int)rml.size()); i++) rml[i].insert_pv_in_tt(pos); return alpha; @@ -1927,12 +1930,21 @@ split_point_start: // At split points actual search starts from here } - // current_search_time() returns the number of milliseconds which have passed - // since the beginning of the current search. + // init_ss_array() does a fast reset of the first entries of a SearchStack + // array and of all the excludedMove and skipNullMove entries. - int current_search_time() { + void init_ss_array(SearchStack* ss, int size) { - return get_system_time() - SearchStartTime; + for (int i = 0; i < size; i++, ss++) + { + ss->excludedMove = MOVE_NONE; + ss->skipNullMove = false; + ss->reduction = DEPTH_ZERO; + ss->sp = NULL; + + if (i < 3) + ss->killers[0] = ss->killers[1] = ss->mateKiller = MOVE_NONE; + } } @@ -1955,7 +1967,17 @@ split_point_start: // At split points actual search starts from here return s.str(); } - // nps() computes the current nodes/second count. + + // current_search_time() returns the number of milliseconds which have passed + // since the beginning of the current search. + + int current_search_time() { + + return get_system_time() - SearchStartTime; + } + + + // nps() computes the current nodes/second count int nps(const Position& pos) { @@ -2042,31 +2064,13 @@ split_point_start: // At split points actual search starts from here bool noMoreTime = t > TimeMgr.maximum_time() || stillAtFirstMove; - if ( (Iteration >= 3 && UseTimeManagement && noMoreTime) + if ( (UseTimeManagement && noMoreTime) || (ExactMaxTime && t >= ExactMaxTime) - || (Iteration >= 3 && MaxNodes && pos.nodes_searched() >= MaxNodes)) + || (MaxNodes && pos.nodes_searched() >= MaxNodes)) // FIXME StopRequest = true; } - // init_ss_array() does a fast reset of the first entries of a SearchStack - // array and of all the excludedMove and skipNullMove entries. - - void init_ss_array(SearchStack* ss, int size) { - - for (int i = 0; i < size; i++, ss++) - { - ss->excludedMove = MOVE_NONE; - ss->skipNullMove = false; - ss->reduction = DEPTH_ZERO; - ss->sp = NULL; - - if (i < 3) - ss->killers[0] = ss->killers[1] = ss->mateKiller = MOVE_NONE; - } - } - - // wait_for_stop_or_ponderhit() is called when the maximum depth is reached // while the program is pondering. The point is to work around a wrinkle in // the UCI protocol: When pondering, the engine is not allowed to give a @@ -2080,6 +2084,7 @@ split_point_start: // At split points actual search starts from here while (true) { + // Wait for a command from stdin if (!std::getline(std::cin, command)) command = "quit";