Skip to content

Instantly share code, notes, and snippets.

@HeshamMeneisi
Last active February 15, 2018 13:09
Show Gist options
  • Save HeshamMeneisi/e1462c64ddcd39e0b4a26af7421e6833 to your computer and use it in GitHub Desktop.
Save HeshamMeneisi/e1462c64ddcd39e0b4a26af7421e6833 to your computer and use it in GitHub Desktop.
Testing OpenAI's Gym
import gym
import time
from gym import envs
print(envs.registry.all())
env = gym.make('CartPole-v0')
env.reset()
t = 0
while True:
time.sleep(0.1)
env.render()
obs, r, done, inf = env.step(env.action_space.sample())
if done:
print("Resetting. Time:", t)
env.reset()
t = 0
else:
t += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment