Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
156083b
Draft structure of organising test cases as dataclasses, using subtests.
tturocy Dec 23, 2025
549b2e6
Suggestion for writing a generic Nash tester.
tturocy Dec 23, 2025
fc4ccf0
removed create_2x2x2_nfg from games.py
rahulsavani Jan 14, 2026
fa70567
removed create_coord_4x4_nfg from games.py
rahulsavani Jan 14, 2026
543c937
removed create_2x2_zero_nfg from games.py
rahulsavani Jan 14, 2026
c8f1752
removed create_STOC_simplified{,2} from games.py (which were not used…
rahulsavani Jan 14, 2026
6887099
added new .nfg files
rahulsavani Jan 14, 2026
00b28c3
removed create_seq_form_STOC_paper_zero_sum_2_player_efg from games.py
rahulsavani Jan 14, 2026
2cfa8a1
removed create_problem_example_efg from games.py
rahulsavani Jan 14, 2026
f2a8039
removed create_chance_in_middle_efg from games.py
rahulsavani Jan 14, 2026
e0f16fb
chance_in_middle efgs
rahulsavani Jan 14, 2026
39332ac
removed create_two_player_perfect_info_win_lose_efg from games.py
rahulsavani Jan 14, 2026
47b6500
removed create_reduction_both_players_payoff_ties_efg from games.py
rahulsavani Jan 14, 2026
255afa4
removed create_3_player_with_internal_outcomes_efg and create_large_p…
rahulsavani Jan 14, 2026
f8c32f4
removed create_reduction_one_player_generic_payoffs_efg from games.py
rahulsavani Jan 14, 2026
ce73a36
removed create_reduction_generic_payoffs_efg from games.py
rahulsavani Jan 14, 2026
9307709
removed create_perfect_info_with_chance_efg from games.py
rahulsavani Jan 14, 2026
78e3375
removed create_entry_accomodation_efg from games.py
rahulsavani Jan 14, 2026
22fafa7
removed create_non_zero_sum_lacking_outcome_efg from games.py
rahulsavani Jan 14, 2026
e275daf
create_matching_pennies_efg uses create_efg_corresponding_to_bimatrix…
rahulsavani Jan 14, 2026
25b42cd
removed temp to_efg call
rahulsavani Jan 14, 2026
02d1d86
removed create_mixed_behav_game_efg from games.py
rahulsavani Jan 14, 2026
0e5aabd
create_2x2_zero_sum_efg uses create_efg_corresponding_to_bimatrix_game
rahulsavani Jan 14, 2026
9548e67
removed create_selten_horse_game_efg from games.py
rahulsavani Jan 14, 2026
cdb6201
removed create_el_farol_bar_game_efg and create_centipede_game_with_c…
rahulsavani Jan 14, 2026
2394420
comment in create_one_shot_trust_efg, which could be removed in due c…
rahulsavani Jan 14, 2026
7018a16
Merge branch 'master' into dev_testfixtures
rahulsavani Jan 26, 2026
90742ee
Merge remote-tracking branch 'origin/maint_clean_up_tests_games_py' i…
rahulsavani Jan 26, 2026
60fe1c4
enumpure strategy/agent tests using test_nash_{stategy,agent}_solver …
rahulsavani Jan 27, 2026
0ce8538
enumpoly tests using test_nash_{strategy,agent}_solver respectively
rahulsavani Jan 28, 2026
6d07a37
xfail tests for issue 660 now separates from passing tests
rahulsavani Jan 29, 2026
4e20c6b
test_enumpoly_ordered_behavior removed
rahulsavani Feb 5, 2026
8b84d0f
test_enumpoly_unordered_behavior removed
rahulsavani Feb 5, 2026
dc66cce
test_nash_behavior_solver wip
rahulsavani Feb 11, 2026
e1dfe80
test_nash_behavior_solver wip
rahulsavani Feb 11, 2026
1735cb5
LP_STRATEGY_RATIONAL_CASES for test_nash_strategy_solver
rahulsavani Feb 12, 2026
d54dbf1
LCP_BEHAVIOR_RATIONAL_CASES for test_nash_behavior_solver
rahulsavani Feb 12, 2026
92a2599
removed create_matching_pennies_efg; using create_2x2_zero_sum_efg in…
rahulsavani Feb 12, 2026
7d741e5
LCP_STRATEGY_RATIONAL_CASES for test_nash_strategy_solver
rahulsavani Feb 12, 2026
02fe6a5
minor reorder
rahulsavani Feb 12, 2026
b7a8cfc
enumpoly now correctly under behavior test
rahulsavani Feb 13, 2026
01a0642
test expected output in test_liap_agent
rahulsavani Feb 13, 2026
b29e42d
logit,ipa,gnm strategy tests using test_nash_strategy_solver
rahulsavani Feb 13, 2026
2444b5a
lp,lcp,enummixed double cases (mirroring all rational cases)
rahulsavani Feb 13, 2026
1b18acf
lp,lcp behvior double cases (mirroring all rational cases)
rahulsavani Feb 13, 2026
aa761a5
logit_behavior tests + ids for all new tests
rahulsavani Feb 13, 2026
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
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ markers = [
"nash_lcp_behavior: tests of lcp_solve in mixed behaviors",
"nash_lp_strategy: tests of lp_solve in mixed strategies",
"nash_lp_behavior: tests of lp_solve in mixed behaviors",
"nash_logit_strategy: tests of logit_solve in mixed strategies",
"nash_logit_behavior: tests of logit_solve in behavior strategies",
"nash_gnm_strategy: tests of gnm_solve in mixed strategies",
"nash_ipa_strategy: tests of lpa_solve in mixed strategies",
"nash: all tests of Nash equilibrium solvers",
"slow: all time-consuming tests",
]
Expand Down
792 changes: 56 additions & 736 deletions tests/games.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pytest
pytest-subtests
nbformat
nbclient
ipykernel
2,464 changes: 1,602 additions & 862 deletions tests/test_behav.py

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions tests/test_extensive.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_outcome_index_exception_label():
###############################################################################
# 1 player; reduction; generic payoffs
(
games.create_reduction_one_player_generic_payoffs_efg(),
games.read_from_file("reduction_one_player_generic_payoffs.efg"),
[["11", "12", "2*", "3*", "4*"]],
[np.array(range(1, 6))],
),
Expand Down Expand Up @@ -162,13 +162,13 @@ def test_outcome_index_exception_label():
[np.array([[1, 0], [0, 1]]), np.array([[-1, 0], [0, -1]])]
),
(
games.create_2x2_zero_sum_efg(missing_term_outcome=True),
games.create_2x2_zero_sum_efg(variant="missing term outcome"),
[["1", "2"], ["1", "2"]],
[np.array([[1, 0], [0, 1]]), np.array([[-1, 0], [0, -1]])]
),
# 2-player (zero-sum) game; reduction for both players; generic payoffs
(
games.create_reduction_generic_payoffs_efg(),
games.read_from_file("reduction_generic_payoffs.efg"),
[
["1*1", "1*2", "211", "212", "221", "222"],
["11*", "12*", "2**", "3*1", "3*2", "4**"],
Expand Down Expand Up @@ -210,7 +210,7 @@ def test_outcome_index_exception_label():
),
# # 2-player game from GTE survey; reduction for both players; payoff ties
(
games.create_reduction_both_players_payoff_ties_efg(),
games.read_from_file("reduction_both_players_payoff_ties_GTE_survey.efg"),
[
["1*", "2*", "31", "32", "4*"],
[
Expand Down Expand Up @@ -401,28 +401,28 @@ def test_reduced_strategic_form(
"standard,modified",
[
(
games.create_two_player_perfect_info_win_lose_efg(),
games.create_two_player_perfect_info_win_lose_efg(nonterm_outcomes=True)
games.read_from_file("two_player_perfect_info_win_lose.efg"),
games.read_from_file("two_player_perfect_info_win_lose_with_nonterm_outcomes.efg")
),
(
games.create_3_player_with_internal_outcomes_efg(),
games.create_3_player_with_internal_outcomes_efg(nonterm_outcomes=True)
games.read_from_file("3_player.efg"),
games.read_from_file("3_player_with_nonterm_outcomes.efg")
),
(
games.create_chance_in_middle_efg(),
games.create_chance_in_middle_efg(nonterm_outcomes=True)
games.read_from_file("chance_in_middle.efg"),
games.read_from_file("chance_in_middle_with_nonterm_outcomes.efg")
),
(
games.create_non_zero_sum_lacking_outcome_efg(),
games.create_non_zero_sum_lacking_outcome_efg(missing_term_outcome=True)
games.read_from_file("2_player_non_zero_sum.efg"),
games.read_from_file("2_player_non_zero_sum_missing_term_outcome.efg"),
),
(
games.create_entry_accomodation_efg(),
games.create_entry_accomodation_efg(nonterm_outcomes=True)
games.read_from_file("entry_accommodation.efg"),
games.read_from_file("entry_accommodation_with_nonterm_outcomes.efg")
),
(
games.create_three_action_internal_outcomes_efg(),
games.create_three_action_internal_outcomes_efg(nonterm_outcomes=True)
games.read_from_file("2_player_chance.efg"),
games.read_from_file("2_player_chance_nonterm_outcomes_and_missing_term_outcomes.efg"),
),
(
games.create_kuhn_poker_efg(),
Expand All @@ -434,11 +434,11 @@ def test_reduced_strategic_form(
),
(
games.create_2x2_zero_sum_efg(),
games.create_2x2_zero_sum_efg(missing_term_outcome=True)
games.create_2x2_zero_sum_efg(variant="missing term outcome"),
),
(
games.create_matching_pennies_efg(),
games.create_matching_pennies_efg(with_neutral_outcome=True)
games.create_2x2_zero_sum_efg(),
games.create_2x2_zero_sum_efg(variant="with nonterm outcome"),
),
],
)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_games/2_player_chance.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
EFG 2 R "" { "1" "2" }
""

c "" 1 "" { "H" 1/2 "L" 1/2 } 0
p "" 1 1 "" { "A" "B" "C" } 0
p "" 2 1 "" { "X" "Y" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 2 2 "" { "X" "Y" } 0
t "" 2 "-1" { -1, 1 }
t "" 1 "1" { 1, -1 }
p "" 2 3 "" { "X" "Y" } 0
t "" 1 "1" { 1, -1 }
t "" 5 "0" { 0, 0 }
p "" 1 2 "" { "A" "B" "C" } 0
p "" 2 1 "" { "X" "Y" } 0
t "" 5 "0" { 0, 0 }
t "" 1 "1" { 1, -1 }
p "" 2 2 "" { "X" "Y" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 2 3 "" { "X" "Y" } 0
t "" 2 "-1" { -1, 1 }
t "" 1 "1" { 1, -1 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
EFG 2 R "" { "1" "2" }
""

c "" 1 "" { "H" 1/2 "L" 1/2 } 0
p "" 1 1 "" { "A" "B" "C" } 0
p "" 2 1 "" { "X" "Y" } 1 "1" { 1, -1 }
t "" 0
t "" 4 "-2" { -2, 2 }
p "" 2 2 "" { "X" "Y" } 0
t "" 2 "-1" { -1, 1 }
t "" 1 "1" { 1, -1 }
p "" 2 3 "" { "X" "Y" } 0
t "" 1 "1" { 1, -1 }
t "" 0
p "" 1 2 "" { "A" "B" "C" } 0
p "" 2 1 "" { "X" "Y" } 0
t "" 0
t "" 1 "1" { 1, -1 }
p "" 2 2 "" { "X" "Y" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 2 3 "" { "X" "Y" } 2 "-1" { -1, 1 }
t "" 0
t "" 3 "2" { 2, -2 }
18 changes: 18 additions & 0 deletions tests/test_games/2_player_non_zero_sum.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
EFG 2 R "Non constant-sum game lacking outcome" { "1" "2" }
""

c "" 1 "" { "H" 1/2 "T" 1/2 } 0
p "" 1 1 "" { "A" "B" } 0
p "" 2 1 "" { "X" "Y" } 0
t "" 1 "" { 2, 1 }
t "" 2 "" { -1, 2 }
p "" 2 1 "" { "X" "Y" } 0
t "" 3 "" { 1, -1 }
t "" 4 "" { 0, 0 }
p "" 1 1 "" { "A" "B" } 0
p "" 2 1 "" { "X" "Y" } 0
t "" 5 "" { 1, 0 }
t "" 6 "" { 0, 1 }
p "" 2 1 "" { "X" "Y" } 0
t "" 7 "" { -1, 1 }
t "" 8 "" { 2, -1 }
18 changes: 18 additions & 0 deletions tests/test_games/2_player_non_zero_sum_missing_term_outcome.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
EFG 2 R "Non constant-sum game lacking outcome" { "1" "2" }
""

c "" 1 "" { "H" 1/2 "T" 1/2 } 0
p "" 1 1 "" { "A" "B" } 0
p "" 2 1 "" { "X" "Y" } 0
t "" 1 "" { 2, 1 }
t "" 2 "" { -1, 2 }
p "" 2 1 "" { "X" "Y" } 0
t "" 3 "" { 1, -1 }
t "" 0
p "" 1 1 "" { "A" "B" } 0
p "" 2 1 "" { "X" "Y" } 0
t "" 4 "" { 1, 0 }
t "" 5 "" { 0, 1 }
p "" 2 1 "" { "X" "Y" } 0
t "" 6 "" { -1, 1 }
t "" 7 "" { 2, -1 }
14 changes: 14 additions & 0 deletions tests/test_games/2x2_bimatrix_all_zero_payoffs.nfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
NFG 1 R "2x2 bimatrix game with all zero payoffs, with strategy labels" { "Joe" "Dan" }

{ { "cooperate" "defect" }
{ "defect" "defect" }
}
""

{
{ "" 0, 0 }
{ "" 0, 0 }
{ "" 0, 0 }
{ "" 0, 0 }
}
1 2 3 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
NFG 1 R "2x2x2 game with 2 pure and 1 mixed equilibrium"
{ "Player 1" "Player 2" "Player 3" } { 2 2 2 }
"
- This comes from a local max cut instance:
players {1,2,3} are nodes; edge weight{1,2} = 2; weight{1,3} = -1; weight{2,3} = 2
- Pure strategies {a,b} encode if respective player is on left or right of the cut
- The payoff to a player is the sum of their incident edges across the implied cut
- Pure equilibrium iff local max cuts; in addition, uniform mixture is an equilibrium
- Equilibrium analysis for pure profiles:
a a a: 0 0 0 -- Not Nash (regrets: 1, 4, 1)
b a a: 1 2 -1 -- Not Nash (regrets: 0, 0, 3)
a b a: 2 4 2 -- Nash (global max cut)
b b a: -1 2 1 -- Not Nash (regrets: 3, 0, 0)
a a b: -1 2 1 -- Not Nash (regrets: 3, 0, 0)
b a b: 2 4 2 -- Nash (global max cut)
a b b: 1 2 -1 -- Not Nash (regrets: 0, 0, 3)
b b b: 0 0 0 -- Not Nash (regrets: 1, 4, 1)
"

0 0 0 1 2 -1 2 4 2 -1 2 1 -1 2 1 2 4 2 1 2 -1 0 0 0
4 changes: 0 additions & 4 deletions tests/test_games/2x2x2_nfg_with_two_pure_one_mixed_eq.nfg

This file was deleted.

24 changes: 24 additions & 0 deletions tests/test_games/3_player.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
EFG 2 R "3 player game" { "1" "2" "3" }
""

c "" 1 "" { "H" 1/2 "T" 1/2 } 0
p "" 1 1 "" { "a" "b" } 0
p "" 2 1 "" { "A" "B" } 0
p "" 3 2 "" { "Y" "Z" } 0
t "" 1 "" { 3, 1, 4 }
t "" 2 "" { 4, 0, 1 }
p "" 3 2 "" { "Y" "Z" } 0
t "" 10 "" { 0, 0, 0 }
t "" 10 "" { 0, 0, 0 }
p "" 3 1 "" { "W" "X" } 0
t "" 3 "" { 1, 3, 2 }
p "" 2 2 "" { "C" "D" } 0
t "" 4 "" { 2, 4, 1 }
t "" 5 "" { 4, 1, 3 }
p "" 1 2 "" { "c" "d" } 0
p "" 2 1 "" { "A" "B" } 0
t "" 6 "" { 2, 2, 4 }
t "" 7 "" { 3, 1, 1 }
p "" 3 1 "" { "W" "X" } 0
t "" 8 "" { 0, 4, 2 }
t "" 9 "" { 1, 2, 3 }
24 changes: 24 additions & 0 deletions tests/test_games/3_player_with_nonterm_outcomes.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
EFG 2 R "3 player game" { "1" "2" "3" }
""

c "" 1 "" { "H" 1/2 "T" 1/2 } 0
p "" 1 1 "" { "a" "b" } 0
p "" 2 1 "" { "A" "B" } 0
p "" 3 2 "" { "Y" "Z" } 0
t "" 1 "" { 3, 1, 4 }
t "" 2 "" { 4, 0, 1 }
p "" 3 2 "" { "Y" "Z" } 0
t "" 0
t "" 0
p "" 3 1 "" { "W" "X" } 0
t "" 3 "" { 1, 3, 2 }
p "" 2 2 "" { "C" "D" } 0
t "" 4 "" { 2, 4, 1 }
t "" 5 "" { 4, 1, 3 }
p "" 1 2 "" { "c" "d" } 6 "" { 1, 2, 3 }
p "" 2 1 "" { "A" "B" } 0
t "" 7 "" { 1, 0, 1 }
t "" 8 "" { 2, -1, -2 }
p "" 3 1 "" { "W" "X" } 0
t "" 9 "" { -1, 2, -1 }
t "" 0
34 changes: 34 additions & 0 deletions tests/test_games/chance_in_middle.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
EFG 2 R "Chance in middle game" { "1" "2" }
""

p "" 1 1 "" { "A" "B" } 0
c "" 1 "" { "H" 1/5 "L" 4/5 } 0
p "" 2 1 "" { "X" "Y" } 0
p "" 1 2 "" { "C" "D" } 0
t "" 6 "0" { 0, 0 }
t "" 3 "-2" { -2, 2 }
p "" 1 3 "" { "C" "D" } 0
t "" 5 "-0.5" { -1/2, 1/2 }
t "" 7 "-1.5" { -3/2, 3/2 }
p "" 2 2 "" { "X" "Y" } 0
p "" 1 2 "" { "C" "D" } 0
t "" 4 "0.5" { 1/2, -1/2 }
t "" 5 "-0.5" { -1/2, 1/2 }
p "" 1 3 "" { "C" "D" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
c "" 2 "" { "H" 7/10 "L" 3/10 } 0
p "" 2 1 "" { "X" "Y" } 0
p "" 1 4 "" { "C" "D" } 0
t "" 4 "0.5" { 1/2, -1/2 }
t "" 5 "-0.5" { -1/2, 1/2 }
p "" 1 5 "" { "C" "D" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 2 2 "" { "X" "Y" } 0
p "" 1 4 "" { "C" "D" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 1 5 "" { "C" "D" } 0
t "" 4 "0.5" { 1/2, -1/2 }
t "" 5 "-0.5" { -1/2, 1/2 }
34 changes: 34 additions & 0 deletions tests/test_games/chance_in_middle_with_nonterm_outcomes.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
EFG 2 R "Chance in middle game" { "1" "2" }
""

p "" 1 1 "" { "A" "B" } 0
c "" 1 "" { "H" 1/5 "L" 4/5 } 0
p "" 2 1 "" { "X" "Y" } 8 "a" { -1, 1 }
p "" 1 2 "" { "C" "D" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 1 3 "" { "C" "D" } 0
t "" 4 "0.5" { 1/2, -1/2 }
t "" 5 "-0.5" { -1/2, 1/2 }
p "" 2 2 "" { "X" "Y" } 0
p "" 1 2 "" { "C" "D" } 0
t "" 4 "0.5" { 1/2, -1/2 }
t "" 5 "-0.5" { -1/2, 1/2 }
p "" 1 3 "" { "C" "D" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
c "" 2 "" { "H" 7/10 "L" 3/10 } 0
p "" 2 1 "" { "X" "Y" } 0
p "" 1 4 "" { "C" "D" } 0
t "" 4 "0.5" { 1/2, -1/2 }
t "" 5 "-0.5" { -1/2, 1/2 }
p "" 1 5 "" { "C" "D" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 2 2 "" { "X" "Y" } 0
p "" 1 4 "" { "C" "D" } 0
t "" 1 "1" { 1, -1 }
t "" 2 "-1" { -1, 1 }
p "" 1 5 "" { "C" "D" } 0
t "" 4 "0.5" { 1/2, -1/2 }
t "" 5 "-0.5" { -1/2, 1/2 }
14 changes: 14 additions & 0 deletions tests/test_games/entry_accommodation.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
EFG 2 R "Entry-accomodation game" { "1" "2" }
""

p "" 1 1 "" { "S" "T" } 0
p "" 2 1 "" { "E" "O" } 0
p "" 1 2 "" { "A" "F" } 0
t "" 1 "" { 3, 2 }
t "" 2 "" { 0, 1 }
t "" 3 "" { 1, 3 }
p "" 2 1 "" { "E" "O" } 0
p "" 1 3 "" { "A" "F" } 0
t "" 4 "" { 2, 3 }
t "" 5 "" { 1, 0 }
t "" 6 "" { 3, 1 }
14 changes: 14 additions & 0 deletions tests/test_games/entry_accommodation_with_nonterm_outcomes.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
EFG 2 R "Entry-accomodation game" { "1" "2" }
""

p "" 1 1 "" { "S" "T" } 0
p "" 2 1 "" { "E" "O" } 1 "" { 3, 2 }
p "" 1 2 "" { "A" "F" } 0
t "" 0
t "" 2 "" { -3, -1 }
t "" 3 "" { -2, 1 }
p "" 2 1 "" { "E" "O" } 0
p "" 1 3 "" { "A" "F" } 0
t "" 4 "" { 2, 3 }
t "" 5 "" { 1, 0 }
t "" 6 "" { 3, 1 }
Loading
Loading