-
Notifications
You must be signed in to change notification settings - Fork 159
Issue 522 #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Issue 522 #524
Changes from all commits
980ebfb
55dca4a
16714f0
efda6c3
87cf05c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,7 @@ Information about the game | |
Action.precedes | ||
Action.prob | ||
Action.plays | ||
Action.power | ||
|
||
.. autosummary:: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,9 +109,18 @@ class Action: | |
|
||
@property | ||
def plays(self) -> typing.List[Node]: | ||
"""Returns a list of all terminal `Node` objects consistent with it. | ||
"""Returns a list of all terminal `Node` objects consistent with the action. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simpler is just to say 'terminal nodes' rather than 'terminal Node objects' |
||
""" | ||
return [ | ||
Node.wrap(n) for n in | ||
self.action.deref().GetInfoset().deref().GetGame().deref().GetPlays(self.action) | ||
] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docstring has not been updated. It would be useful to write a brief explanation of what the 'veto' of an action is here - a few lines so the documentation is self-contained |
||
@property | ||
def veto(self) -> typing.List[Node]: | ||
"""Returns power of the action. | ||
""" | ||
return [ | ||
Node.wrap(n) for n in | ||
self.action.deref().GetInfoset().deref().GetGame().deref().GetVeto(self.action) | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,3 +143,18 @@ def test_action_plays(): | |
} # paths=[0, 1, 0], [0, 1] | ||
|
||
assert set(test_action.plays) == expected_set_of_plays | ||
|
||
|
||
def test_action_veto(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This explanation would be better put in the docstring of veto rather than in the tests. |
||
"""Verify `action.veto` returns the action's veto | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be useful to have a few test fixtures rather than a single test (see other examples throughout the test suite for setting up fixtures). In particular think about potential edge cases - e.g. actions at the root node, actions at singleton information sets versus nontrivial information sets, so on. |
||
(terminal `Node` objects contained in the information set associated with this action | ||
that cannot be reached from this action). | ||
""" | ||
game = games.read_from_file("e01.efg") | ||
list_infosets = list(game.infosets) | ||
|
||
test_action = list_infosets[2].actions[0] # members' paths=[0, 1, 0], [0, 1] | ||
|
||
expected_set_of_plays = set(list_infosets[2].plays) - set(test_action.plays) | ||
|
||
assert set(test_action.veto) == expected_set_of_plays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
Action.veto