File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -228,15 +228,34 @@ class Player:
228228 previously , information sets were (expensively ) re-sorted after every change
229229 to the game tree.
230230
231+ Raises
232+ ------
233+ UndefinedOperationError
234+ If the game does not have a tree representation.
235+
231236 See also
232237 --------
233238 Game.sort_infosets
234239 """
240+ if not self.game.is_tree:
241+ raise UndefinedOperationError(
242+ "Operation only defined for games with a tree representation"
243+ )
235244 return PlayerInfosets.wrap(self.player )
236245
237246 @property
238247 def actions(self ) -> PlayerActions:
239- """Returns the set of actions available to the player at some information set."""
248+ """Returns the set of actions available to the player at some information set.
249+
250+ Raises
251+ ------
252+ UndefinedOperationError
253+ If the game does not have a tree representation.
254+ """
255+ if not self.game.is_tree:
256+ raise UndefinedOperationError(
257+ "Operation only defined for games with a tree representation"
258+ )
240259 return PlayerActions.wrap(self )
241260
242261 @property
Original file line number Diff line number Diff line change @@ -11,12 +11,24 @@ def test_strategic_game_actions():
1111 _ = game .actions
1212
1313
14+ def test_strategic_game_player_actions ():
15+ game = gbt .Game .new_table ([2 , 2 ])
16+ with pytest .raises (gbt .UndefinedOperationError ):
17+ _ = game .players [0 ].actions
18+
19+
1420def test_strategic_game_infosets ():
1521 game = gbt .Game .new_table ([2 , 2 ])
1622 with pytest .raises (gbt .UndefinedOperationError ):
1723 _ = game .infosets
1824
1925
26+ def test_strategic_game_player_infosets ():
27+ game = gbt .Game .new_table ([2 , 2 ])
28+ with pytest .raises (gbt .UndefinedOperationError ):
29+ _ = game .players [0 ].infosets
30+
31+
2032def test_strategic_game_root ():
2133 game = gbt .Game .new_table ([2 , 2 ])
2234 with pytest .raises (gbt .UndefinedOperationError ):
You can’t perform that action at this time.
0 commit comments