-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
41 lines (28 loc) · 856 Bytes
/
main.py
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
#!/usr/bin/env python
'''
Created on May 15, 2011
@author: ben
'''
import sys, getopt, world
def main(argv):
world_to_run = 'PrisonersDilemma'
try:
opts, args = getopt.getopt(argv, 'h','--help')
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ('-h','--help'):
usage()
sys.exit()
world_to_run = "".join(args) or world_to_run
print "running world %s" % world_to_run
instantiate_world(world_to_run).run()
def usage():
'''prints usage instructions'''
print('Usage: main.py [world]')
def instantiate_world(name_of_world):
'''instantiates the named world (class = world.[name_of_world]World)'''
return world.PrisonersDilemmaWorld()
if __name__ == '__main__':
main(sys.argv[1:])