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
32 changes: 20 additions & 12 deletions tests/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create_coord_4x4_nfg(outcome_version: bool = False) -> gbt.Game:
# Extensive-form games (efg)


def create_2x2_zero_sum_efg(missing_term_outcome=False) -> gbt.Game:
def create_2x2_zero_sum_efg(missing_term_outcome: bool = False) -> gbt.Game:
"""
EFG corresponding to 2x2 zero-sum game (I,-I).
If missing_term_outcome, the terminal node after "T" then "r" does not have an outcome.
Expand All @@ -123,7 +123,7 @@ def create_2x2_zero_sum_efg(missing_term_outcome=False) -> gbt.Game:
return g


def create_matching_pennies_efg(with_neutral_outcome=False) -> gbt.Game:
def create_matching_pennies_efg(with_neutral_outcome: bool = False) -> gbt.Game:
"""
The version with_neutral_outcome adds a (0,0) payoff outcomes at a non-terminal node.
"""
Expand Down Expand Up @@ -156,7 +156,7 @@ def create_mixed_behav_game_efg() -> gbt.Game:
return read_from_file("mixed_behavior_game.efg")


def create_stripped_down_poker_efg(nonterm_outcomes=False) -> gbt.Game:
def create_stripped_down_poker_efg(nonterm_outcomes: bool = False) -> gbt.Game:
"""
Returns
-------
Expand Down Expand Up @@ -404,7 +404,7 @@ def get_path(node):
return g


def create_kuhn_poker_efg(nonterm_outcomes=False) -> gbt.Game:
def create_kuhn_poker_efg(nonterm_outcomes: bool = False) -> gbt.Game:
"""
Returns
-------
Expand Down Expand Up @@ -458,12 +458,15 @@ def kuhn_poker_lcp_first_mixed_strategy_prof():
return [alice, bob]


def create_one_shot_trust_efg() -> gbt.Game:
def create_one_shot_trust_efg(unique_NE_variant: bool = False) -> gbt.Game:
"""
Returns
-------
Game
One-shot trust game, after Kreps (1990)
One-shot trust game, after Kreps (1990)

The unique_NE_variant makes Trust a dominant strategy, replacing the
non-singleton equilibrium component from the standard version of the game
where the Buyer plays "Not Trust" and the seller can play any mixture with
< 0.5 probability on Honor with a unique NE where the Buyer plays Trust and
the Seller plays Abuse.
"""
g = gbt.Game.new_tree(
players=["Buyer", "Seller"], title="One-shot trust game, after Kreps (1990)"
Expand All @@ -473,9 +476,14 @@ def create_one_shot_trust_efg() -> gbt.Game:
g.set_outcome(
g.root.children[0].children[0], g.add_outcome([1, 1], label="Trustworthy")
)
g.set_outcome(
g.root.children[0].children[1], g.add_outcome([-1, 2], label="Untrustworthy")
)
if unique_NE_variant:
g.set_outcome(
g.root.children[0].children[1], g.add_outcome(["1/2", 2], label="Untrustworthy")
)
else:
g.set_outcome(
g.root.children[0].children[1], g.add_outcome([-1, 2], label="Untrustworthy")
)
g.set_outcome(g.root.children[1], g.add_outcome([0, 0], label="Opt-out"))
return g

Expand Down
17 changes: 13 additions & 4 deletions tests/test_nash.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,20 @@ def test_enummixed_rational(game: gbt.Game, mixed_strategy_prof_data: list):
None,
),
# 2-player non-zero-sum games
(
pytest.param(
games.create_one_shot_trust_efg(),
[[[[0, 1]], [["1/2", "1/2"]]], [[[0, 1]], [[0, 0]]]],
2,
), # Note all zero probs at iset
[[[[0, 1]], [["1/2", "1/2"]]], [[[0, 1]], [[0, 1]]]],
# second entry assumes we extend to Nash using only pure behaviors
# currently we get [[0, 1]], [[0, 0]]] as a second eq
None,
marks=pytest.mark.xfail(reason="Problem with enumpoly, as per issue #660")
),
pytest.param(
games.create_one_shot_trust_efg(unique_NE_variant=True),
[[[[1, 0]], [[0, 1]]]], # currently we get [[0, 1]], [[0, 0]]] as a second eq
None,
marks=pytest.mark.xfail(reason="Problem with enumpoly, as per issue #660")
),
(
games.create_EFG_for_nxn_bimatrix_coordination_game(3),
[
Expand Down
Loading