Skip to content

Commit 00da58d

Browse files
committed
test_regrets_tmp
1 parent c03048c commit 00da58d

File tree

3 files changed

+85
-15
lines changed

3 files changed

+85
-15
lines changed

tests/games.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def create_3_player_with_internal_outcomes_efg(nonterm_outcomes: bool = False) -
352352
o = g.add_outcome([0, 0, 0])
353353
g.set_outcome(g.root.children[0].children[0].children[1].children[0], o)
354354
g.set_outcome(g.root.children[0].children[0].children[1].children[1], o)
355+
g.to_efg(f"TEST_{nonterm_outcomes}.efg")
355356
return g
356357

357358

tests/test_behav.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,8 @@ def test_infoset_regret_consistency(game: gbt.Game, rational_flag: bool):
843843
(games.create_stripped_down_poker_efg(), True),
844844
(games.create_kuhn_poker_efg(), False),
845845
(games.create_kuhn_poker_efg(), True),
846+
(games.create_3_player_with_internal_outcomes_efg(), False),
847+
(games.create_3_player_with_internal_outcomes_efg(), True)
846848
]
847849
)
848850
def test_max_regret_consistency(game: gbt.Game, rational_flag: bool):

tests/test_nash.py

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -894,27 +894,94 @@ def test_logit_solve_lambda():
894894

895895
def test_regrets_tmp():
896896

897+
prof_data_doub = []
898+
prof_data_doub.append([[[1, 0], [1, 0]], [[1, 0], [0.5, 0.5]], [[1, 0], [0, 1]]])
899+
# prof_data_doub.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [[1, 0], [0.33333, 0.6666]]])
900+
# prof_data_doub.append([[[1, 0], [1, 0]], [[1, 0], [0.5, 0.5]], [[0, 1], [1, 0]]])
901+
# prof_data_doub.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [[0.33333, 0.6666], [1, 0]]])
902+
903+
prof_data_rat = []
904+
prof_data_rat.append([[[1, 0], [1, 0]], [[1, 0], ["1/2", "1/2"]], [[1, 0], [0, 1]]])
905+
# prof_data_rat.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [[1, 0], ["1/3", "2/3"]]])
906+
# prof_data_rat.append([[[1, 0], [1, 0]], [[1, 0], ["1/2", "1/2"]], [[0, 1], [1, 0]]])
907+
# prof_data_rat.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [["1/3", "2/3"], [1, 0]]])
908+
897909
g = games.create_3_player_with_internal_outcomes_efg()
898-
prof_data = []
899-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], [0.5, 0.5]], [[1, 0], [0, 1]]])
900-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [[1, 0], [0.33333, 0.6666]]])
901-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], [0.5, 0.5]], [[0, 1], [1, 0]]])
902-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [[0.33333, 0.6666], [1, 0]]])
910+
911+
print()
903912
print("==================")
904-
for p in prof_data:
913+
for p in prof_data_doub:
905914
prof = g.mixed_behavior_profile(rational=False, data=p)
906-
# print(prof)
907915
print(prof.max_regret())
908916
print(prof.agent_max_regret())
909-
910917
print("==================")
911-
prof_data = []
912-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], ["1/2", "1/2"]], [[1, 0], [0, 1]]])
913-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [[1, 0], ["1/3", "2/3"]]])
914-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], ["1/2", "1/2"]], [[0, 1], [1, 0]]])
915-
prof_data.append([[[1, 0], [1, 0]], [[1, 0], [0, 1]], [["1/3", "2/3"], [1, 0]]])
916-
for p in prof_data:
918+
for p in prof_data_rat:
917919
prof = g.mixed_behavior_profile(rational=True, data=p)
918-
# print(prof)
919920
print(prof.max_regret())
920921
print(prof.agent_max_regret())
922+
print("==================")
923+
for p in prof_data_doub:
924+
prof = g.mixed_behavior_profile(rational=False, data=p)
925+
print(prof.max_regret())
926+
print(prof.agent_max_regret())
927+
928+
929+
def test_regrets_tmp2():
930+
931+
g = games.create_3_player_with_internal_outcomes_efg()
932+
933+
prof_data_rat = [[[1, 0], [1, 0]], [[1, 0], ["1/2", "1/2"]], [[1, 0], [0, 1]]]
934+
profile_rat = g.mixed_behavior_profile(rational=True, data=prof_data_rat)
935+
print()
936+
print(profile_rat.max_regret()) # 3/2
937+
# print(profile1.max_regret()) # same
938+
profile_rat = g.mixed_behavior_profile(rational=True, data=prof_data_rat)
939+
print(profile_rat.max_regret()) # now different! 0
940+
print("=======================================")
941+
942+
prof_data_doub = [[[1, 0], [1, 0]], [[1, 0], [0.5, 0.5]], [[1, 0], [0, 1]]]
943+
profile_doub = g.mixed_behavior_profile(rational=False, data=prof_data_doub)
944+
print()
945+
print(profile_doub.max_regret())
946+
# print(profile1.max_regret()) # same
947+
profile_doub = g.mixed_behavior_profile(rational=False, data=prof_data_doub)
948+
print(profile_doub.max_regret())
949+
print("=======================================")
950+
951+
prof_data_rat = [[[1, 0], [1, 0]], [[1, 0], ["1/2", "1/2"]], [[1, 0], [0, 1]]]
952+
profile_rat = g.mixed_behavior_profile(rational=True, data=prof_data_rat)
953+
print()
954+
print(profile_rat.max_regret())
955+
# print(profile1.max_regret()) # same
956+
profile_rat = g.mixed_behavior_profile(rational=True, data=prof_data_rat)
957+
print(profile_rat.max_regret())
958+
print("=======================================")
959+
960+
961+
def test_regrets_tmp3():
962+
963+
g = games.create_3_player_with_internal_outcomes_efg()
964+
965+
prof_data_doub = [[[1, 0], [1, 0]], [[1, 0], [0.5, 0.5]], [[1, 0], [0, 1]]]
966+
profile_doub = g.mixed_behavior_profile(rational=False, data=prof_data_doub)
967+
print()
968+
print(profile_doub.max_regret()) # 1.5
969+
profile_doub = g.mixed_behavior_profile(rational=False, data=prof_data_doub)
970+
print(profile_doub.max_regret()) # now different! 0
971+
print("=======================================")
972+
973+
prof_data_rat = [[[1, 0], [1, 0]], [[1, 0], ["1/2", "1/2"]], [[1, 0], [0, 1]]]
974+
profile_rat = g.mixed_behavior_profile(rational=True, data=prof_data_rat)
975+
print()
976+
print(profile_rat.max_regret())
977+
profile_rat = g.mixed_behavior_profile(rational=True, data=prof_data_rat)
978+
print(profile_rat.max_regret())
979+
print("=======================================")
980+
981+
prof_data_doub = [[[1, 0], [1, 0]], [[1, 0], [0.5, 0.5]], [[1, 0], [0, 1]]]
982+
profile_doub = g.mixed_behavior_profile(rational=False, data=prof_data_doub)
983+
print()
984+
print(profile_doub.max_regret())
985+
profile_doub = g.mixed_behavior_profile(rational=False, data=prof_data_doub)
986+
print(profile_doub.max_regret())
987+
print("=======================================")

0 commit comments

Comments
 (0)