add gym examples

This commit is contained in:
Jie Tan
2017-03-10 11:22:38 -08:00
parent d3ee7f68a1
commit 923fbe8588
8 changed files with 430 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
"""One-line documentation for gym_example module.
A detailed description of gym_example.
"""
import gym
from envs.bullet.cartpole_bullet import CartPoleBulletEnv
import setuptools
import time
import numpy as np
w = [0.3, 0.02, 0.02, 0.012]
def main():
env = gym.make('CartPoleBulletEnv-v0')
for i_episode in range(1):
observation = env.reset()
done = False
t = 0
while not done:
print(observation)
action = np.array([np.inner(observation, w)])
print(action)
observation, reward, done, info = env.step(action)
t = t + 1
if done:
print("Episode finished after {} timesteps".format(t+1))
break
main()