forked from Axelrod-Python/Axelrod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_axelrod
executable file
·122 lines (100 loc) · 3.14 KB
/
run_axelrod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python
"""A script to run the Axelrod tournament.
The code for strategies is present in `axelrod/strategies`.
"""
from __future__ import division
import argparse
from axelrod import run_tournaments, setup_logging
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Run a recreation of Axelrod's tournament")
parser.add_argument(
'-l', '--logging',
type=str,
default='console',
dest="logging_destination",
help='logging (none, console or file)')
parser.add_argument(
'-v', '--verbosity',
type=str,
default='INFO',
help='Logging level. DEBUG, INFO, ERROR or CRITICAL')
parser.add_argument(
'-t',
'--turns',
type=int,
default=200,
help='turns per pair')
parser.add_argument(
'-r', '--repetitions',
type=int,
default=10,
help='round-robin repetitions')
parser.add_argument(
'-o', '--output_directory',
default='./',
help='output directory')
parser.add_argument(
'--xb',
"--exclude-basic",
action='store_true',
dest="exclude_basic",
help='exclude basic strategies plot')
parser.add_argument(
'--xs', "--exclude-ordinary",
action='store_true',
dest="exclude_ordinary",
help='exclude ordinary strategies plot')
parser.add_argument(
'--xc', "--exclude-cheating",
action='store_true',
dest="exclude_cheating",
help='exclude cheating strategies plot')
parser.add_argument(
'--xa', "--exclude-combined",
action='store_true',
dest="exclude_combined",
help='exclude combined strategies plot')
parser.add_argument(
'--ne', "--no-ecological",
action='store_true',
dest="no_ecological",
help='no ecological variant')
parser.add_argument(
'-p', '--processes',
type=int,
default=None,
help='Number of parallel processes to spawn. 0 uses cpu count.')
parser.add_argument(
'--rc', "--rebuild-cache",
action='store_true',
dest="rebuild_cache",
help='rebuild cache and save to file')
parser.add_argument(
'-c', '--cache_file',
type=str,
default='./cache.txt',
help='Path to cache file')
parser.add_argument(
'-n', '--noise',
type=float,
default=0,
help='Noise level')
parser.add_argument(
'-i', '--image_format',
type=str,
default="svg",
help='Image format for matplotlib, e.g. svg, jpeg, png')
args = parser.parse_args()
if all([args.exclude_basic,
args.exclude_ordinary,
args.exclude_cheating,
args.exclude_combined]):
print("You've excluded everything - nothing for me to do")
else:
setup_logging(args.logging_destination, args.verbosity)
# Unravel argparse Namespace object to python keyword arguments.
kwargs = vars(args)
del kwargs["logging_destination"]
del kwargs["verbosity"]
run_tournaments(**kwargs)