At each step of the cart and pole, several variables can be observed, such as the position, velocity, angle, and angular velocity. The possible state_values of the cart are moved right and left:
- state_values: Four dimensions of continuous values.
- Actions: Two discrete values.
- The dimensions, or space, can be referred to as the state_value space and the action space. Let's start by importing the required libraries, as follows:
import gymimport numpy as npimport randomimport math
- Next, make the environment for playing CartPole, as follows:
environment = gym.make('CartPole-v0')
- Next, define the number of buckets and the number of actions, as follows:
no_buckets = (1, 1, 6, 3)no_actions = environment.action_space.n
- Next, define ...