def main():
    parser = IO.io_parser('Create Data for Memory Experiments')
    parser.add_argument('players', type=int, help='number of players')
    parser.add_argument('strategies', type=int, help='number of strategies')
    IO.sys.argv = IO.sys.argv[:3] + ["-input", None] + IO.sys.argv[3:]
    args = parser.parse_args()
    game = RandomGames.uniform_symmetric_game(args.players, args.strategies, 0, 100).to_asymmetric_game()
    open(args.output + ".nfg", 'w').write(IO.to_NFG_asym(game))
示例#2
0
def construct_game(input):
    options = input.get('options', {})
    if input['type'] == 'local_effect':
        game = RandomGames.local_effect_game(**options)
        RandomGames.rescale_payoffs(game)
    elif input['type'] == 'congestion':
        game = RandomGames.congestion_game(**options)
        RandomGames.rescale_payoffs(game)
    elif input['type'] == 'uniform':
        game = RandomGames.uniform_symmetric_game(**options)
        RandomGames.rescale_payoffs(game)
    elif input['type'] == 'file':
        game = Reductions.deviation_preserving_reduction(GameIO.read(input['file']), {'All': 6})
    return game
示例#3
0
def bootstrap_experiment(base_game_func, noise_model, statistic=regret, \
		num_games=1000, stdevs=[1.,10.,100.], sample_sizes=[5,10,20, \
		50,100,200,500], equilibrium_search=mixed_nash, bootstrap_args=[]):
	results = [{s:{} for s in stdevs} for i in range(num_games)]
	for i in range(num_games):
		base_game = base_game_func()
		RG.rescale_payoffs(base_game, 0, 100)
		for stdev in stdevs:
			sample_game = RG.add_noise(base_game, noise_model, stdev, \
									sample_sizes[-1])
			for sample_size in sample_sizes:
				subsample_game = subsample(sample_game, sample_size)
				equilibria = equilibrium_search(subsample_game)
				results[i][stdev][sample_size] = [ \
					{ \
						"profile" : eq,
						"statistic" : statistic(base_game, eq),
						"bootstrap" : bootstrap(subsample_game, eq, statistic, \
												*bootstrap_args)
					} for eq in equilibria]
	return results