|
17 | 17 | TOL = 1e-13 # tolerance for floating point assertions |
18 | 18 |
|
19 | 19 |
|
| 20 | +def kuhn_poker_lcp_mixed_strategy_prof(): |
| 21 | + alice = [0] * 27 |
| 22 | + alice[1] = "2/3" |
| 23 | + alice[4] = "1/3" |
| 24 | + bob = [0] * 64 |
| 25 | + bob[12] = "2/3" |
| 26 | + bob[30] = "1/3" |
| 27 | + return [alice, bob] |
| 28 | + |
| 29 | + |
20 | 30 | def test_enumpure_strategy(): |
21 | 31 | """Test calls of enumeration of pure strategies.""" |
22 | 32 | game = games.read_from_file("poker.efg") |
@@ -143,19 +153,28 @@ def test_lcp_strategy_double(): |
143 | 153 |
|
144 | 154 | @pytest.mark.nash |
145 | 155 | @pytest.mark.nash_lcp_strategy |
146 | | -def test_lcp_strategy_rational(): |
| 156 | +@pytest.mark.parametrize( |
| 157 | + "game,mixed_strategy_prof_data,stop_after", |
| 158 | + [ |
| 159 | + # Zero-sum games |
| 160 | + # (games.create_1_card_poker_efg(), [["1/3", "2/3", 0, 0], ["2/3", "1/3"]]), |
| 161 | + # (games.create_myerson_2_card_poker_efg(), [["1/3", "2/3", 0, 0], ["2/3", "1/3"]]), |
| 162 | + # (games.create_kuhn_poker_efg(), kuhn_poker_lcp_mixed_strategy_prof()) |
| 163 | + (games.create_EFG_for_nxn_bimatrix_coordination_game(3), [[[1, 0, 0], [1, 0, 0]]], 1), |
| 164 | + # Non-zero-sum games |
| 165 | + ] |
| 166 | +) |
| 167 | +def test_lcp_strategy_rational(game: gbt.Game, mixed_strategy_prof_data: list, |
| 168 | + stop_after: typing.Union[None, int]): |
147 | 169 | """Test calls of LCP for mixed strategy equilibria, rational precision.""" |
148 | | - game = games.read_from_file("poker.efg") |
149 | | - result = gbt.nash.lcp_solve(game, use_strategic=True, rational=True) |
| 170 | + result = gbt.nash.lcp_solve(game, use_strategic=True, rational=True, stop_after=stop_after) |
| 171 | + print(result.equilibria) |
150 | 172 | assert len(result.equilibria) == 1 |
151 | | - expected = game.mixed_strategy_profile( |
152 | | - rational=True, |
153 | | - data=[ |
154 | | - [gbt.Rational(1, 3), gbt.Rational(2, 3), gbt.Rational(0), gbt.Rational(0)], |
155 | | - [gbt.Rational(2, 3), gbt.Rational(1, 3)], |
156 | | - ], |
157 | | - ) |
158 | | - assert result.equilibria[0] == expected |
| 173 | + eq = result.equilibria[0] |
| 174 | + assert eq.max_regret() == 0 |
| 175 | + print(eq) |
| 176 | + expected = game.mixed_strategy_profile(rational=True, data=mixed_strategy_prof_data[0]) |
| 177 | + assert eq == expected |
159 | 178 |
|
160 | 179 |
|
161 | 180 | def test_lcp_behavior_double(): |
|
0 commit comments