std::string UCTSearch::get_pv(BoardHistory& state, UCTNode& parent, bool use_san) { if (!parent.has_children()) { return std::string(); } auto& best_child = parent.get_best_root_child(state.cur().side_to_move()); auto best_move = best_child.get_move(); auto res = use_san ? state.cur().move_to_san(best_move) : UCI::move(best_move); StateInfo st; state.cur().do_move(best_move, st); auto next = get_pv(state, best_child, use_san); if (!next.empty()) { res.append(" ").append(next); } state.cur().undo_move(best_move); return res; }
std::string UCTSearch::get_pv(FastState & state, UCTNode& parent) { if (!parent.has_children()) { return std::string(); } auto& best_child = parent.get_best_root_child(state.get_to_move()); if (best_child.first_visit()) { return std::string(); } auto best_move = best_child.get_move(); auto res = state.move_to_text(best_move); state.play_move(best_move); auto next = get_pv(state, best_child); if (!next.empty()) { res.append(" ").append(next); } return res; }