Created
March 18, 2017 20:00
-
-
Save sofroniewn/ec9c711b81aa3ed60b350cbbbba74c7e to your computer and use it in GitHub Desktop.
CartPole-experiment-1.py
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 | |
| from gym import wrappers | |
| env = gym.make('CartPole-v0') | |
| env = wrappers.Monitor(env, './tmp/cartpole-experiment-1') | |
| for i_episode in range(20): | |
| observation = env.reset() | |
| for t in range(100): | |
| env.render() | |
| action = env.action_space.sample() | |
| observation, reward, done, info = env.step(action) | |
| if done: | |
| print("Episode finished after {} timesteps".format(t+1)) | |
| break | |
| env.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment