Project - Reinforcement Learning - How to make computer learn to play CartPole game

9 / 24

Understanding CartPole game of OpenAI gym

  • Let us use the cartpole environment.
INSTRUCTIONS
  • Let's get the CartPole environment from gym:

    env = gym.make('CartPole-v1')
    
  • Set the seed for env:

    env.seed(42)
    
  • Let's initialize the environment by calling is reset() method. This returns an observation:

    obs = env.<< your code comes here >>()
    
  • Print the observation obs:

    print(obs)
    

    As discussed previously, the obs of CartPole has 4 values:

    • First value -0.01258566 is the position of the cart.

    • Second value -0.00156614 is the velocity of the cart.

    • Third value 0.04207708 is the angle of the pole.

    • Fourth value -0.00180545 is the angular velocity of the pole.

  • Let's see what the action space looks like:

    print(env.action_space)
    

    It says that CartPole has two values for action. As discussed previously, 0 means left action, 1 means right action.

  • For more info on env, we could do:

    help(env)
    
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...