diff --git a/ChangeLog b/ChangeLog index 836c13e68..e6bd1f6f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ to the left, wrapping if appropriate). - Max regret is calculated correctly for strategy and behavior profiles on games with zero player strategies or actions (is defined to be 0 trivially) (#904) +- Corrected calculation of total number of actions for a player in `pygambit` (#938) ### Changed - Added a new welcome/landing window on launching the GUI without a game. This has the effect of diff --git a/src/pygambit/player.pxi b/src/pygambit/player.pxi index 90483f25f..4da57be4e 100644 --- a/src/pygambit/player.pxi +++ b/src/pygambit/player.pxi @@ -82,7 +82,7 @@ class PlayerActions: return f"PlayerActions(player={self.player})" def __len__(self) -> int: - return sum(len(s.actions) for s in self.player.actions) + return sum(len(s.actions) for s in self.player.infosets) def __iter__(self) -> typing.Iterator[Action]: for infoset in self.player.infosets: diff --git a/tests/test_actions.py b/tests/test_actions.py index 28989e33e..5c5c64863 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -251,3 +251,9 @@ def test_strategy_action_raises_error_for_strategic_game(): with pytest.raises(gbt.UndefinedOperationError): strategy.action(test_infoset) + + +def test_player_actions_len(): + game = games.create_stripped_down_poker_efg() + for player in game.players: + assert len(player.actions) == len(list(player.actions))