Skip to content

Commit a70fc05

Browse files
committed
Fix caching in MixedStrategyProfile
For mixed strategy profiles which are defined on trees, a behavior strategy profile is computed and cached. This was not correctly being cleared when changing the strategy probabilities, resulting in incorrect output. Closes #616.
1 parent 9d28e17 commit a70fc05

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/games/stratmixed.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ template <class T> class MixedStrategyProfileRep {
4949
return m_probs[m_profileIndex.at(p_strategy)];
5050
}
5151
/// Returns the probability the strategy is played
52-
T &operator[](const GameStrategy &p_strategy) { return m_probs[m_profileIndex.at(p_strategy)]; }
52+
T &operator[](const GameStrategy &p_strategy)
53+
{
54+
InvalidateCache();
55+
return m_probs[m_profileIndex.at(p_strategy)];
56+
}
5357
/// Set the strategy of the corresponding player to a pure strategy
5458
void SetStrategy(const GameStrategy &p_strategy)
5559
{

0 commit comments

Comments
 (0)