How do people know about class objects of each environment?


#1

So far I’ve experimented with cartpole and frozen lake. In frozen lake apparently there exists a value in env.observation_space.n and env.action_space.n.
How do people know about stuff like this ?
Also how do people know what values we need to set for action and what values it return ?

Sorry for sounding like a noob but I’ve searched online without much success. Please help


#2

These are usually self-explanatory. E.g., in frozen lake the observation is just the index of the current tile and the action is the desired movement direction.

If it’s hard to guess, it usually helps to perform some actions manually and after each of them output the observation and render the environment to understand what’s going on.


#3

Those are kind of guessable. Where I am confused is the part where people come to know and use “env.observation_space.n”. This is not included anywhere is the documentation and is specific to every environment. For Eg, “env.observation_space.n” is not present in cartpole environment.


#4

Think about observations and actions as about points in space. E.g., if the type of observation_space is Dicrete(16) like in frozen lake, each observation is an integer from 0 to 15 and observation_space.n is how you get the value in the parentheses (16 in this case).

In cart-pole the type of the observation space is Box(4,), thus, its bounds are defined by observation_space.high and observation_space.low instead of observation_space.n. You can find the details in the section on spaces of the documentation.


#5

Cross referencing this post since we have some similar discussions and in case anyone comes across this they’ll be able to read up there.

Long story short, I’ve read the source and used the python ‘dir’ function/method to extract what functions exist on the env variable.