Skip to content

Commit dcad462

Browse files
committed
Added two simple games with chance nodes: nature playing first and last
1 parent 2ee6965 commit dcad462

3 files changed

Lines changed: 64 additions & 9 deletions

File tree

tests/test_games/nature-leaves.efg

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
EFG 2 R "2 player game: chance plays last" { "Player 1" "Player 2" }
2+
""
3+
4+
p "" 1 1 "" { "B" "T" } 0
5+
p "" 2 1 "" { "r" "l" } 0
6+
c "" 1 "" { "1" 1/2 "2" 1/2 } 0
7+
t "" 1 "Outcome 1" { 0, 0 }
8+
t "" 2 "Outcome 2" { -2, -2 }
9+
c "" 2 "" { "1" 1/2 "2" 1/2 } 0
10+
t "" 3 "Outcome 3" { 3, 3 }
11+
t "" 4 "Outcome 4" { 1, 1 }
12+
p "" 2 2 "" { "R" "L" } 0
13+
c "" 3 "" { "1" 1/2 "2" 1/2 } 0
14+
t "" 5 "Outcome 5" { 0, 4 }
15+
t "" 6 "Outcome 6" { 0, 2 }
16+
c "" 4 "" { "1" 1/2 "2" 1/2 } 0
17+
t "" 7 "Outcome 7" { 0, 5 }
18+
t "" 8 "Outcome 8" { 0, 3 }

tests/test_games/nature-rooted.efg

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
EFG 2 R "2 player game: chance plays at the root" { "Player 1" "Player 2" }
2+
""
3+
4+
c "" 1 "" { "1" 1/2 "2" 1/2 } 0
5+
p "" 1 1 "" { "B" "T" } 0
6+
p "" 2 2 "" { "r" "l" } 0
7+
t "" 1 "Outcome 1" { 0, 0 }
8+
t "" 2 "Outcome 2" { 3, 3 }
9+
p "" 2 1 "" { "R" "L" } 0
10+
t "" 3 "Outcome 3" { 0, 4 }
11+
t "" 4 "Outcome 4" { 0, 5 }
12+
p "" 1 1 "" { "B" "T" } 0
13+
p "" 2 2 "" { "r" "l" } 0
14+
t "" 5 "Outcome 5" { -2, -2 }
15+
t "" 6 "Outcome 6" { 1, 1 }
16+
p "" 2 1 "" { "R" "L" } 0
17+
t "" 7 "Outcome 7" { 0, 2 }
18+
t "" 8 "Outcome 8" { 0, 3 }

tests/test_rsf.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@
4444
np.array([[[1, 1], [0, 1]], [[2, 0], [2, 0]]]),
4545
],
4646
),
47-
# Myerson 2-card poker; game with chance node
48-
(
49-
games.read_from_file("myerson_2_card_poker.efg"), # CHANGE
50-
[["11", "12", "21", "22"], ["1", "2"]],
51-
[
52-
np.array([[-1, 0], ["-1/2", -1], ["-5/2", -1], [-2, -2]]),
53-
np.array([[1, 0], ["1/2", 1], ["5/2", 1], [2, 2]]),
54-
],
55-
),
5647
# 2-player (zero-sum) game with reduction for both players and generic payoffs
5748
(
5849
games.create_reduction_generic_payoffs_efg(),
@@ -136,6 +127,34 @@
136127
),
137128
],
138129
),
130+
# N A T U R E
131+
# Myerson 2-card poker; game with chance playing at the root
132+
(
133+
games.read_from_file("myerson_2_card_poker.efg"), # CHANGE
134+
[["11", "12", "21", "22"], ["1", "2"]],
135+
[
136+
np.array([[-1, 0], ["-1/2", -1], ["-5/2", -1], [-2, -2]]),
137+
np.array([[1, 0], ["1/2", 1], ["5/2", 1], [2, 2]]),
138+
],
139+
),
140+
# Nature playing at the root
141+
(
142+
games.read_from_file("nature-rooted.efg"),
143+
[["1", "2"], ["11", "12", "21", "22"]],
144+
[
145+
np.array([[-1, -1, 2, 2], [0, 0, 0, 0]]),
146+
np.array([[-1, -1, 2, 2], [3, 4, 3, 4]]),
147+
],
148+
),
149+
# Nature playing last determining the payoffs
150+
(
151+
games.read_from_file("nature-leaves.efg"),
152+
[["1", "2"], ["11", "12", "21", "22"]],
153+
[
154+
np.array([[-1, -1, 2, 2], [0, 0, 0, 0]]),
155+
np.array([[-1, -1, 2, 2], [3, 4, 3, 4]]),
156+
],
157+
),
139158
],
140159
)
141160
def test_reduced_strategic_form(

0 commit comments

Comments
 (0)