Skip to content

Instantly share code, notes, and snippets.

@EKami
Created August 21, 2017 15:02
Show Gist options
  • Save EKami/0b63f44988edf09d31b7652b7222c97c to your computer and use it in GitHub Desktop.
Save EKami/0b63f44988edf09d31b7652b7222c97c to your computer and use it in GitHub Desktop.
Cartpole test
import gym
from gym import wrappers
env = gym.make('CartPole-v0')
env = wrappers.Monitor(env, '/tmp/cartpole-experiment-1', force=True)
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.close()
gym.upload('/tmp/cartpole-experiment-1', api_key='sk_pLl5b2tRYmVSt3YnhT7Hg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment