Skip to content

Commit c69b56d

Browse files
committed
Remove unused functionality from BehaviorContingencies
1 parent 4c00bb7 commit c69b56d

3 files changed

Lines changed: 11 additions & 59 deletions

File tree

src/games/behavpure.cc

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -98,30 +98,16 @@ MixedBehaviorProfile<Rational> PureBehaviorProfile::ToMixedBehaviorProfile() con
9898
// class BehaviorContingencies
9999
//========================================================================
100100

101-
BehaviorContingencies::BehaviorContingencies(const BehaviorSupportProfile &p_support,
102-
const std::set<GameInfoset> &p_reachable,
103-
const std::vector<GameAction> &p_frozen)
104-
: m_support(p_support), m_frozen(p_frozen)
101+
BehaviorContingencies::BehaviorContingencies(const BehaviorSupportProfile &p_support)
102+
: m_support(p_support)
105103
{
106-
if (!p_reachable.empty()) {
107-
for (const auto &infoset : p_reachable) {
108-
m_activeInfosets.push_back(infoset);
109-
}
110-
}
111-
else {
112-
for (const auto &player : m_support.GetGame()->GetPlayers()) {
113-
for (const auto &infoset : player->GetInfosets()) {
114-
if (p_support.IsReachable(infoset)) {
115-
m_activeInfosets.push_back(infoset);
116-
}
104+
for (const auto &player : m_support.GetGame()->GetPlayers()) {
105+
for (const auto &infoset : player->GetInfosets()) {
106+
if (p_support.IsReachable(infoset)) {
107+
m_reachableInfosets.push_back(infoset);
117108
}
118109
}
119110
}
120-
for (const auto &action : m_frozen) {
121-
m_activeInfosets.erase(std::find_if(
122-
m_activeInfosets.begin(), m_activeInfosets.end(),
123-
[action](const GameInfoset &infoset) { return infoset == action->GetInfoset(); }));
124-
}
125111
}
126112

127113
BehaviorContingencies::iterator::iterator(BehaviorContingencies *p_cont, bool p_end)
@@ -136,15 +122,12 @@ BehaviorContingencies::iterator::iterator(BehaviorContingencies *p_cont, bool p_
136122
m_profile.SetAction(*m_currentBehav[infoset]);
137123
}
138124
}
139-
for (const auto &action : m_cont->m_frozen) {
140-
m_profile.SetAction(action);
141-
}
142125
}
143126

144127
BehaviorContingencies::iterator &BehaviorContingencies::iterator::operator++()
145128
{
146-
for (auto infoset = m_cont->m_activeInfosets.crbegin();
147-
infoset != m_cont->m_activeInfosets.crend(); ++infoset) {
129+
for (auto infoset = m_cont->m_reachableInfosets.crbegin();
130+
infoset != m_cont->m_reachableInfosets.crend(); ++infoset) {
148131
++m_currentBehav[*infoset];
149132
if (m_currentBehav.at(*infoset) != m_cont->m_support.GetActions(*infoset).end()) {
150133
m_profile.SetAction(*m_currentBehav[*infoset]);

src/games/behavpure.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ namespace Gambit {
3232
/// It specifies exactly one strategy for each information set in the
3333
/// game.
3434
class PureBehaviorProfile {
35-
private:
3635
Game m_efg;
3736
std::map<GameInfoset, GameAction> m_profile;
3837

@@ -86,14 +85,11 @@ template <> inline std::string PureBehaviorProfile::GetPayoff(const GamePlayer &
8685
}
8786

8887
class BehaviorContingencies {
89-
private:
9088
BehaviorSupportProfile m_support;
91-
std::vector<GameAction> m_frozen;
92-
std::list<GameInfoset> m_activeInfosets;
89+
std::list<GameInfoset> m_reachableInfosets;
9390

9491
public:
9592
class iterator {
96-
private:
9793
BehaviorContingencies *m_cont;
9894
bool m_atEnd;
9995
std::map<GameInfoset, BehaviorSupportProfile::Support::const_iterator> m_currentBehav;
@@ -127,10 +123,8 @@ class BehaviorContingencies {
127123
};
128124
/// @name Lifecycle
129125
//@{
130-
/// Construct a new iterator on the support, holding the listed actions fixed
131-
explicit BehaviorContingencies(const BehaviorSupportProfile &,
132-
const std::set<GameInfoset> &p_active = {},
133-
const std::vector<GameAction> &p_frozen = {});
126+
/// Construct a new iterator on the support
127+
explicit BehaviorContingencies(const BehaviorSupportProfile &);
134128
//@}
135129
iterator begin() { return {this, false}; }
136130
iterator end() { return {this, true}; }

src/games/behavspt.cc

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,6 @@ std::list<GameInfoset> BehaviorSupportProfile::GetInfosets(const GamePlayer &p_p
104104
return answer;
105105
}
106106

107-
namespace {
108-
109-
void ReachableInfosets(const BehaviorSupportProfile &p_support, const GameNode &p_node,
110-
std::set<GameInfoset> &p_reached)
111-
{
112-
if (p_node->IsTerminal()) {
113-
return;
114-
}
115-
116-
const GameInfoset infoset = p_node->GetInfoset();
117-
if (!infoset->GetPlayer()->IsChance()) {
118-
p_reached.insert(infoset);
119-
for (const auto &action : p_support.GetActions(infoset)) {
120-
ReachableInfosets(p_support, p_node->GetChild(action), p_reached);
121-
}
122-
}
123-
else {
124-
for (const auto &child : p_node->GetChildren()) {
125-
ReachableInfosets(p_support, child, p_reached);
126-
}
127-
}
128-
}
129-
130-
} // end anonymous namespace
131-
132107
bool BehaviorSupportProfile::HasReachableMembers(const GameInfoset &p_infoset) const
133108
{
134109
const auto &members = p_infoset->GetMembers();

0 commit comments

Comments
 (0)