- // 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, int depth, Value alpha, Value beta) {
-
- std::stringstream ss;
- Time::point elapsed = Time::now() - SearchTime + 1;
- size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
- int selDepth = 0;
-
- for (size_t i = 0; i < Threads.size(); ++i)
- if (Threads[i]->maxPly > selDepth)
- selDepth = Threads[i]->maxPly;
-
- for (size_t i = 0; i < uciPVSize; ++i)
- {
- bool updated = (i <= PVIdx);
-
- if (depth == 1 && !updated)
- continue;
-
- int d = updated ? depth : depth - 1;
- Value v = updated ? RootMoves[i].score : RootMoves[i].prevScore;
-
- if (ss.rdbuf()->in_avail()) // Not at first line
- ss << "\n";
-
- ss << "info depth " << d
- << " seldepth " << selDepth
- << " multipv " << i + 1
- << " score " << (i == PVIdx ? UCI::format_value(v, alpha, beta) : UCI::format_value(v))
- << " nodes " << pos.nodes_searched()
- << " nps " << pos.nodes_searched() * 1000 / elapsed
- << " time " << elapsed
- << " pv";