From 45b08ad43156268e0db1fb60f4faf359cfe61069 Mon Sep 17 00:00:00 2001 From: drdkad Date: Mon, 8 Jun 2026 13:19:09 +0100 Subject: [PATCH 1/4] fix: `PlayerActions.__len__ ` iterates actions instead of infosets --- src/pygambit/player.pxi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From 54e902450130e0298abf6e584dfedbdffa091ee5 Mon Sep 17 00:00:00 2001 From: drdkad Date: Mon, 8 Jun 2026 13:20:19 +0100 Subject: [PATCH 2/4] add a test comparing `__len__` to `len(list(player.actions))` --- tests/test_actions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_actions.py b/tests/test_actions.py index 28989e33e..ecbdbf514 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -251,3 +251,10 @@ 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: + from_iter = len(list(player.actions)) + assert len(player.actions) == from_iter From b07a43b9c03e3bdceff637be731ee6642d3bd80b Mon Sep 17 00:00:00 2001 From: drdkad Date: Mon, 8 Jun 2026 13:30:04 +0100 Subject: [PATCH 3/4] polish the test --- tests/test_actions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_actions.py b/tests/test_actions.py index ecbdbf514..5c5c64863 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -256,5 +256,4 @@ def test_strategy_action_raises_error_for_strategic_game(): def test_player_actions_len(): game = games.create_stripped_down_poker_efg() for player in game.players: - from_iter = len(list(player.actions)) - assert len(player.actions) == from_iter + assert len(player.actions) == len(list(player.actions)) From bccff3324e62fa133dbf7100ba1f32cdaf419899 Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Tue, 16 Jun 2026 08:39:08 +0100 Subject: [PATCH 4/4] Added ChangeLog entry --- ChangeLog | 1 + 1 file changed, 1 insertion(+) 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