@@ -798,9 +798,11 @@ def test_action_value_by_label_reference(game: gbt.Game, label: str,
798798 (games .create_mixed_behav_game_efg (), True ),
799799 (games .create_stripped_down_poker_efg (), False ),
800800 (games .create_stripped_down_poker_efg (), True ),
801+ (games .create_kuhn_poker_efg (), False ),
802+ (games .create_kuhn_poker_efg (), True ),
801803 ]
802804)
803- def test_regret_consistency (game : gbt .Game , rational_flag : bool ):
805+ def test_action_regret_consistency (game : gbt .Game , rational_flag : bool ):
804806 profile = game .mixed_behavior_profile (rational = rational_flag )
805807 for player in game .players :
806808 for infoset in player .infosets :
@@ -812,6 +814,60 @@ def test_regret_consistency(game: gbt.Game, rational_flag: bool):
812814 )
813815
814816
817+ @pytest .mark .parametrize (
818+ "game,rational_flag" ,
819+ [(games .create_mixed_behav_game_efg (), False ),
820+ (games .create_mixed_behav_game_efg (), True ),
821+ (games .create_stripped_down_poker_efg (), False ),
822+ (games .create_stripped_down_poker_efg (), True ),
823+ (games .create_kuhn_poker_efg (), False ),
824+ (games .create_kuhn_poker_efg (), True ),
825+ ]
826+ )
827+ def test_infoset_regret_consistency (game : gbt .Game , rational_flag : bool ):
828+ profile = game .mixed_behavior_profile (rational = rational_flag )
829+ for player in game .players :
830+ for infoset in player .infosets :
831+ assert (
832+ profile .infoset_regret (infoset ) ==
833+ max (profile .action_value (a ) for a in infoset .actions ) -
834+ profile .infoset_value (infoset )
835+ )
836+
837+
838+ @pytest .mark .parametrize (
839+ "game,rational_flag" ,
840+ [(games .create_mixed_behav_game_efg (), False ),
841+ (games .create_mixed_behav_game_efg (), True ),
842+ (games .create_stripped_down_poker_efg (), False ),
843+ (games .create_stripped_down_poker_efg (), True ),
844+ (games .create_kuhn_poker_efg (), False ),
845+ (games .create_kuhn_poker_efg (), True ),
846+ ]
847+ )
848+ def test_max_regret_consistency (game : gbt .Game , rational_flag : bool ):
849+ profile = game .mixed_behavior_profile (rational = rational_flag )
850+ assert profile .max_regret () == profile .as_strategy ().max_regret ()
851+
852+
853+ @pytest .mark .parametrize (
854+ "game,rational_flag" ,
855+ [(games .create_mixed_behav_game_efg (), False ),
856+ (games .create_mixed_behav_game_efg (), True ),
857+ (games .create_stripped_down_poker_efg (), False ),
858+ (games .create_stripped_down_poker_efg (), True ),
859+ (games .create_kuhn_poker_efg (), False ),
860+ (games .create_kuhn_poker_efg (), True ),
861+ ]
862+ )
863+ def test_agent_max_regret_consistency (game : gbt .Game , rational_flag : bool ):
864+ profile = game .mixed_behavior_profile (rational = rational_flag )
865+ assert (
866+ profile .agent_max_regret () ==
867+ max ([profile .infoset_regret (infoset ) for infoset in game .infosets ])
868+ )
869+
870+
815871@pytest .mark .parametrize (
816872 "game,player_idx,infoset_idx,action_idx,action_probs,rational_flag,tol,value" ,
817873 [
@@ -823,14 +879,14 @@ def test_regret_consistency(game: gbt.Game, rational_flag: bool):
823879 (games .create_mixed_behav_game_efg (), 2 , 0 , 0 , None , False , TOL , 0 ),
824880 (games .create_mixed_behav_game_efg (), 2 , 0 , 1 , None , False , TOL , 0.5 ), # 3.5 - 3
825881 # U1 U2 U3
826- (games .create_mixed_behav_game_efg (), 0 , 0 , 0 , [1.0 , 0.0 , 1.0 , 0.0 , 1.0 , 0. 0 ], False , TOL , 0 ),
827- (games .create_mixed_behav_game_efg (), 0 , 0 , 0 , ["1" , "0" , "1" , "0" , "1" , "0" ], True , ZERO , 0 ),
828- (games .create_mixed_behav_game_efg (), 0 , 0 , 1 , [1.0 , 0.0 , 1.0 , 0.0 , 1.0 , 0. 0 ], False , TOL , 9 ),
829- (games .create_mixed_behav_game_efg (), 0 , 0 , 1 , ["1" , "0" , "1" , "0" , "1" , "0" ], True , ZERO , 9 ),
830- (games .create_mixed_behav_game_efg (), 1 , 0 , 0 , [1.0 , 0.0 , 1.0 , 0.0 , 1.0 , 0. 0 ], False , TOL , 0 ),
831- (games .create_mixed_behav_game_efg (), 1 , 0 , 0 , ["1" , "0" , "1" , "0" , "1" , "0" ], True , ZERO , 0 ),
832- (games .create_mixed_behav_game_efg (), 1 , 0 , 1 , [1.0 , 0.0 , 1.0 , 0.0 , 1.0 , 0. 0 ], False , TOL , 8 ),
833- (games .create_mixed_behav_game_efg (), 1 , 0 , 1 , ["1" , "0" , "1" , "0" , "1" , "0" ], True , ZERO , 8 ),
882+ (games .create_mixed_behav_game_efg (), 0 , 0 , 0 , [1 , 0 , 1 , 0 , 1 , 0 ], False , TOL , 0 ),
883+ (games .create_mixed_behav_game_efg (), 0 , 0 , 0 , [1 , 0 , 1 , 0 , 1 , 0 ], True , ZERO , 0 ),
884+ (games .create_mixed_behav_game_efg (), 0 , 0 , 1 , [1 , 0 , 1 , 0 , 1 , 0 ], False , TOL , 9 ),
885+ (games .create_mixed_behav_game_efg (), 0 , 0 , 1 , [1 , 0 , 1 , 0 , 1 , 0 ], True , ZERO , 9 ),
886+ (games .create_mixed_behav_game_efg (), 1 , 0 , 0 , [1 , 0 , 1 , 0 , 1 , 0 ], False , TOL , 0 ),
887+ (games .create_mixed_behav_game_efg (), 1 , 0 , 0 , [1 , 0 , 1 , 0 , 1 , 0 ], True , ZERO , 0 ),
888+ (games .create_mixed_behav_game_efg (), 1 , 0 , 1 , [1 , 0 , 1 , 0 , 1 , 0 ], False , TOL , 8 ),
889+ (games .create_mixed_behav_game_efg (), 1 , 0 , 1 , [1 , 0 , 1 , 0 , 1 , 0 ], True , ZERO , 8 ),
834890 # Mixed Nash equilibrium
835891 (games .create_mixed_behav_game_efg (), 0 , 0 , 0 , ["2/5" , "3/5" , "1/2" , "1/2" , "1/3" , "2/3" ],
836892 True , ZERO , 0 ),
@@ -858,9 +914,9 @@ def test_regret_consistency(game: gbt.Game, rational_flag: bool):
858914 True , ZERO , "8/3" ), # (2/3*2 + 1/3*1) - (-1)
859915 ]
860916)
861- def test_regret_reference (game : gbt .Game , player_idx : int , infoset_idx : int , action_idx : int ,
862- action_probs : None | list , rational_flag : bool ,
863- tol : gbt .Rational | float , value : str | float ):
917+ def test_action_regret_reference (game : gbt .Game , player_idx : int , infoset_idx : int ,
918+ action_idx : int , action_probs : None | list , rational_flag : bool ,
919+ tol : gbt .Rational | float , value : str | float ):
864920 action = game .players [player_idx ].infosets [infoset_idx ].actions [action_idx ]
865921 profile = game .mixed_behavior_profile (rational = rational_flag )
866922 if action_probs :
@@ -955,6 +1011,41 @@ def test_agent_liap_value_reference(game: gbt.Game, action_probs: None | list,
9551011 )
9561012
9571013
1014+ @pytest .mark .parametrize (
1015+ "game,action_probs,rational_flag,max_regret,agent_max_regret,liap_value,agent_liap_value" ,
1016+ [
1017+ # uniform (non-Nash):
1018+ (games .create_mixed_behav_game_efg (), None , True , "1/4" , "1/4" , "1/16" , "1/16" ),
1019+ (games .create_mixed_behav_game_efg (), None , False , 0.25 , 0.25 , 0.0625 , 0.0625 ),
1020+ # Myerson fig 2.4
1021+ pytest .param (
1022+ games .read_from_file ("myerson_fig_4_2.efg" ), [0 , 1 , 0 , 1 , 1 , 0 ], True , 1 , 0 , 1 , 0 ,
1023+ marks = pytest .mark .xfail (reason = "Needs to be fixed now" )
1024+ ),
1025+ ]
1026+ )
1027+ def test_agent_max_regret_versus_non_agent (game : gbt .Game , action_probs : None | list ,
1028+ rational_flag : bool ,
1029+ max_regret : str | float ,
1030+ agent_max_regret : str | float ,
1031+ agent_liap_value : str | float ,
1032+ liap_value : str | float ,
1033+ ):
1034+ profile = game .mixed_behavior_profile (rational = rational_flag )
1035+ if action_probs :
1036+ _set_action_probs (profile , action_probs , rational_flag )
1037+ assert (profile .max_regret () == (gbt .Rational (max_regret ) if rational_flag else max_regret ))
1038+ assert (
1039+ profile .agent_max_regret () == (gbt .Rational (agent_max_regret )
1040+ if rational_flag else agent_max_regret )
1041+ )
1042+ assert (profile .liap_value () == (gbt .Rational (liap_value ) if rational_flag else liap_value ))
1043+ assert (
1044+ profile .agent_liap_value () == (gbt .Rational (agent_liap_value )
1045+ if rational_flag else agent_liap_value )
1046+ )
1047+
1048+
9581049@pytest .mark .parametrize (
9591050 "game,tol,probs,infoset_idx,member_idx,value,rational_flag" ,
9601051 [(games .create_mixed_behav_game_efg (), TOL , [0.8 , 0.2 , 0.4 , 0.6 , 0.0 , 1.0 ], 0 , 0 , 1.0 , False ),
@@ -1157,6 +1248,39 @@ def _get_and_check_answers(game: gbt.Game, action_probs1: tuple, action_probs2:
11571248 lambda x , y : x .agent_liap_value (), lambda x : [1 ]),
11581249 (games .create_stripped_down_poker_efg (), PROBS_1A_rat , PROBS_2A_rat , True ,
11591250 lambda x , y : x .agent_liap_value (), lambda x : [1 ]),
1251+ ######################################################################################
1252+ # liap_value (of profile, hence [1] for objects_to_test,
1253+ # any singleton collection would do)
1254+ (games .create_mixed_behav_game_efg (), PROBS_1A_doub , PROBS_2A_doub , False ,
1255+ lambda x , y : x .liap_value (), lambda x : [1 ]),
1256+ (games .create_mixed_behav_game_efg (), PROBS_1A_rat , PROBS_2A_rat , True ,
1257+ lambda x , y : x .liap_value (), lambda x : [1 ]),
1258+ (games .create_stripped_down_poker_efg (), PROBS_1B_doub , PROBS_2B_doub , False ,
1259+ lambda x , y : x .liap_value (), lambda x : [1 ]),
1260+ (games .create_stripped_down_poker_efg (), PROBS_1A_rat , PROBS_2A_rat , True ,
1261+ lambda x , y : x .liap_value (), lambda x : [1 ]),
1262+ ######################################################################################
1263+ # agent_max_regret (of profile, hence [1] for objects_to_test,
1264+ # any singleton collection would do)
1265+ (games .create_mixed_behav_game_efg (), PROBS_1A_doub , PROBS_2A_doub , False ,
1266+ lambda x , y : x .agent_max_regret (), lambda x : [1 ]),
1267+ (games .create_mixed_behav_game_efg (), PROBS_1A_rat , PROBS_2A_rat , True ,
1268+ lambda x , y : x .agent_max_regret (), lambda x : [1 ]),
1269+ (games .create_stripped_down_poker_efg (), PROBS_1B_doub , PROBS_2B_doub , False ,
1270+ lambda x , y : x .agent_max_regret (), lambda x : [1 ]),
1271+ (games .create_stripped_down_poker_efg (), PROBS_1A_rat , PROBS_2A_rat , True ,
1272+ lambda x , y : x .agent_max_regret (), lambda x : [1 ]),
1273+ ######################################################################################
1274+ # max_regret (of profile, hence [1] for objects_to_test,
1275+ # any singleton collection would do)
1276+ (games .create_mixed_behav_game_efg (), PROBS_1A_doub , PROBS_2A_doub , False ,
1277+ lambda x , y : x .max_regret (), lambda x : [1 ]),
1278+ (games .create_mixed_behav_game_efg (), PROBS_1A_rat , PROBS_2A_rat , True ,
1279+ lambda x , y : x .max_regret (), lambda x : [1 ]),
1280+ (games .create_stripped_down_poker_efg (), PROBS_1B_doub , PROBS_2B_doub , False ,
1281+ lambda x , y : x .max_regret (), lambda x : [1 ]),
1282+ (games .create_stripped_down_poker_efg (), PROBS_1A_rat , PROBS_2A_rat , True ,
1283+ lambda x , y : x .max_regret (), lambda x : [1 ]),
11601284 ]
11611285)
11621286def test_profile_order_consistency (game : gbt .Game ,
0 commit comments