|
10 | 10 | from typing import Any |
11 | 11 |
|
12 | 12 | import pygambit as gbt |
13 | | -from pygambit.enumeration import SupportEnumeration |
| 13 | +from pygambit.nash import possible_nash_supports |
14 | 14 |
|
15 | 15 | from gambit_plugin.gambit_utils import extensive_to_gambit_table, normal_form_to_gambit |
16 | 16 | from gambit_plugin.strategies import enumerate_strategies, resolve_payoffs |
@@ -44,8 +44,7 @@ def run_support_enum( |
44 | 44 | gambit_game = extensive_to_gambit_table(game, strategies, resolve_payoffs) |
45 | 45 |
|
46 | 46 | try: |
47 | | - enumerator = SupportEnumeration() |
48 | | - supports = list(enumerator.enumerate_supports(gambit_game)) |
| 47 | + supports = possible_nash_supports(gambit_game) |
49 | 48 |
|
50 | 49 | # Convert to serializable format |
51 | 50 | support_list = [] |
@@ -76,20 +75,14 @@ def run_support_enum( |
76 | 75 | } |
77 | 76 |
|
78 | 77 |
|
79 | | -def _support_to_dict(game: gbt.Game, support) -> dict[str, Any]: |
80 | | - """Convert a support profile to a serializable dict.""" |
| 78 | +def _support_to_dict(game: gbt.Game, support: gbt.StrategySupportProfile) -> dict[str, Any]: |
| 79 | + """Convert a StrategySupportProfile to a serializable dict.""" |
81 | 80 | result: dict[str, list[str]] = {} |
82 | 81 |
|
83 | | - # Support is indexed by player |
84 | 82 | for player in game.players: |
85 | 83 | player_support = [] |
86 | 84 | for strategy in player.strategies: |
87 | | - # Check if strategy is in support |
88 | | - try: |
89 | | - if support[strategy]: |
90 | | - player_support.append(strategy.label) |
91 | | - except (KeyError, TypeError): |
92 | | - # If we can't check, assume it's in support |
| 85 | + if strategy in support: |
93 | 86 | player_support.append(strategy.label) |
94 | 87 | result[player.label] = player_support |
95 | 88 |
|
|
0 commit comments