in simple_game/search.h [1703:1786]
ResultAgg _bruteforceSearchJointInfoSet(const std::vector<Entry>& prefix,
const InfoSets& infoSets,
int playerIdx,
Analysis* analysis) {
// choose possible actions and set the policy accordingly
if (analysis != nullptr) {
dumpReachability(prefix, infoSets, analysis);
}
ResultAgg res;
if (options_.maxDepth <= 0 || options_.maxDepth > (int)prefix.size()) {
for (const auto& infoSet : infoSets) {
assert(!infoSet->isChance());
auto strategy = infoSet->strategy();
for (int a = 0; a < infoSet->numAction(); ++a) {
auto currAction = std::make_pair(infoSet->key(), a);
// Set to delta strategy.
if (options_.skipSameDeltaPolicy && _isDeltaStrategy(strategy, a))
continue;
infoSet->setDeltaStrategy(a);
if (options_.use2ndOrder) {
for (const auto& infoSet2 : infoSets) {
if (infoSet2->key() == infoSet->key())
break;
auto strategy2 = infoSet2->strategy();
for (int b = 0; b < infoSet2->numAction(); ++b) {
auto currAction2 = std::make_pair(infoSet2->key(), b);
if (options_.skipSameDeltaPolicy &&
_isDeltaStrategy(strategy2, b))
continue;
// Set to delta strategy.
infoSet2->setDeltaStrategy(b);
auto prefix2 = prefix;
prefix2.push_back(currAction);
prefix2.push_back(currAction2);
auto nextInfoSets =
combineInfoSets(infoSet->succ(a), infoSet2->succ(b));
// recurse its children.
auto thisRes = _bruteforceSearchJointInfoSet(
prefix2, nextInfoSets, playerIdx, analysis);
// auto thisRes = _bruteforceSearch(prefix2, nextInfoSets,
// playerIdx, analysis);
res.append(
thisRes.attach(currAction, 0).attach(currAction2, 0));
}
infoSet2->setStrategy(strategy2);
}
}
if (!options_.skipSingleInfoSetOpt) {
auto prefix2 = prefix;
prefix2.push_back(currAction);
// recurse its children.
auto thisRes = _bruteforceSearchJointInfoSet(
prefix2, infoSet->succ(a), playerIdx, analysis);
// auto thisRes = _bruteforceSearch(prefix2, nextInfoSets,
// playerIdx, analysis);
res.append(thisRes.attach(currAction, 0));
}
}
// Resume old strategy.
infoSet->setStrategy(strategy);
}
}
// Evaluate current policy.
evaluate();
res.append(Result(root_->u()[playerIdx]));
return res;
}