# run this from the terminal and make sure you are loading appropriate environment variables # $ echo $LD_LIBRARY_PATH import gym from tf_rl.common.monitor import Monitor import environments.register as register video_dir = "./video/" temp = 5 env = gym.make("CentipedeSix-v1") env = Monitor(env, video_dir, force=True) for ep in range(10): if ep % temp == 0: print("recording") env.record_start() env.reset() done = False while not done: # env.render() action = env.action_space.sample() s, r, done, info = env.step(action) # take a random action if ep % temp == 0: env.record_end()
import gym from tf_rl.common.monitor import Monitor env = gym.make('CartPole-v0') env = Monitor(env=env, directory="./video/cartpole", force=True) for ep in range(20): if ep == 0: env.record_start() state = env.reset() for t in range(1000): action = env.action_space.sample() state, reward, done, info = env.step(action) if done: if ep == 0: env.record_end() break env.close()