Skip to content

Instantly share code, notes, and snippets.

@ChenLi0830
Created June 23, 2016 14:21
Show Gist options
  • Save ChenLi0830/cbfac3a244b00a2ad0f193a8b6b29661 to your computer and use it in GitHub Desktop.
Save ChenLi0830/cbfac3a244b00a2ad0f193a8b6b29661 to your computer and use it in GitHub Desktop.
OpenAI test
import gym
env = gym.make('CartPole-v0')
env.monitor.start('tmp/cartpole-experiment-1')
for i_episode in range(20):
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
env.monitor.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment