in simple_game/search.h [840:892]
InfoSets sample() {
const auto& options = manager_.getOptions();
auto infoSetsWithStats = getInfoSetsWithStats();
int totalNumState = 0;
for (int i = 0; i < (int)infoSetsWithStats.size(); ++i) {
const auto& states = infoSetsWithStats[i].info->states();
totalNumState += states.size();
}
auto samples = getSamples(infoSetsWithStats);
clearSampledStates();
if (samples.empty())
return _getInfoSets(infoSetsWithStats);
struct _Data {
int cnt = 0;
int total;
std::shared_ptr<InfoSet> info;
};
std::unordered_map<std::string, _Data> counts;
for (const auto& p : samples) {
const auto& info = infoSetsWithStats[p.first].info;
auto& s = info->states()[p.second];
s->setSampleActive(true);
sampledRootStates_.push_back(s);
auto& c = counts[info->key()];
if (c.cnt == 0) {
c.total = info->states().size();
c.info = info;
}
c.cnt++;
}
if (options.verbose == NORMAL) {
std::cout << "Sampled: #infoSet: " << counts.size() << "/"
<< infoSetsWithStats.size() << ", #states: " << samples.size()
<< "/" << totalNumState << std::endl;
}
if (options.verbose == VERBOSE) {
for (const auto& kv : counts) {
std::cout << "Sample: infoSet[" << kv.first << "]: " << kv.second.cnt
<< "/" << kv.second.total << std::endl;
}
}
InfoSets infoSets;
for (const auto& kv : counts) {
infoSets.push_back(kv.second.info);
}
return infoSets;
}