In a gym environment, the action space is often a discrete space, where each action is labeled by an integer. I cannot find a way to figure out the correspondence between action and number. For example, in frozen lake, the agent can move Up, Down, Left or Right. The code:

import gym
env = gym.make("FrozenLake-v0")

returns Discrete(4), showing that four actions are available. If I env.step(0), which direction is my agent moving?


There is no way to tell via the Gym API, and to any RL-based learning agent this is entirely unimportant, discrete actions are just arbitrary labels, and their effects are learned by trial and error in terms of reward and changes to state.

If you need to know, you can read the code for each environment. Often it is described in a comment, or as constants.

E.g. in FrozenLake-v0, you can find this code:

LEFT = 0
DOWN = 1
UP = 3

If I env.step(0), which direction is my agent moving?

Left, according to those constant names at least.


Not the answer you're looking for? Browse other questions tagged or ask your own question.