forked from MorvanZhou/train-robot-arm-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (38 loc) · 813 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
42
43
44
45
46
47
48
49
"""
Complete the env.py
"""
from part3.env import ArmEnv
from part3.rl import DDPG
MAX_EPISODES = 500
MAX_EP_STEPS = 200
# set env
env = ArmEnv()
s_dim = env.state_dim
a_dim = env.action_dim
a_bound = env.action_bound
# set RL method
rl = DDPG(a_dim, s_dim, a_bound)
# start training
for i in range(MAX_EPISODES):
s = env.reset()
for j in range(MAX_EP_STEPS):
env.render()
a = rl.choose_action(s)
s_, r, done = env.step(a)
rl.store_transition(s, a, r, s_)
if rl.memory_full:
# start to learn once has fulfilled the memory
rl.learn()
s = s_
# summary:
"""
env should have at least:
env.reset()
env.render()
env.step()
while RL should have at least:
rl.choose_action()
rl.store_transition()
rl.learn()
rl.memory_full
"""