Skip to content

Commit b66d630

Browse files
authored
Add version of one-shot trust game with dominant action
1 parent 788ed67 commit b66d630

2 files changed

Lines changed: 33 additions & 16 deletions

File tree

tests/games.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def create_coord_4x4_nfg(outcome_version: bool = False) -> gbt.Game:
100100
# Extensive-form games (efg)
101101

102102

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

125125

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

158158

159-
def create_stripped_down_poker_efg(nonterm_outcomes=False) -> gbt.Game:
159+
def create_stripped_down_poker_efg(nonterm_outcomes: bool = False) -> gbt.Game:
160160
"""
161161
Returns
162162
-------
@@ -404,7 +404,7 @@ def get_path(node):
404404
return g
405405

406406

407-
def create_kuhn_poker_efg(nonterm_outcomes=False) -> gbt.Game:
407+
def create_kuhn_poker_efg(nonterm_outcomes: bool = False) -> gbt.Game:
408408
"""
409409
Returns
410410
-------
@@ -458,12 +458,15 @@ def kuhn_poker_lcp_first_mixed_strategy_prof():
458458
return [alice, bob]
459459

460460

461-
def create_one_shot_trust_efg() -> gbt.Game:
461+
def create_one_shot_trust_efg(unique_NE_variant: bool = False) -> gbt.Game:
462462
"""
463-
Returns
464-
-------
465-
Game
466-
One-shot trust game, after Kreps (1990)
463+
One-shot trust game, after Kreps (1990)
464+
465+
The unique_NE_variant makes Trust a dominant strategy, replacing the
466+
non-singleton equilibrium component from the standard version of the game
467+
where the Buyer plays "Not Trust" and the seller can play any mixture with
468+
< 0.5 probability on Honor with a unique NE where the Buyer plays Trust and
469+
the Seller plays Abuse.
467470
"""
468471
g = gbt.Game.new_tree(
469472
players=["Buyer", "Seller"], title="One-shot trust game, after Kreps (1990)"
@@ -473,9 +476,14 @@ def create_one_shot_trust_efg() -> gbt.Game:
473476
g.set_outcome(
474477
g.root.children[0].children[0], g.add_outcome([1, 1], label="Trustworthy")
475478
)
476-
g.set_outcome(
477-
g.root.children[0].children[1], g.add_outcome([-1, 2], label="Untrustworthy")
478-
)
479+
if unique_NE_variant:
480+
g.set_outcome(
481+
g.root.children[0].children[1], g.add_outcome(["1/2", 2], label="Untrustworthy")
482+
)
483+
else:
484+
g.set_outcome(
485+
g.root.children[0].children[1], g.add_outcome([-1, 2], label="Untrustworthy")
486+
)
479487
g.set_outcome(g.root.children[1], g.add_outcome([0, 0], label="Opt-out"))
480488
return g
481489

tests/test_nash.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,20 @@ def test_enummixed_rational(game: gbt.Game, mixed_strategy_prof_data: list):
9595
None,
9696
),
9797
# 2-player non-zero-sum games
98-
(
98+
pytest.param(
9999
games.create_one_shot_trust_efg(),
100-
[[[[0, 1]], [["1/2", "1/2"]]], [[[0, 1]], [[0, 0]]]],
101-
2,
102-
), # Note all zero probs at iset
100+
[[[[0, 1]], [["1/2", "1/2"]]], [[[0, 1]], [[0, 1]]]],
101+
# second entry assumes we extend to Nash using only pure behaviors
102+
# currently we get [[0, 1]], [[0, 0]]] as a second eq
103+
None,
104+
marks=pytest.mark.xfail(reason="Problem with enumpoly, as per issue #660")
105+
),
106+
pytest.param(
107+
games.create_one_shot_trust_efg(unique_NE_variant=True),
108+
[[[[1, 0]], [[0, 1]]]], # currently we get [[0, 1]], [[0, 0]]] as a second eq
109+
None,
110+
marks=pytest.mark.xfail(reason="Problem with enumpoly, as per issue #660")
111+
),
103112
(
104113
games.create_EFG_for_nxn_bimatrix_coordination_game(3),
105114
[

0 commit comments

Comments
 (0)