Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions tests/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,20 @@ def create_mixed_behav_game_efg() -> gbt.Game:
return read_from_file("mixed_behavior_game.efg")


def create_1_card_poker_efg() -> gbt.Game:
def create_stripped_down_poker_efg() -> gbt.Game:
"""
Returns
-------
Game
One-card two-player poker game, as used in the user guide
"""
return read_from_file("poker.efg")

Stripped-Down Poker: A Classroom Game with Signaling and Bluffing
Reiley et al (2008)

def create_myerson_2_card_poker_efg() -> gbt.Game:
"""
Returns
-------
Game
Simplied "stripped down" version of Myerson 2-card poker:
Two-player extensive poker game with a chance move with two moves,
then player 1 can raise or fold; after raising player 2 is in an infoset with two nodes
and can choose to meet or pass
Two-player extensive-form poker game between Fred and Alice
Chance deals King or Queen to Fred
Fred can then Bet or Fold; after raising Alice is in an infoset with two nodes
and can choose to Call or Fold
"""
return read_from_file("myerson_2_card_poker.efg")
return read_from_file("stripped_down_poker.efg")


def create_kuhn_poker_efg() -> gbt.Game:
Expand Down
28 changes: 14 additions & 14 deletions tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@pytest.mark.parametrize(
"game,label",
[(games.create_myerson_2_card_poker_efg(), "random label")]
[(games.create_stripped_down_poker_efg(), "random label")]
)
def test_set_action_label(game: gbt.Game, label: str):
game.root.infoset.actions[0].label = label
Expand All @@ -16,9 +16,9 @@ def test_set_action_label(game: gbt.Game, label: str):

@pytest.mark.parametrize(
"game,inprobs,outprobs",
[(games.create_myerson_2_card_poker_efg(),
[(games.create_stripped_down_poker_efg(),
[0.75, 0.25], [0.75, 0.25]),
(games.create_myerson_2_card_poker_efg(),
(games.create_stripped_down_poker_efg(),
["16/17", "1/17"], [gbt.Rational("16/17"), gbt.Rational("1/17")])]
)
def test_set_chance_valid_probability(game: gbt.Game, inprobs: list, outprobs: list):
Expand All @@ -29,9 +29,9 @@ def test_set_chance_valid_probability(game: gbt.Game, inprobs: list, outprobs: l

@pytest.mark.parametrize(
"game,inprobs",
[(games.create_myerson_2_card_poker_efg(), [0.75, -0.10]),
(games.create_myerson_2_card_poker_efg(), [0.75, 0.40]),
(games.create_myerson_2_card_poker_efg(), ["foo", "bar"])]
[(games.create_stripped_down_poker_efg(), [0.75, -0.10]),
(games.create_stripped_down_poker_efg(), [0.75, 0.40]),
(games.create_stripped_down_poker_efg(), ["foo", "bar"])]
)
def test_set_chance_improper_probability(game: gbt.Game, inprobs: list):
with pytest.raises(ValueError):
Expand All @@ -40,8 +40,8 @@ def test_set_chance_improper_probability(game: gbt.Game, inprobs: list):

@pytest.mark.parametrize(
"game,inprobs",
[(games.create_myerson_2_card_poker_efg(), [0.25, 0.75, 0.25]),
(games.create_myerson_2_card_poker_efg(), [1.00])]
[(games.create_stripped_down_poker_efg(), [0.25, 0.75, 0.25]),
(games.create_stripped_down_poker_efg(), [1.00])]
)
def test_set_chance_bad_dimension(game: gbt.Game, inprobs: list):
with pytest.raises(IndexError):
Expand All @@ -50,7 +50,7 @@ def test_set_chance_bad_dimension(game: gbt.Game, inprobs: list):

@pytest.mark.parametrize(
"game",
[games.create_myerson_2_card_poker_efg()]
[games.create_stripped_down_poker_efg()]
)
def test_set_chance_personal(game: gbt.Game):
with pytest.raises(gbt.UndefinedOperationError):
Expand All @@ -59,7 +59,7 @@ def test_set_chance_personal(game: gbt.Game):

@pytest.mark.parametrize(
"game",
[games.create_myerson_2_card_poker_efg()]
[games.create_stripped_down_poker_efg()]
)
def test_action_precedes(game: gbt.Game):
child = game.root.children[0]
Expand All @@ -69,7 +69,7 @@ def test_action_precedes(game: gbt.Game):

@pytest.mark.parametrize(
"game",
[games.create_myerson_2_card_poker_efg()]
[games.create_stripped_down_poker_efg()]
)
def test_action_precedes_nonnode(game: gbt.Game):
with pytest.raises(TypeError):
Expand All @@ -78,7 +78,7 @@ def test_action_precedes_nonnode(game: gbt.Game):

@pytest.mark.parametrize(
"game",
[games.create_myerson_2_card_poker_efg()]
[games.create_stripped_down_poker_efg()]
)
def test_action_delete_personal(game: gbt.Game):
node = game.players[0].infosets[0].members[0]
Expand All @@ -90,7 +90,7 @@ def test_action_delete_personal(game: gbt.Game):

@pytest.mark.parametrize(
"game",
[games.create_myerson_2_card_poker_efg()]
[games.create_stripped_down_poker_efg()]
)
def test_action_delete_last(game: gbt.Game):
node = game.players[0].infosets[0].members[0]
Expand All @@ -103,7 +103,7 @@ def test_action_delete_last(game: gbt.Game):
@pytest.mark.parametrize(
"game",
[games.read_from_file("chance_root_3_moves_only_one_nonzero_prob.efg"),
games.create_myerson_2_card_poker_efg(),
games.create_stripped_down_poker_efg(),
games.read_from_file("chance_root_5_moves_no_nonterm_player_nodes.efg")]
)
def test_action_delete_chance(game: gbt.Game):
Expand Down
Loading
Loading