Skip to content

Commit fc4981e

Browse files
committed
Make regret and liap implementations in behaviour parallel to strategy
1 parent 3bcd4e1 commit fc4981e

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

src/games/behavmixed.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,11 @@ template <class T> T MixedBehaviorProfile<T>::GetLiapValue() const
266266
CheckVersion();
267267
ComputeSolutionData();
268268

269-
auto value = T(0);
270-
for (auto player : m_support.GetGame()->GetPlayers()) {
271-
for (auto infoset : player->GetInfosets()) {
272-
for (auto action : m_support.GetActions(infoset)) {
273-
value += sqr(std::max(GetPayoff(action) - GetPayoff(infoset), T(0)));
274-
}
269+
auto value = static_cast<T>(0);
270+
for (auto infoset : m_support.GetGame()->GetInfosets()) {
271+
for (auto action : m_support.GetActions(infoset)) {
272+
value +=
273+
sqr(std::max(map_actionValues[action] - map_infosetValues[infoset], static_cast<T>(0)));
275274
}
276275
}
277276
return value;
@@ -352,24 +351,23 @@ template <class T> const T &MixedBehaviorProfile<T>::GetRegret(const GameAction
352351
{
353352
CheckVersion();
354353
ComputeSolutionData();
355-
return map_regret[act];
354+
return map_regret.at(act);
356355
}
357356

358357
template <class T> T MixedBehaviorProfile<T>::GetRegret(const GameInfoset &p_infoset) const
359358
{
360-
auto actions = p_infoset->GetActions();
361-
T br_payoff = std::accumulate(
362-
std::next(actions.begin()), actions.end(), GetPayoff(*actions.begin()),
363-
[this](const T &x, const GameAction &action) { return std::max(x, GetPayoff(action)); });
364-
return br_payoff - GetPayoff(p_infoset);
359+
CheckVersion();
360+
ComputeSolutionData();
361+
T br_payoff = maximize_function(p_infoset->GetActions(), [this](const auto &action) -> T {
362+
return map_actionValues.at(action);
363+
});
364+
return br_payoff - map_infosetValues[p_infoset];
365365
}
366366

367367
template <class T> T MixedBehaviorProfile<T>::GetMaxRegret() const
368368
{
369-
auto infosets = m_support.GetGame()->GetInfosets();
370-
return std::accumulate(
371-
infosets.begin(), infosets.end(), T(0),
372-
[this](const T &x, const GameInfoset &infoset) { return std::max(x, GetRegret(infoset)); });
369+
return maximize_function(m_support.GetGame()->GetInfosets(),
370+
[this](const auto &infoset) -> T { return this->GetRegret(infoset); });
373371
}
374372

375373
template <class T>

0 commit comments

Comments
 (0)