Skip to content

Commit 6d3d556

Browse files
committed
Ensure ordering whenever we create a profile.
1 parent 6a0210b commit 6d3d556

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/games/behavmixed.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ MixedBehaviorProfile<T>::MixedBehaviorProfile(const Game &p_game)
3737
: m_probs(p_game->BehavProfileLength()), m_support(BehaviorSupportProfile(p_game)),
3838
m_gameversion(p_game->GetVersion())
3939
{
40+
p_game->EnsureInfosetOrdering();
4041
int index = 1;
4142
for (const auto &infoset : p_game->GetInfosets()) {
4243
for (const auto &action : infoset->GetActions()) {
@@ -51,6 +52,7 @@ MixedBehaviorProfile<T>::MixedBehaviorProfile(const BehaviorSupportProfile &p_su
5152
: m_probs(p_support.BehaviorProfileLength()), m_support(p_support),
5253
m_gameversion(p_support.GetGame()->GetVersion())
5354
{
55+
m_support.GetGame()->EnsureInfosetOrdering();
5456
int index = 1;
5557
for (const auto &infoset : p_support.GetGame()->GetInfosets()) {
5658
for (const auto &action : infoset->GetActions()) {
@@ -126,6 +128,7 @@ MixedBehaviorProfile<T>::MixedBehaviorProfile(const MixedStrategyProfile<T> &p_p
126128
: m_probs(p_profile.GetGame()->BehavProfileLength()), m_support(p_profile.GetGame()),
127129
m_gameversion(p_profile.GetGame()->GetVersion())
128130
{
131+
m_support.GetGame()->EnsureInfosetOrdering();
129132
int index = 1;
130133
for (const auto &infoset : p_profile.GetGame()->GetInfosets()) {
131134
for (const auto &action : infoset->GetActions()) {

src/games/gametree.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ void GameTreeRep::BuildComputedValues() const
916916
if (m_computedValues) {
917917
return;
918918
}
919-
EnsureNodeOrdering();
919+
EnsureInfosetOrdering();
920920
for (const auto &player : m_players) {
921921
std::map<GameInfosetRep *, int> behav;
922922
std::map<GameNodeRep *, GameNodeRep *> ptr, whichbranch;
@@ -1354,6 +1354,7 @@ MixedStrategyProfile<double> GameTreeRep::NewMixedStrategyProfile(double) const
13541354
if (!IsPerfectRecall()) {
13551355
throw UndefinedException("Mixed strategies not supported for games with imperfect recall.");
13561356
}
1357+
EnsureInfosetOrdering();
13571358
return StrategySupportProfile(std::const_pointer_cast<GameRep>(shared_from_this()))
13581359
.NewMixedStrategyProfile<double>();
13591360
}
@@ -1363,6 +1364,7 @@ MixedStrategyProfile<Rational> GameTreeRep::NewMixedStrategyProfile(const Ration
13631364
if (!IsPerfectRecall()) {
13641365
throw UndefinedException("Mixed strategies not supported for games with imperfect recall.");
13651366
}
1367+
EnsureInfosetOrdering();
13661368
return StrategySupportProfile(std::const_pointer_cast<GameRep>(shared_from_this()))
13671369
.NewMixedStrategyProfile<Rational>();
13681370
}
@@ -1373,6 +1375,7 @@ GameTreeRep::NewMixedStrategyProfile(double, const StrategySupportProfile &spt)
13731375
if (!IsPerfectRecall()) {
13741376
throw UndefinedException("Mixed strategies not supported for games with imperfect recall.");
13751377
}
1378+
EnsureInfosetOrdering();
13761379
return MixedStrategyProfile<double>(std::make_unique<TreeMixedStrategyProfileRep<double>>(spt));
13771380
}
13781381

@@ -1382,6 +1385,7 @@ GameTreeRep::NewMixedStrategyProfile(const Rational &, const StrategySupportProf
13821385
if (!IsPerfectRecall()) {
13831386
throw UndefinedException("Mixed strategies not supported for games with imperfect recall.");
13841387
}
1388+
EnsureInfosetOrdering();
13851389
return MixedStrategyProfile<Rational>(
13861390
std::make_unique<TreeMixedStrategyProfileRep<Rational>>(spt));
13871391
}
@@ -1411,6 +1415,7 @@ class TreePureStrategyProfileRep : public PureStrategyProfileRep {
14111415

14121416
PureStrategyProfile GameTreeRep::NewPureStrategyProfile() const
14131417
{
1418+
EnsureInfosetOrdering();
14141419
return PureStrategyProfile(std::make_shared<TreePureStrategyProfileRep>(
14151420
std::const_pointer_cast<GameRep>(shared_from_this())));
14161421
}

0 commit comments

Comments
 (0)