-
Notifications
You must be signed in to change notification settings - Fork 8
/
random_agent.py
38 lines (27 loc) · 860 Bytes
/
random_agent.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
from environment.particle import ParticleEnv
import numpy as np
def run(testing=False):
env = ParticleEnv()
env.reset()
tmax = 100
episodes = 10
e = 0
while e < episodes:
print("new episode")
goal_obs = env.generate_goal(e)
t = 0
while t < tmax:
env.reset()
state = env.state
obs, state, r, done = env.step([np.random.uniform(low=-0.5, high=0.5), np.random.uniform(low=-0.5, high=0.5)])
if t == 0 and testing:
from scipy import misc
misc.imsave('goal_obs{}.png'.format(e), goal_obs)
misc.imsave('first_obs{}.png'.format(e), obs)
if done:
print("Done", r)
env.reset()
t += 1
e += 1
if __name__ == '__main__':
run(testing=False)