in simple_game/search.cc [79:110]
std::string ResultAgg::info(const Manager& m, bool sortByValue) const {
std::stringstream ss;
auto compByValue = [](const Result& r1, const Result& r2) {
return r1.value > r2.value;
};
auto compByPrefix = [&m](const Result& r1, const Result& r2) {
return r1.prefix(m) < r2.prefix(m);
};
std::vector<Result> results2;
for (const auto& rr : results) {
results2.push_back(rr.second);
}
if (sortByValue) {
std::sort(results2.begin(), results2.end(), compByValue);
} else {
std::sort(results2.begin(), results2.end(), compByPrefix);
}
for (const auto& rr : results2) {
ss << rr.info(m) << std::endl;
}
if (!results2.empty() && sortByValue) {
ss << "Best over " << results2.size() << ": " << results2[0].info(m)
<< std::endl;
}
return ss.str();
}