Last active
February 23, 2018 21:17
-
-
Save breuderink/2e535381d7f9d8fc92c17e4ff4e75e46 to your computer and use it in GitHub Desktop.
Dump SARS from AI Gym
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-0.044 | -0.15 | 0.013 | 0.28 | 1 | 1 | -0.047 | 0.046 | 0.018 | -0.013 | |
---|---|---|---|---|---|---|---|---|---|---|
-0.047 | 0.046 | 0.018 | -0.013 | 1 | 1 | -0.046 | 0.24 | 0.018 | -0.3 | |
-0.046 | 0.24 | 0.018 | -0.3 | 0 | 1 | -0.041 | 0.046 | 0.012 | -0.0013 | |
-0.041 | 0.046 | 0.012 | -0.0013 | 1 | 1 | -0.04 | 0.24 | 0.012 | -0.29 | |
-0.04 | 0.24 | 0.012 | -0.29 | 1 | 1 | -0.035 | 0.44 | 0.0063 | -0.58 | |
-0.035 | 0.44 | 0.0063 | -0.58 | 1 | 1 | -0.026 | 0.63 | -0.0053 | -0.87 | |
-0.026 | 0.63 | -0.0053 | -0.87 | 1 | 1 | -0.014 | 0.83 | -0.023 | -1.2 | |
-0.014 | 0.83 | -0.023 | -1.2 | 1 | 1 | 0.0027 | 1 | -0.046 | -1.5 | |
0.0027 | 1 | -0.046 | -1.5 | 1 | 1 | 0.023 | 1.2 | -0.075 | -1.8 | |
0.023 | 1.2 | -0.075 | -1.8 | 1 | 1 | 0.047 | 1.4 | -0.11 | -2.1 | |
0.047 | 1.4 | -0.11 | -2.1 | 0 | 1 | 0.076 | 1.2 | -0.15 | -1.8 | |
0.076 | 1.2 | -0.15 | -1.8 | 0 | 1 | 0.1 | 1 | -0.19 | -1.6 | |
0.1 | 1 | -0.19 | -1.6 | 1 | 0 | 0.12 | 1.2 | -0.22 | -1.9 | |
-0.039 | -0.18 | -0.01 | 0.31 | 0 | 1 | -0.043 | -0.37 | -0.0043 | 0.6 | |
-0.043 | -0.37 | -0.0043 | 0.6 | 0 | 1 | -0.05 | -0.57 | 0.0076 | 0.89 | |
-0.05 | -0.57 | 0.0076 | 0.89 | 0 | 1 | -0.062 | -0.76 | 0.025 | 1.2 | |
-0.062 | -0.76 | 0.025 | 1.2 | 0 | 1 | -0.077 | -0.96 | 0.049 | 1.5 | |
-0.077 | -0.96 | 0.049 | 1.5 | 1 | 1 | -0.096 | -0.76 | 0.079 | 1.2 | |
-0.096 | -0.76 | 0.079 | 1.2 | 0 | 1 | -0.11 | -0.96 | 0.1 | 1.5 | |
-0.11 | -0.96 | 0.1 | 1.5 | 1 | 1 | -0.13 | -0.77 | 0.13 | 1.3 | |
-0.13 | -0.77 | 0.13 | 1.3 | 1 | 1 | -0.15 | -0.57 | 0.16 | 1 | |
-0.15 | -0.57 | 0.16 | 1 | 0 | 1 | -0.16 | -0.77 | 0.18 | 1.4 | |
-0.16 | -0.77 | 0.18 | 1.4 | 0 | 1 | -0.17 | -0.97 | 0.21 | 1.7 | |
-0.17 | -0.97 | 0.21 | 1.7 | 1 | 0 | -0.19 | -0.77 | 0.24 | 1.5 | |
-0.044 | 0.2 | -0.045 | -0.26 | 1 | 1 | -0.04 | 0.39 | -0.05 | -0.57 | |
-0.04 | 0.39 | -0.05 | -0.57 | 1 | 1 | -0.032 | 0.59 | -0.062 | -0.87 | |
-0.032 | 0.59 | -0.062 | -0.87 | 0 | 1 | -0.02 | 0.4 | -0.079 | -0.6 | |
-0.02 | 0.4 | -0.079 | -0.6 | 1 | 1 | -0.012 | 0.59 | -0.091 | -0.92 | |
-0.012 | 0.59 | -0.091 | -0.92 | 0 | 1 | -0.00056 | 0.4 | -0.11 | -0.65 | |
-0.00056 | 0.4 | -0.11 | -0.65 | 1 | 1 | 0.0074 | 0.59 | -0.12 | -0.98 | |
0.0074 | 0.59 | -0.12 | -0.98 | 0 | 1 | 0.019 | 0.4 | -0.14 | -0.73 | |
0.019 | 0.4 | -0.14 | -0.73 | 1 | 1 | 0.027 | 0.6 | -0.16 | -1.1 | |
0.027 | 0.6 | -0.16 | -1.1 | 1 | 1 | 0.039 | 0.79 | -0.18 | -1.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
import numpy as np | |
import gym | |
SARS = namedtuple('SARS', ['state', 'action', 'reward', 'state_next']) | |
if __name__ == '__main__': | |
# See https://github.com/openai/gym/blob/master/gym/envs/classic_control/cartpole.py . | |
env = gym.make('CartPole-v1') | |
env.seed(0) | |
trace = [] | |
for i in range(50): | |
ob = env.reset() | |
s_old = [] | |
while True: | |
a = env.action_space.sample() | |
s, r, done, _ = env.step(a) | |
s = s.tolist() | |
if s_old != []: | |
trace.append(SARS(s_old, a, 0 if done else 1, s)) | |
s_old = s | |
if done: | |
break | |
env.close() | |
D = [t.state + [t.action, t.reward] + t.state_next for t in trace] | |
np.savetxt('cartpolev1.tsv', D, '%.2g', delimiter='\t') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment