from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates')) from example_tournaments import axelrod_strategies strategy_names = list(map(str, axelrod_strategies())) strategy_names = [x.replace('/', '-') for x in strategy_names] heatmap_types_names = [("cooperation", "Cooperation Rate Heatmap"), ("opponent_cooperation", "Opponent Cooperation Rate Heatmap"), ("score", "Mean Score Heatmap"), ("score_diff", "Mean Score Difference Heatmap")] # Render individual strategy pages for strategy_name in strategy_names: for (heatmap_directory, heatmap_name) in heatmap_types_names: template = env.get_template('strategy.template') md = template.render(heatmap_types_names=heatmap_types_names, strategy_name=strategy_name) filename = "strategies/{0}.md".format(strategy_name) with open(filename, 'w') as f: f.write(md) # Render README.md plottypes_headers = [("boxplot", "Score Distributions"), ("winplot", "Win Distributions"), ("payoff", "Pairwise Payoffs"), ("sdvplot", "Score Difference Distributions"), ("pdplot", "Pairwise Payoff Differences") ] tournament_info = [("AllFairStrategies", "All Fair Strategies", """This tournament covers all strategies in the Axelrod library that follow the standard Axelrod rules."""),
ensure_directory(str(path)) for sub in ["score", "score_diff", "cooperation", "opponent_cooperation"]: path = Path("assets") / "csv" / sub ensure_directory(str(path)) path = Path("assets") / "heatmaps" / sub ensure_directory(str(path)) path = Path("assets") / "heatmaps" / (sub + "-noisy") ensure_directory(str(path)) if __name__ == "__main__": init() turns, repetitions, noise, function, gen_data = parse_args() # Grab the strategy lists from axelrod # players = list(axelrod_strategies(meta=True)) players = list(reversed(axelrod_strategies())) opponents = list(players) # Generate the data? if gen_data: save_all_match_results(players, turns=200, repetitions=1000, noise=noise) aggregated_data_to_csv(players, opponents, noise=noise) save_tournament_data(players) table_1(players) table_2(players) exit() # We're assuming that the data has been generated going forward # Visualizations make_figures(players, opponents, turns=turns, repetitions=repetitions, noise=noise, function=function)
path = path / "heatmaps" ensure_directory(str(path)) for sub in ["score", "score_diff", "cooperation", "opponent_cooperation"]: path = Path("assets") / "csv" / sub ensure_directory(str(path)) path = Path("assets") / "heatmaps" / sub ensure_directory(str(path)) path = Path("assets") / "heatmaps" / (sub + "-noisy") ensure_directory(str(path)) if __name__ == "__main__": init() turns, repetitions, noise, function, gen_data = parse_args() players = list(reversed(axelrod_strategies(meta=False))) opponents = list(reversed(axelrod_strategies(meta=False))) # Generate the data? if gen_data: save_all_match_results(players, turns=200, repetitions=1000, noise=noise) aggregated_data_to_csv(players, opponents, noise=noise) save_tournament_data(players) table_1(players) table_2(players) exit() # We're assuming that the data has been generated going forward
from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates')) from example_tournaments import axelrod_strategies strategy_names = list(map(str, axelrod_strategies())) strategy_names = [x.replace('/', '-') for x in strategy_names] heatmap_types_names = [("cooperation", "Cooperation Rate Heatmap"), ("opponent_cooperation", "Opponent Cooperation Rate Heatmap"), ("score", "Mean Score Heatmap"), ("score_diff", "Mean Score Difference Heatmap")] # Render individual strategy pages for strategy_name in strategy_names: for (heatmap_directory, heatmap_name) in heatmap_types_names: template = env.get_template('strategy.template') md = template.render(heatmap_types_names=heatmap_types_names, strategy_name=strategy_name) filename = "strategies/{0}.md".format(strategy_name) with open(filename, 'w') as f: f.write(md) # Render README.md plottypes_headers = [("boxplot", "Score Distributions"), ("winplot", "Win Distributions"), ("payoff", "Pairwise Payoffs"), ("sdvplot", "Score Difference Distributions"), ("pdplot", "Pairwise Payoff Differences")]