mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 13:17:44 +00:00
Move uci_pv under UCI namespace
That's the correct place. No functional change.
This commit is contained in:
+40
-41
@@ -109,7 +109,6 @@ namespace {
|
|||||||
Value value_from_tt(Value v, int ply);
|
Value value_from_tt(Value v, int ply);
|
||||||
void update_pv(Move* pv, Move move, Move* childPv);
|
void update_pv(Move* pv, Move move, Move* childPv);
|
||||||
void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt);
|
void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt);
|
||||||
string uci_pv(const Position& pos, Depth depth, Value alpha, Value beta);
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -357,7 +356,7 @@ namespace {
|
|||||||
if ( multiPV == 1
|
if ( multiPV == 1
|
||||||
&& (bestValue <= alpha || bestValue >= beta)
|
&& (bestValue <= alpha || bestValue >= beta)
|
||||||
&& Time::now() - SearchTime > 3000)
|
&& Time::now() - SearchTime > 3000)
|
||||||
sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
|
sync_cout << UCI::pv(pos, depth, alpha, beta) << sync_endl;
|
||||||
|
|
||||||
// In case of failing low/high increase aspiration window and
|
// In case of failing low/high increase aspiration window and
|
||||||
// re-search, otherwise exit the loop.
|
// re-search, otherwise exit the loop.
|
||||||
@@ -390,7 +389,7 @@ namespace {
|
|||||||
<< " time " << Time::now() - SearchTime << sync_endl;
|
<< " time " << Time::now() - SearchTime << sync_endl;
|
||||||
|
|
||||||
else if (PVIdx + 1 == multiPV || Time::now() - SearchTime > 3000)
|
else if (PVIdx + 1 == multiPV || Time::now() - SearchTime > 3000)
|
||||||
sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
|
sync_cout << UCI::pv(pos, depth, alpha, beta) << sync_endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If skill level is enabled and time is up, pick a sub-optimal best move
|
// If skill level is enabled and time is up, pick a sub-optimal best move
|
||||||
@@ -1399,60 +1398,60 @@ moves_loop: // When in check and at SpNode search starts from here
|
|||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// uci_pv() formats PV information according to the UCI protocol. UCI
|
|
||||||
// requires that all (if any) unsearched PV lines are sent using a previous
|
|
||||||
// search score.
|
|
||||||
|
|
||||||
string uci_pv(const Position& pos, Depth depth, Value alpha, Value beta) {
|
/// UCI::pv() formats PV information according to the UCI protocol. UCI requires
|
||||||
|
/// that all (if any) unsearched PV lines are sent using a previous search score.
|
||||||
|
|
||||||
std::stringstream ss;
|
string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
|
||||||
Time::point elapsed = Time::now() - SearchTime + 1;
|
|
||||||
size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
|
|
||||||
int selDepth = 0;
|
|
||||||
|
|
||||||
for (Thread* th : Threads)
|
std::stringstream ss;
|
||||||
if (th->maxPly > selDepth)
|
Time::point elapsed = Time::now() - SearchTime + 1;
|
||||||
selDepth = th->maxPly;
|
size_t multiPV = std::min((size_t)Options["MultiPV"], RootMoves.size());
|
||||||
|
int selDepth = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < uciPVSize; ++i)
|
for (Thread* th : Threads)
|
||||||
{
|
if (th->maxPly > selDepth)
|
||||||
bool updated = (i <= PVIdx);
|
selDepth = th->maxPly;
|
||||||
|
|
||||||
if (depth == ONE_PLY && !updated)
|
for (size_t i = 0; i < multiPV; ++i)
|
||||||
continue;
|
{
|
||||||
|
bool updated = (i <= PVIdx);
|
||||||
|
|
||||||
Depth d = updated ? depth : depth - ONE_PLY;
|
if (depth == ONE_PLY && !updated)
|
||||||
Value v = updated ? RootMoves[i].score : RootMoves[i].previousScore;
|
continue;
|
||||||
|
|
||||||
bool tb = TB::RootInTB && abs(v) < VALUE_MATE - MAX_PLY;
|
Depth d = updated ? depth : depth - ONE_PLY;
|
||||||
v = tb ? TB::Score : v;
|
Value v = updated ? RootMoves[i].score : RootMoves[i].previousScore;
|
||||||
|
|
||||||
if (ss.rdbuf()->in_avail()) // Not at first line
|
bool tb = TB::RootInTB && abs(v) < VALUE_MATE - MAX_PLY;
|
||||||
ss << "\n";
|
v = tb ? TB::Score : v;
|
||||||
|
|
||||||
ss << "info depth " << d / ONE_PLY
|
if (ss.rdbuf()->in_avail()) // Not at first line
|
||||||
<< " seldepth " << selDepth
|
ss << "\n";
|
||||||
<< " multipv " << i + 1
|
|
||||||
<< " score " << UCI::value(v);
|
|
||||||
|
|
||||||
if (!tb && i == PVIdx)
|
ss << "info"
|
||||||
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
|
<< " depth " << d / ONE_PLY
|
||||||
|
<< " seldepth " << selDepth
|
||||||
|
<< " multipv " << i + 1
|
||||||
|
<< " score " << UCI::value(v);
|
||||||
|
|
||||||
ss << " nodes " << pos.nodes_searched()
|
if (!tb && i == PVIdx)
|
||||||
<< " nps " << pos.nodes_searched() * 1000 / elapsed
|
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
|
||||||
<< " tbhits " << TB::Hits
|
|
||||||
<< " time " << elapsed
|
|
||||||
<< " pv";
|
|
||||||
|
|
||||||
for (size_t j = 0; j < RootMoves[i].pv.size(); ++j)
|
ss << " nodes " << pos.nodes_searched()
|
||||||
ss << " " << UCI::move(RootMoves[i].pv[j], pos.is_chess960());
|
<< " nps " << pos.nodes_searched() * 1000 / elapsed
|
||||||
}
|
<< " tbhits " << TB::Hits
|
||||||
|
<< " time " << elapsed
|
||||||
|
<< " pv";
|
||||||
|
|
||||||
return ss.str();
|
for (Move m : RootMoves[i].pv)
|
||||||
|
ss << " " << UCI::move(m, pos.is_chess960());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// RootMove::insert_pv_in_tt() is called at the end of a search iteration, and
|
/// RootMove::insert_pv_in_tt() is called at the end of a search iteration, and
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ void loop(int argc, char* argv[]);
|
|||||||
std::string value(Value v);
|
std::string value(Value v);
|
||||||
std::string square(Square s);
|
std::string square(Square s);
|
||||||
std::string move(Move m, bool chess960);
|
std::string move(Move m, bool chess960);
|
||||||
|
std::string pv(const Position& pos, Depth depth, Value alpha, Value beta);
|
||||||
Move to_move(const Position& pos, std::string& str);
|
Move to_move(const Position& pos, std::string& str);
|
||||||
|
|
||||||
} // namespace UCI
|
} // namespace UCI
|
||||||
|
|||||||
Reference in New Issue
Block a user