@@ -501,49 +501,55 @@ def test_strategy_value_reference(game: gbt.Game, profile_data: list, rational_f
501501
502502
503503@pytest .mark .parametrize (
504- "game,profile_data,liap_expected ,tol,rational_flag" ,
504+ "game,profile_data,liap_exp,max_regret_exp ,tol,rational_flag" ,
505505 [
506506 ##############################################################################
507507 # Zero matrix nfg, all liap_values are zero
508- (games .create_2x2_zero_nfg (), [["3/4" , "1/4" ], ["2/5" , "3/5" ]], 0 , ZERO , True ),
509- (games .create_2x2_zero_nfg (), [["1/2" , "1/2" ], ["1/2" , "1/2" ]], 0 , ZERO , True ),
510- (games .create_2x2_zero_nfg (), [[1 , 0 ], [1 , 0 ]], 0 , ZERO , True ),
511- (games .create_2x2_zero_nfg (), [[1 / 4 , 3 / 4 ], [2 / 5 , 3 / 5 ]], 0 , TOL , False ),
508+ (games .create_2x2_zero_nfg (), [["3/4" , "1/4" ], ["2/5" , "3/5" ]], 0 , 0 , ZERO , True ),
509+ (games .create_2x2_zero_nfg (), [["1/2" , "1/2" ], ["1/2" , "1/2" ]], 0 , 0 , ZERO , True ),
510+ (games .create_2x2_zero_nfg (), [[1 , 0 ], [1 , 0 ]], 0 , 0 , ZERO , True ),
511+ (games .create_2x2_zero_nfg (), [[1 / 4 , 3 / 4 ], [2 / 5 , 3 / 5 ]], 0 , 0 , TOL , False ),
512512 ##############################################################################
513513 # 4x4 coordination nfg
514- (games .create_coord_4x4_nfg (), None , 0 , ZERO , True ),
515- (games .create_coord_4x4_nfg (), None , 0 , TOL , False ),
514+ (games .create_coord_4x4_nfg (), None , 0 , 0 , ZERO , True ),
515+ (games .create_coord_4x4_nfg (), None , 0 , 0 , TOL , False ),
516+ (games .create_coord_4x4_nfg (), [[1 , 0 , 0 , 0 ], [1 , 0 , 0 , 0 ]], 0 , 0 , ZERO , True ),
517+ (games .create_coord_4x4_nfg (), [[1 , 0 , 0 , 0 ], [1 , 0 , 0 , 0 ]], 0 , 0 , TOL , False ),
516518 (games .create_coord_4x4_nfg (),
517- [["1/3" , "1/2" , "1/12" , "1/12" ], ["3/8" , "1/8" , "1/4" , "1/4" ]], "245/2304" , ZERO , True ),
518- (games .create_coord_4x4_nfg (),
519- [["1/4" , "1/4" , "1/4" , "1/4" ], ["1/4" , "1/4" , "1/4" , "1/4" ]], 0 , ZERO , True ),
520- (games .create_coord_4x4_nfg (), [[1 , 0 , 0 , 0 ], [1 , 0 , 0 , 0 ]], 0 , ZERO , True ),
519+ [["1/3" , "1/2" , "1/12" , "1/12" ], ["3/8" , "1/8" , "1/4" , "1/4" ]],
520+ "245/2304" , "13/48" , ZERO , True ),
521521 (games .create_coord_4x4_nfg (), [[1 / 3 , 1 / 2 , 1 / 12 , 1 / 12 ], [3 / 8 , 1 / 8 , 1 / 4 , 1 / 4 ]],
522- 245 / 2304 , TOL , False ),
522+ 245 / 2304 , 13 / 48 , TOL , False ),
523+ (games .create_coord_4x4_nfg (),
524+ [["1/3" , 0 , 0 , "2/3" ], [1 , 0 , 0 , 0 ]], "5/9" , "2/3" , ZERO , True ),
525+ (games .create_coord_4x4_nfg (),
526+ [[1 / 3 , 0 , 0 , 2 / 3 ], [1 , 0 , 0 , 0 ]], 5 / 9 , 2 / 3 , TOL , False ),
523527 ##############################################################################
524528 # El Farol bar game efg
525529 (games .create_el_farol_bar_game_efg (),
526- [["1/2" , "1/2" ], ["1/2" , "1/2" ], ["1/2" , "1/2" ], ["1/2" , "1/2" ], ["1/2" , "1/2" ]], "0" ,
527- ZERO , True ),
528- (games .create_el_farol_bar_game_efg (),
529- [["1/1" , "0/1" ], ["1/1" , "0/1" ], ["0/1" , "1/1" ], ["0/1" , "1/1" ], ["0/1" , "1/1" ]], "0" ,
530- ZERO , True ),
530+ [["1/2" , "1/2" ], ["1/2" , "1/2" ], ["1/2" , "1/2" ], ["1/2" , "1/2" ], ["1/2" , "1/2" ]],
531+ 0 , 0 , ZERO , True ),
532+ (games .create_el_farol_bar_game_efg (), [[1 , 0 ], [1 , 0 ], [0 , 1 ], [0 , 1 ], [0 , 1 ]],
533+ 0 , 0 , ZERO , True ),
531534 ##############################################################################
532- # 2x2x2 nfg with 2 pure and 1 mixed eq
533- (games .create_2x2x2_nfg (), [[1 , 0 ], [1 , 0 ], [1 , 0 ]], 18 , ZERO , True ), # 4^2+1+1
534- (games .create_2x2x2_nfg (), [[0 , 1 ], [0 , 1 ], [0 , 1 ]], 18 , ZERO , True ), # 4^2+1+1
535- (games .create_2x2x2_nfg (), [[1 , 0 ], [0 , 1 ], [1 , 0 ]], 0 , ZERO , True ),
536- (games .create_2x2x2_nfg (), [[0 , 1 ], [1 , 0 ], [0 , 1 ]], 0 , ZERO , True ),
537- (games .create_2x2x2_nfg (), None , 0 , ZERO , True ), # uniform is Nash
535+ # # 2x2x2 nfg with 2 pure and 1 mixed eq
536+ (games .create_2x2x2_nfg (), [[1 , 0 ], [1 , 0 ], [1 , 0 ]], 18 , 4 , ZERO , True ), # 4^2+1+1
537+ (games .create_2x2x2_nfg (), [[0 , 1 ], [0 , 1 ], [0 , 1 ]], 18 , 4 , ZERO , True ), # 4^2+1+1
538+ (games .create_2x2x2_nfg (), [[1 , 0 ], [0 , 1 ], [1 , 0 ]], 0 , 0 , ZERO , True ),
539+ (games .create_2x2x2_nfg (), [[0 , 1 ], [1 , 0 ], [0 , 1 ]], 0 , 0 , ZERO , True ),
540+ (games .create_2x2x2_nfg (), None , 0 , 0 , ZERO , True ), # uniform is Nash
538541 ]
539542)
540- def test_liapunov_value_reference (game : gbt .Game , profile_data : list ,
541- liap_expected : float | str ,
542- tol : float | gbt . Rational | int ,
543- rational_flag : bool ):
544- liap_expected = gbt . Rational ( liap_expected ) if rational_flag else liap_expected
543+ def test_liap_value_max_regret_reference (game : gbt .Game , profile_data : list ,
544+ liap_exp : float | str ,
545+ max_regret_exp : float | str ,
546+ tol : float | gbt . Rational | int ,
547+ rational_flag : bool ):
545548 profile = game .mixed_strategy_profile (rational = rational_flag , data = profile_data )
546- assert abs (profile .liap_value () - liap_expected ) <= tol
549+ liap_exp = gbt .Rational (liap_exp ) if rational_flag else liap_exp
550+ max_regret_exp = gbt .Rational (max_regret_exp ) if rational_flag else max_regret_exp
551+ assert abs (profile .liap_value () - liap_exp ) <= tol
552+ assert abs (profile .max_regret () - max_regret_exp ) <= tol
547553
548554
549555@pytest .mark .parametrize (
0 commit comments