October 2019
Intermediate to advanced
366 pages
12h 4m
English
In OpenAI Gym, actions and observations are mostly instances of the Discrete or Box class. These two classes represent different spaces. Box represents an n-dimensional array, while Discrete, on the other hand, is a space that allows a fixed range of non-negative numbers. In the preceding table, we have already seen that the observation of CartPole is encoded by four floats, meaning that it's an instance of the Box class. It is possible to check the type and dimension of the observation spaces by printing the env.observation_space variable:
import gymenv = gym.make('CartPole-v1')print(env.observation_space)
Indeed, as we expected, the output is as follows:
>> Box(4,)
Read now
Unlock full access