def pure_equilibria(game, *, epsilon=0): """Returns an array of all pure nash profiles""" eqa = [ prof for prof in game.profiles() if regret.pure_strategy_regret(game, prof) <= epsilon ] return np.stack(eqa) if eqa else np.empty((0, game.num_strats))
def test_pure_incomplete_data(): """Test pure regret with incomplete data""" profiles = [[2, 0]] payoffs = [[1.0, 0.0]] game = paygame.game(2, 2, profiles, payoffs) reg = regret.pure_strategy_regret(game, [2, 0]) assert np.isnan(reg), 'regret of missing profile not nan'
def test_pure_prisoners_dilemma(_): """Test pure prisoners dilemma""" game = gamegen.sym_2p2s_game(2, 0, 3, 1) # prisoners dilemma eqm = [0, 2] assert regret.pure_strategy_regret(game, eqm) == 0, \ 'Known equilibrium was not zero regret'
def min_regret_profile(game): """Finds the profile with the confirmed lowest regret An error will be raised if there are no profiles with a defined regret. """ regs = np.fromiter((regret.pure_strategy_regret(game, prof) for prof in game.profiles), float, game.num_profiles) return game.profiles[np.nanargmin(regs)]
def pure_nash(game, epsilon=0): """Returns an array of all pure nash profiles""" eqa = [prof[None] for prof in game.profiles if regret.pure_strategy_regret(game, prof) <= epsilon] if eqa: return np.concatenate(eqa) else: return np.empty((0, game.num_role_strats))
def min_regret_profile(game): """Finds the profile with the confirmed lowest regret An error will be raised if there are no profiles with a defined regret. """ utils.check(not game.is_empty(), 'Game must have a profile') reg, _, prof = min( (_nan_to_inf(regret.pure_strategy_regret(game, prof)), i, prof) for i, prof in enumerate(game.profiles())) utils.check(not np.isinf(reg), 'No profiles had valid regret') return prof
def reg(game, serial, prof): """the regret of the profile""" if is_pure_profile(game, prof): return regret.pure_strategy_regret(game, prof).item() else: return regret.mixture_regret(game, prof).item()
def calc_reg(game, prof): """the regret of the profile""" if is_pure_profile(game, prof): # pylint: disable=no-else-return return regret.pure_strategy_regret(game, np.asarray(prof, int)).item() else: return regret.mixture_regret(game, prof).item()
def test_pure_incomplete_data(): profiles = [[2, 0]] payoffs = [[1.0, 0.0]] game = rsgame.Game(2, 2, profiles, payoffs) reg = regret.pure_strategy_regret(game, [2, 0]) assert np.isnan(reg), "regret of missing profile not nan"
def pure_equilibria(game, *, epsilon=0): """Returns an array of all pure nash profiles""" eqa = [prof for prof in game.profiles() if regret.pure_strategy_regret(game, prof) <= epsilon] return np.stack(eqa) if eqa else np.empty((0, game.num_strats))