Skip to content

Instantly share code, notes, and snippets.

@tankala
Last active October 19, 2018 11:26
Show Gist options
  • Save tankala/b33d92e2b46742c0364a79ef5b9c0729 to your computer and use it in GitHub Desktop.
Save tankala/b33d92e2b46742c0364a79ef5b9c0729 to your computer and use it in GitHub Desktop.
First time we want to understand exactly what happens with CartPole game this code snippet will help you
import gym
env = gym.make('CartPole-v1')
env.reset()
for step_index in range(1000):
env.render()
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
print("Step {}:".format(step_index))
print("action: {}".format(action))
print("observation: {}".format(observation))
print("reward: {}".format(reward))
print("done: {}".format(done))
print("info: {}".format(info))
if done:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment