Skip to content

Commit cead607

Browse files
committed
Adding the run_axelrod script
1 parent c0903d5 commit cead607

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

run_axelrod

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

0 commit comments

Comments
 (0)