-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (42 loc) · 1.37 KB
/
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
42
43
44
45
46
47
48
49
import sys
import getopt
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(
argv[1:], "hg:n:", ["help", "game=", "network="])
except getopt.error as msg:
raise Usage(msg)
except Usage as err:
print(sys.stderr, err.msg)
print(sys.stderr, "for help use --help")
return 2
if len(opts) == 0:
print("Please specify parameters!")
return 1
for opt, arg in opts:
if opt in ("-h", "--help"):
print(__doc__)
return 0
elif opt in ("-g", "--game"):
if arg == 'fb':
from train_fb import run
if arg == 'fbtest':
from test_fb import run
else:
print("No this game, now we have flappy bird(fb)")
return 1
elif opt in ("-n", "--network"):
if arg in ['dqn', 'double_dqn', 'mydqn', 'mydqn2', 'prio_dqn', 'pos_prio_dqn', 'dueling_dqn']:
run(arg)
else:
print("You could choose 'dqn','double_dqn','mydqn', 'mydqn2', 'prio_dqn', 'pos_prio_dqn', 'dueling_dqn' as network's parameter")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())