Skip to content

Commit f3606ac

Browse files
committed
extended tests for RSF-algorithm
1 parent 7813a60 commit f3606ac

4 files changed

Lines changed: 191 additions & 20 deletions

File tree

tests/test_extensive.py

Lines changed: 129 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,30 @@ def test_game_add_players_nolabel():
6868
(games.BinEfgThreePlayer.get_test_data(level=3)[0], True),
6969
7070
# Games with imperfect recall from files (game_input is a string)
71+
#
7172
# - imperfect recall without absent-mindedness
72-
("wichardt.efg", False), # forgetting past action; Wichardt (GEB, 2008)
73-
("noPR-action-selten-horse.efg", False), # forgetting past action
74-
("noPR-information-no-deflate.efg", False), # forgetting past information
75-
("gilboa_two_am_agents.efg", False), # forgetting past information; Gilboa (GEB, 1997)
73+
# Wichardt (GEB, 2008): 2 players; Player 1 in Infoset 1:2 forgets past action
74+
("wichardt.efg", False),
75+
# variation of the Selten's Horse (1975): Player 1 in Infoset 1:2 forgets past action
76+
("noPR-action-selten-horse.efg", False),
77+
# deflate-stable game (cf. Thompson); Player 2 in Infoset 2:2 forgets past information
78+
("noPR-information-no-deflate.efg", False),
79+
# Gilboa (GEB, 1997) 2 players; agents of Player 1 forget past information
80+
("gilboa-two-am-agents-deterministic.efg", False),
81+
#
7682
# - imperfect recall with absent-mindedness
77-
("noPR-AM-driver-one-player.efg", False), # 1 players, one infoset unreached
78-
("noPR-AM-driver-two-players.efg", False), # 2 players, one infoset unreached
79-
("noPR-action-AM.efg", False), # 2 players + forgetting past action; P1 has one infoset
80-
("noPR-action-AM2.efg", False), # 2 players + forgetting past action; P1 has >1 infoset
81-
("noPR-action-AM-two-hops.efg", False), # 2 players, one AM-infoset each
83+
# Classic AM-driver game: Player 2 does not move, but gets payoffs assigned
84+
("noPR-AM-driver-one-player.efg", False),
85+
# forgetting past action; Player 1 in Infoset 1:1 has AM; unreachable: Infosets 2:2, 2:3
86+
("noPR-action-AM.efg", False),
87+
# forgetting past action; Player 1 in Infoset 1:1 has AM; unreachable: Infosets 1:3, 2:1
88+
("noPR-action-AM2.efg", False),
89+
# Player 1 in Infoset 1:1 has AM; unreachable: Infosets 1:3, 2:2, 2:3, 2:4, 2:5
90+
("noPR-action-big-AM.efg", False),
91+
# one AM-infoset each, unreachable: Infoset 2:2
92+
("noPR-action-AM-two-hops.efg", False),
93+
# one AM-infoset each, unreachable: Infosets 1:2, 2:2, Node 7 in Infoset 1:1
94+
("noPR-action-AM-two-hops-unreached.efg", False),
8295
8396
# Games with imperfect recall from generated games (game_input is a gbt.Game object)
8497
# - One-player binary tree games
@@ -364,16 +377,113 @@ def test_outcome_index_exception_label():
364377
(games.BinEfgOnePlayerIR.get_test_data(level=5)),
365378
(games.BinEfgOnePlayerIR.get_test_data(level=6)),
366379
#
367-
# I M P E R F E C T R E C A L L --- commented out in the test suite
368-
# Wichardt (2008): binary tree of height 3; 2 players; the root player forgets the action
369-
# (
370-
# games.read_from_file("wichardt.efg"),
371-
# [["11", "12", "21", "22"], ["1", "2"]],
372-
# [
373-
# np.array([[1, -1], [-5, -5], [-5, -5], [-1, 1]]),
374-
# np.array([[-1, 1], [5, 5], [5, 5], [1, -1]]),
375-
# ],
376-
# ),
380+
# I M P E R F E C T R E C A L L --- no absent-mindedness
381+
# Wichardt (2008)
382+
(
383+
games.read_from_file("wichardt.efg"),
384+
[["11", "12", "21", "22"], ["1", "2"]],
385+
[
386+
np.array([[1, -1], [-5, -5], [-5, -5], [-1, 1]]),
387+
np.array([[-1, 1], [5, 5], [5, 5], [1, -1]]),
388+
],
389+
),
390+
# variation of the Selten's Horse (1975): 2 players
391+
(
392+
games.read_from_file("noPR-action-selten-horse.efg"),
393+
[["11", "12", "21", "22"], ["1", "2"]],
394+
[
395+
np.array([[1, 4], [1, 0], [3, 3], [0, 0]]),
396+
np.array([[1, 4], [1, 0], [2, 2], [0, 0]]),
397+
],
398+
),
399+
# deflate-stable game
400+
(
401+
games.read_from_file("noPR-information-no-deflate.efg"),
402+
[["1", "2", "3"], ["11", "12", "21", "22"]],
403+
[
404+
np.array([[8, 8, 7, 7], [0, 0, 4, 3], [2, 1, 2, 1]]),
405+
np.array([[-8, -8, -7, -7], [0, 0, -4, -3], [-2, -1, -2, -1]]),
406+
],
407+
),
408+
# Gilboa (1997)
409+
(
410+
games.read_from_file("gilboa-two-am-agents-deterministic.efg"),
411+
[["11", "12", "21", "22"], ["1", "2"]],
412+
[
413+
np.array([[1, 4], [1, 6], [2, 5], [3, 6]]),
414+
np.array([[-1, -4], [-1, -6], [-2, -5], [-3, -6]]),
415+
],
416+
),
417+
#
418+
# A B S E N T M I N D E D N E S S
419+
# AM-driver ---- NB: the legacy algorithm works well, pytest.mark.xfail is thus not added
420+
(
421+
games.read_from_file("noPR-AM-driver-one-player.efg"),
422+
[["11*", "12*", "2**"], ["*"]],
423+
[
424+
np.array([[1], [3], [4]]),
425+
np.array([[-1], [-3], [-4]]),
426+
],
427+
),
428+
pytest.param(
429+
games.read_from_file("noPR-action-AM.efg"),
430+
[["1", "2"], ["1**1", "1**2", "2**1", "2**2"]],
431+
[
432+
np.array([[1, 1, 2, 2], [7, 8, 7, 8]]),
433+
np.array([[-1, -1, -2, -2], [-7, -8, -7, -8]]),
434+
],
435+
marks=pytest.mark.xfail
436+
),
437+
pytest.param(
438+
games.read_from_file("noPR-action-AM2.efg"),
439+
[["11*", "12*", "2**"], ["*1", "*2"]],
440+
[
441+
np.array([[1, 1], [2, 2], [7, 8]]),
442+
np.array([[-1, -1], [-2, -2], [-7, -8]]),
443+
],
444+
marks=pytest.mark.xfail
445+
),
446+
pytest.param(
447+
games.read_from_file("noPR-action-big-AM.efg"),
448+
[["1***", "21**", "22*1", "22*2"], ["1****1", "1****2", "2****1", "2****2"]],
449+
[
450+
np.array(
451+
[
452+
[1, 1, 2, 2],
453+
[17, 17, 17, 17],
454+
[18, 19, 18, 19],
455+
[18, 20, 18, 20]
456+
]
457+
),
458+
np.array(
459+
[
460+
[-1, -1, -2, -2],
461+
[-17, -17, -17, -17],
462+
[-18, -19, -18, -19],
463+
[-18, -20, -18, -20]
464+
]
465+
),
466+
],
467+
marks=pytest.mark.xfail
468+
),
469+
pytest.param(
470+
games.read_from_file("noPR-action-AM-two-hops.efg"),
471+
[["11", "12", "2*"], ["1*", "2*"]],
472+
[
473+
np.array([[1, 0], [10, 0], [2, 2]]),
474+
np.array([[1, 3], [-10, 3], [0, 0]]),
475+
],
476+
marks=pytest.mark.xfail
477+
),
478+
pytest.param(
479+
games.read_from_file("noPR-action-AM-two-hops-unreached.efg"),
480+
[["1*", "2*"], ["1*", "2*"]],
481+
[
482+
np.array([[1, 0], [2, 2]]),
483+
np.array([[1, 3], [0, 0]]),
484+
],
485+
marks=pytest.mark.xfail
486+
),
377487
],
378488
)
379489
def test_reduced_strategic_form(

tests/test_games/gilboa_two_am_agents.efg renamed to tests/test_games/gilboa-two-am-agents-deterministic.efg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
EFG 2 R "Untitled Extensive Game" { "Player 1" "Player 2" }
22
""
33

4-
c "" 1 "" { "1" 1/2 "2" 1/2 } 0
4+
p "" 2 1 "" { "1" "2" } 0
55
p "" 1 1 "" { "1" "2" } 0
66
t "" 1 "Outcome 1" { 1, -1 }
77
p "" 1 2 "" { "1" "2" } 0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
EFG 2 R "Untitled Extensive Game" { "Player 1" "Player 2" }
2+
""
3+
4+
p "" 1 1 "" { "1" "2" } 0
5+
p "" 2 1 "" { "1" "2" } 0
6+
p "" 1 1 "" { "1" "2" } 0
7+
p "" 2 1 "" { "1" "2" } 0
8+
t "" 1 "Outcome 1" { 1, 1 }
9+
p "" 1 2 "" { "1" "2" } 0
10+
p "" 1 1 "" { "1" "2" } 0
11+
t "" 7 "Outcome 7" { 7, -7 }
12+
t "" 8 "Outcome 8" { 8, -8 }
13+
t "" 9 "Outcome 9" { 9, -9 }
14+
p "" 2 2 "" { "1" "2" "3" } 0
15+
t "" 2 "Outcome 2" { 0, 2 }
16+
t "" 3 "Outcome 5" { 0, 5 }
17+
t "" 4 "Outcome 6" { 0, 6 }
18+
t "" 5 "Outcome 3" { 0, 3 }
19+
t "" 6 "Outcome 4" { 2, 0 }
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
EFG 2 R "Untitled Extensive Game" { "Player 1" "Player 2" }
2+
""
3+
4+
p "" 1 1 "" { "1" "2" } 0
5+
p "" 1 1 "" { "1" "2" } 0
6+
p "" 1 1 "" { "1" "2" } 0
7+
p "" 2 1 "" { "1" "2" } 0
8+
t "" 1 "Outcome 1" { 1, -1 }
9+
t "" 2 "Outcome 2" { 2, -2 }
10+
p "" 2 2 "" { "1" "2" } 0
11+
t "" 3 "Outcome 3" { 3, -3 }
12+
t "" 4 "Outcome 4" { 4, -4 }
13+
p "" 1 1 "" { "1" "2" } 0
14+
p "" 2 3 "" { "1" "2" } 0
15+
t "" 5 "Outcome 5" { 5, -5 }
16+
t "" 6 "Outcome 6" { 6, -6 }
17+
p "" 2 3 "" { "1" "2" } 0
18+
t "" 7 "Outcome 7" { 7, -7 }
19+
t "" 8 "Outcome 8" { 8, -8 }
20+
p "" 1 1 "" { "1" "2" } 0
21+
p "" 1 1 "" { "1" "2" } 0
22+
p "" 2 4 "" { "1" "2" } 0
23+
t "" 9 "Outcome 9" { 9, -9 }
24+
t "" 10 "Outcome 10" { 10, -10 }
25+
p "" 2 4 "" { "1" "2" } 0
26+
t "" 11 "Outcome 11" { 11, -11 }
27+
t "" 12 "Outcome 12" { 12, -12 }
28+
p "" 1 1 "" { "1" "2" } 0
29+
p "" 1 2 "" { "1" "2" } 0
30+
p "" 1 3 "" { "1" "2" } 0
31+
t "" 13 "Outcome 13" { 13, -13 }
32+
t "" 14 "Outcome 14" { 14, -14 }
33+
p "" 2 5 "" { "1" "2" } 0
34+
t "" 15 "Outcome 15" { 15, -15 }
35+
t "" 16 "Outcome 16" { 16, -16 }
36+
p "" 1 2 "" { "1" "2" } 0
37+
t "" 17 "Outcome 17" { 17, -17 }
38+
p "" 2 6 "" { "1" "2" } 0
39+
t "" 18 "Outcome 18" { 18, -18 }
40+
p "" 1 4 "" { "1" "2" } 0
41+
t "" 19 "Outcome 19" { 19, -19 }
42+
t "" 20 "Outcome 20" { 20, -20 }

0 commit comments

Comments
 (0)