Last active
February 15, 2018 13:09
-
-
Save HeshamMeneisi/e1462c64ddcd39e0b4a26af7421e6833 to your computer and use it in GitHub Desktop.
Testing OpenAI's Gym
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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