@@ -109,7 +109,6 @@ namespace {
109109 Value value_from_tt (Value v, int ply);
110110 void update_pv (Move* pv, Move move, Move* childPv);
111111 void update_stats (const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt);
112- string uci_pv (const Position& pos, Depth depth, Value alpha, Value beta);
113112
114113} // namespace
115114
@@ -357,7 +356,7 @@ namespace {
357356 if ( multiPV == 1
358357 && (bestValue <= alpha || bestValue >= beta)
359358 && Time::now () - SearchTime > 3000 )
360- sync_cout << uci_pv (pos, depth, alpha, beta) << sync_endl;
359+ sync_cout << UCI::pv (pos, depth, alpha, beta) << sync_endl;
361360
362361 // In case of failing low/high increase aspiration window and
363362 // re-search, otherwise exit the loop.
@@ -390,7 +389,7 @@ namespace {
390389 << " time " << Time::now () - SearchTime << sync_endl;
391390
392391 else if (PVIdx + 1 == multiPV || Time::now () - SearchTime > 3000 )
393- sync_cout << uci_pv (pos, depth, alpha, beta) << sync_endl;
392+ sync_cout << UCI::pv (pos, depth, alpha, beta) << sync_endl;
394393 }
395394
396395 // If skill level is enabled and time is up, pick a sub-optimal best move
@@ -1399,60 +1398,60 @@ namespace {
13991398 return best;
14001399 }
14011400
1401+ } // namespace
14021402
1403- // uci_pv() formats PV information according to the UCI protocol. UCI
1404- // requires that all (if any) unsearched PV lines are sent using a previous
1405- // search score.
14061403
1407- string uci_pv (const Position& pos, Depth depth, Value alpha, Value beta) {
1404+ // / UCI::pv() formats PV information according to the UCI protocol. UCI requires
1405+ // / that all (if any) unsearched PV lines are sent using a previous search score.
14081406
1409- std::stringstream ss;
1410- Time::point elapsed = Time::now () - SearchTime + 1 ;
1411- size_t uciPVSize = std::min ((size_t )Options[" MultiPV" ], RootMoves.size ());
1412- int selDepth = 0 ;
1407+ string UCI::pv (const Position& pos, Depth depth, Value alpha, Value beta) {
14131408
1414- for (Thread* th : Threads)
1415- if (th->maxPly > selDepth)
1416- selDepth = th->maxPly ;
1409+ std::stringstream ss;
1410+ Time::point elapsed = Time::now () - SearchTime + 1 ;
1411+ size_t multiPV = std::min ((size_t )Options[" MultiPV" ], RootMoves.size ());
1412+ int selDepth = 0 ;
14171413
1418- for (size_t i = 0 ; i < uciPVSize; ++i )
1419- {
1420- bool updated = (i <= PVIdx) ;
1414+ for (Thread* th : Threads )
1415+ if (th-> maxPly > selDepth)
1416+ selDepth = th-> maxPly ;
14211417
1422- if (depth == ONE_PLY && !updated)
1423- continue ;
1418+ for (size_t i = 0 ; i < multiPV; ++i)
1419+ {
1420+ bool updated = (i <= PVIdx);
14241421
1425- Depth d = updated ? depth : depth - ONE_PLY;
1426- Value v = updated ? RootMoves[i]. score : RootMoves[i]. previousScore ;
1422+ if (depth == ONE_PLY && !updated)
1423+ continue ;
14271424
1428- bool tb = TB::RootInTB && abs (v) < VALUE_MATE - MAX_PLY ;
1429- v = tb ? TB::Score : v ;
1425+ Depth d = updated ? depth : depth - ONE_PLY ;
1426+ Value v = updated ? RootMoves[i]. score : RootMoves[i]. previousScore ;
14301427
1431- if (ss. rdbuf ()-> in_avail ()) // Not at first line
1432- ss << " \n " ;
1428+ bool tb = TB::RootInTB && abs (v) < VALUE_MATE - MAX_PLY;
1429+ v = tb ? TB::Score : v ;
14331430
1434- ss << " info depth " << d / ONE_PLY
1435- << " seldepth " << selDepth
1436- << " multipv " << i + 1
1437- << " score " << UCI::value (v);
1431+ if (ss.rdbuf ()->in_avail ()) // Not at first line
1432+ ss << " \n " ;
14381433
1439- if (!tb && i == PVIdx)
1440- ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : " " );
1434+ ss << " info"
1435+ << " depth " << d / ONE_PLY
1436+ << " seldepth " << selDepth
1437+ << " multipv " << i + 1
1438+ << " score " << UCI::value (v);
14411439
1442- ss << " nodes " << pos.nodes_searched ()
1443- << " nps " << pos.nodes_searched () * 1000 / elapsed
1444- << " tbhits " << TB::Hits
1445- << " time " << elapsed
1446- << " pv" ;
1440+ if (!tb && i == PVIdx)
1441+ ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : " " );
14471442
1448- for (size_t j = 0 ; j < RootMoves[i].pv .size (); ++j)
1449- ss << " " << UCI::move (RootMoves[i].pv [j], pos.is_chess960 ());
1450- }
1443+ ss << " nodes " << pos.nodes_searched ()
1444+ << " nps " << pos.nodes_searched () * 1000 / elapsed
1445+ << " tbhits " << TB::Hits
1446+ << " time " << elapsed
1447+ << " pv" ;
14511448
1452- return ss.str ();
1449+ for (Move m : RootMoves[i].pv )
1450+ ss << " " << UCI::move (m, pos.is_chess960 ());
14531451 }
14541452
1455- } // namespace
1453+ return ss.str ();
1454+ }
14561455
14571456
14581457// / RootMove::insert_pv_in_tt() is called at the end of a search iteration, and
0 commit comments