Skip to content

[Bug]: UndefinedOperationError not thrown for game.Player.actions on non-tree game #696

@rahulsavani

Description

@rahulsavani

Where did you find this bug?

PyGambit

What operating system are you using?

macOS

What version of Gambit are you using?

16.4.0

What happened?

If one has a non-tree game g and does g.actions we throw a UndefinedOperationError.

It seems logical to throw the same error if one calls actions for a player in this game, but instead we just return a empty set of PlayerActions, as in the following:

In [1]: import pygambit as gbt

In [2]: g = gbt.read_nfg('tests/test_games/2x2x2_nfg_with_two_pure_one_mixed_eq.nfg')

In [3]: g.actions
---------------------------------------------------------------------------
UndefinedOperationError                   Traceback (most recent call last)
Cell In[3], line 1
----> 1 g.actions

File ~/gambit/src/pygambit/game.pxi:701, in pygambit.gambit.Game.actions.__get__()
    699 """
    700 if not self.is_tree:
--> 701     raise UndefinedOperationError(
    702         "Operation only defined for games with a tree representation"
    703     )

UndefinedOperationError: Operation only defined for games with a tree representation

In [4]: g.players[0].actions
Out[4]: PlayerActions(player=Player(game=Game(title='2x2x2 game with 2 pure and 1 mixed equilibrium'), label='Player 1'))

In [5]: len(g.players[0].actions)
Out[5]: 0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions