Skip to content

Instantly share code, notes, and snippets.

@machinaut
Created May 10, 2016 21:06
Show Gist options
  • Save machinaut/b53714194dd7443a820f9bbd8be2c783 to your computer and use it in GitHub Desktop.
Save machinaut/b53714194dd7443a820f9bbd8be2c783 to your computer and use it in GitHub Desktop.
Random agent (run with environment name as argument) for OpenAI gym.
#!/usr/bin/env python
import gym
import sys
env = gym.make(sys.argv[1])
num_episodes = 200
max_timestep = 1000
env.monitor.start(sys.argv[1])
for _ in xrange(num_episodes):
env.reset()
for _ in xrange(max_timestep):
a = env.action_space.sample()
_, _, done, _ = env.step(a)
if done:
break
env.monitor.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment