@@ -106,106 +106,6 @@ std::list<GameInfoset> BehaviorSupportProfile::GetInfosets(const GamePlayer &p_p
106106 return answer;
107107}
108108
109- namespace {
110-
111- void ReachableInfosets (const BehaviorSupportProfile &p_support, const GameNode &p_node,
112- std::set<GameInfoset> &p_reached)
113- {
114- if (p_node->IsTerminal ()) {
115- return ;
116- }
117-
118- const GameInfoset infoset = p_node->GetInfoset ();
119- if (!infoset->GetPlayer ()->IsChance ()) {
120- p_reached.insert (infoset);
121- for (const auto &action : p_support.GetActions (infoset)) {
122- ReachableInfosets (p_support, p_node->GetChild (action), p_reached);
123- }
124- }
125- else {
126- for (const auto &child : p_node->GetChildren ()) {
127- ReachableInfosets (p_support, child, p_reached);
128- }
129- }
130- }
131-
132- } // end anonymous namespace
133-
134- bool BehaviorSupportProfile::Dominates (const GameAction &a, const GameAction &b,
135- bool p_strict) const
136- {
137- const GameInfoset infoset = a->GetInfoset ();
138- if (infoset != b->GetInfoset ()) {
139- throw UndefinedException ();
140- }
141-
142- GamePlayer player = infoset->GetPlayer ();
143- int thesign = 0 ;
144-
145- auto nodelist = GetMembers (infoset);
146- for (const auto &node : GetMembers (infoset)) {
147- std::set<GameInfoset> reachable;
148- ReachableInfosets (*this , node->GetChild (a), reachable);
149- ReachableInfosets (*this , node->GetChild (b), reachable);
150-
151- auto contingencies = BehaviorContingencies (*this , reachable);
152- if (p_strict) {
153- if (!std::all_of (contingencies.begin (), contingencies.end (),
154- [&](const PureBehaviorProfile &profile) {
155- return profile.GetPayoff <Rational>(node->GetChild (a), player) >
156- profile.GetPayoff <Rational>(node->GetChild (b), player);
157- })) {
158- return false ;
159- }
160- }
161- else {
162- for (const auto &iter : contingencies) {
163- auto newsign = sign (iter.GetPayoff <Rational>(node->GetChild (a), player) -
164- iter.GetPayoff <Rational>(node->GetChild (b), player));
165- if (newsign < 0 ) {
166- return false ;
167- }
168- thesign = std::max (thesign, newsign);
169- }
170- }
171- }
172- return p_strict || thesign > 0 ;
173- }
174-
175- bool BehaviorSupportProfile::IsDominated (const GameAction &p_action, const bool p_strict) const
176- {
177- const auto &actions = GetActions (p_action->GetInfoset ());
178- return std::any_of (actions.begin (), actions.end (), [&](const GameAction &a) {
179- return a != p_action && Dominates (a, p_action, p_strict);
180- });
181- }
182-
183- BehaviorSupportProfile BehaviorSupportProfile::Undominated (const bool p_strict) const
184- {
185- BehaviorSupportProfile result (*this );
186- for (const auto &player : m_efg->GetPlayers ()) {
187- for (const auto &infoset : player->GetInfosets ()) {
188- const auto &actions = GetActions (infoset);
189- std::set<GameAction> dominated;
190- for (const auto &action1 : actions) {
191- if (contains (dominated, action1)) {
192- continue ;
193- }
194- for (const auto &action2 : actions) {
195- if (action1 == action2 || contains (dominated, action2)) {
196- continue ;
197- }
198- if (Dominates (action1, action2, p_strict)) {
199- dominated.insert (action2);
200- result.RemoveAction (action2);
201- }
202- }
203- }
204- }
205- }
206- return result;
207- }
208-
209109bool BehaviorSupportProfile::HasReachableMembers (const GameInfoset &p_infoset) const
210110{
211111 const auto &members = p_infoset->GetMembers ();
0 commit comments