Skip to content

Instantly share code, notes, and snippets.

@shivangg
Created March 15, 2017 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shivangg/f44534f6c3093a4129ec2b194326448b to your computer and use it in GitHub Desktop.
Save shivangg/f44534f6c3093a4129ec2b194326448b to your computer and use it in GitHub Desktop.
Trying out OpenAI cartpole example
import gym
from gym import wrappers
env = gym.make('CartPole-v0')
env = wrappers.Monitor(env, '/tmp/cartpole-experiment-1')
for i_episode in range(200):
observation = env.reset()
for t in range(1000):
env.render()
print(observation)
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
if done:
print("Episode finished after {} timesteps".format(t+1))
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment