Skip to content

Instantly share code, notes, and snippets.

Created May 1, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/de3e7e1f5919511ca77d3f3c02015b36 to your computer and use it in GitHub Desktop.
Save anonymous/de3e7e1f5919511ca77d3f3c02015b36 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import gym
import sys
import os
try:
test = str(sys.argv[1])
env = gym.make(test)
env.monitor.start('/tmp/{0}-1'.format(test[2:]))
env.reset()
counter = 0
while 1:
tick = counter + 1
counter = tick
env.render()
action = env.action_space.sample() # take a random action
observation, reward, done, info = env.step(action)
print observation
if done:
apikey = file('APIKey', 'r').read()
print "Episode {0} finished".format(counter)
env.monitor.close()
writeup = os.popen("gist OpenAI").read()
gym.upload('/tmp/{0}-1'.format(test[2:]), writeup=writeup,api_key=str(apikey).strip("\n"))
break
except KeyboardInterrupt:
env.monitor.close()
sys.exit()
except IndexError:
print "Error! Missing Test."
print "Please run: "
print "{0} Test-v0".format(sys.argv[0])
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment