Go to the documentation of this file.00001
00002
00003 #include "osl/search/historyTable.h"
00004 #include <algorithm>
00005 #include <functional>
00006 #include <iostream>
00007
00008 void osl::search::
00009 HistoryTable::extractTopN(Player p, vector<OutputEntry>& out, size_t limit) const
00010 {
00011 out.clear();
00012 for (size_t i=0; i<=Square(9,9).uintValue(); ++i)
00013 for (size_t j=Square(1,1).uintValue(); j<=Square(9,9).uintValue(); ++j)
00014 if (table[p][i][j].value > 100)
00015 out.push_back(OutputEntry(i, j, table[p][i][j].value));
00016 std::sort(out.begin(), out.end(), std::greater<OutputEntry>());
00017 if (limit < out.size())
00018 out.resize(limit);
00019 }
00020
00021 std::ostream& osl::search::operator<<(std::ostream& os, const HistoryTable::OutputEntry& e)
00022 {
00023 os << '(';
00024 if (e.from_or_ptype < PTYPE_SIZE)
00025 os << Ptype(e.from_or_ptype);
00026 else
00027 os << Square::makeDirect(e.from_or_ptype);
00028 return os << " => " << e.to << " " << e.value << ")";
00029 }
00030
00031
00032
00033
00034