Skip to content

Instantly share code, notes, and snippets.

@vimal1083
Created January 26, 2017 10:23
Show Gist options
  • Select an option

  • Save vimal1083/31793f5860b71471e1902a2b2304602d to your computer and use it in GitHub Desktop.

Select an option

Save vimal1083/31793f5860b71471e1902a2b2304602d to your computer and use it in GitHub Desktop.
import gym
from gym import wrappers
env = gym.make('CartPole-v0')
env = wrappers.Monitor(env, '/tmp/cartpole-experiment-1')
for i_episode in range(100):
observation = env.reset()
for t in range(100):
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