-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
160 lines (110 loc) · 7.27 KB
/
tests.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import os.path
import re
import unittest
import subprocess
class TestAppRuns(unittest.TestCase):
def test_train_cct_env_01(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env CartPole-v1 -eps 2 -init -net dueling", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_ram_atari_env_01(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env BeamRider-ram-v0 -eps 2 -init", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_img_atari_env_01(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env BeamRider-v0 -frames 3 -eps 2 -init -net dueling", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_2048_env_01(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env 2048-v0 -eps 2 -init -net dueling", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_cct_env_02(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env CartPole-v0 -eps 2 -init -mem prioritized", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_ram_atari_env_02(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env Breakout-ram-v0 -eps 2 -init -mem prioritized", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_img_atari_env_02(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env Breakout-v0 -frames 3 -eps 2 -init -mem prioritized", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_2048_env_02(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env 2048-v0 -eps 2 -init -mem prioritized", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_cct_env_03(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env MountainCar-v0 -eps 2 -alg DQN+TN -update_f 1", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_ram_atari_env_03(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env SpaceInvaders-ram-v0 -eps 2 -init -alg DQN+TN", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_img_atari_env_03(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env SpaceInvaders-v0 -frames 4 -eps 2 -init -alg DQN+TN", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_2048_env_03(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env 2048-v0 -eps 2 -init -mem prioritized -alg DQN+TN -update_f 1", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_cct_env_04(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env Acrobot-v1 -eps 2 -alg DDQN -save_f 1", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_ram_atari_env_04(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env Breakout-ram-v0 -eps 2 -init -alg DDQN -save_f 2", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_img_atari_env_04(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env Breakout-v0 -frames 2 -eps 2 -init -alg DDQN -save_f 2", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_train_2048_env_04(self):
output = subprocess.check_output("python3 pgunn/main.py -mode train -env 2048-v0 -eps 2 -init -mem prioritized -alg DDQN -dont_save", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_test_cct_env_05(self):
output = subprocess.check_output("python3 pgunn/main.py -mode test -env CartPole-v1 -eps 2 -mdl ./models/CartPole-v1_basic.h5", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_test_ram_atari_env_05(self):
output = subprocess.check_output("python3 pgunn/main.py -mode test -env BeamRider-ram-v0 -eps 2 -mdl ./models/BeamRider-ram-v0_basic.h5", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_test_img_atari_env_05(self):
output = subprocess.check_output("python3 pgunn/main.py -mode test -env BeamRider-v0 -frames 2 -eps 2 -mdl ./models/BeamRider-v0_basic.h5", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_test_2048_env_05(self):
output = subprocess.check_output("python3 pgunn/main.py -mode test -env 2048-v0 -eps 2 -mdl ./models/2048-v0_basic.h5", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_visualization_01(self):
output = subprocess.check_output("python3 pgunn/visualization.py -filename log.out -graph_name score -idx_val 6", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_visualization_02(self):
output = subprocess.check_output("python3 pgunn/visualization.py -filename log.out -graph_name results -idx_val 6 -lines 22 30 -scatter", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
def test_visualization_03(self):
output = subprocess.check_output("python3 pgunn/visualization.py -filename log.out -graph_name moves -idx_val 4 -coordinate_x 50", shell=True)
rgx = re.compile(r'''\[SUCCESSFUL\sRUN\]''', re.X)
self.assertTrue(rgx.search(str(output)))
if __name__ == "__main__":
with open('./pgunn/agent_args.json', 'r') as file:
data = file.readlines()
data[57] = ' \"memory_size\": \"100\",\n'
data[69] = ' \"memory_size\": \"100\",\n'
data[81] = ' \"memory_size\": \"100\",\n'
data[93] = ' \"memory_size\": \"100\",\n'
data[105] = ' \"memory_size\": \"100\",\n'
data[117] = ' \"memory_size\": \"100\",\n'
data[129] = ' \"memory_size\": \"100\",\n'
with open('./pgunn/agent_args.json', 'w') as file:
file.writelines(data)
unittest.main()