-
Notifications
You must be signed in to change notification settings - Fork 0
/
sumotest.py
executable file
·39 lines (30 loc) · 916 Bytes
/
sumotest.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import agent as ag
import sumoenv as se
env_train = se.SumoEnv(gui_f=False)
env_test = se.SumoEnv(gui_f=True)
agent = ag.Agent()
EPS = 2
for ieps in range(EPS):
for i in range(20):
print "Start Training"
state = env_train.reset()
done = False
while not done:
action = agent.policy(state)
next_state, reward, done, rewards = env_train.step_d(action)
agent.train(state, action, reward, 0.001, [1, 1, done, 1, 1])
state = next_state
print "Stop Training"
env_train.close()
print "Start Testing"
state = env_test.reset()
done = False
while not done:
action = agent.policy(state)
next_state, reward, done, rewards = env_test.step_d(action)
print(state)
state = next_state
print "Stop Testing"
env_test.close()