-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_states_std.py
43 lines (29 loc) · 1006 Bytes
/
get_states_std.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
import gym
import pybulletgym
import numpy as np
import random
import math
import matplotlib.pyplot as plt
ENV_NAME = "InvertedDoublePendulumPyBulletEnv-v0"
# ENV_NAME = "InvertedPendulumPyBulletEnv-v0"
MAX_EPISODES = 500
MAX_TIMESTEPS = 10000
if __name__=="__main__":
env = gym.make(ENV_NAME)
random.seed(46454)
states = []
for i_episode in range(MAX_EPISODES):
state = env.reset()
for timesteps in range(MAX_TIMESTEPS):
states.append(state)
action = random.random() * 2 - 1
state, reward, done, _ = env.step([action])
if done:
# print("Episode {} finished after {} timesteps".format(i_episode, timesteps+1))
break
env.close()
states = np.array(states)
print(np.mean(states, axis=0))
print(np.std(states, axis=0))
print("Max : {}".format(np.max(states, axis=0)))
print("Min : {}".format(np.min(states, axis=0)))