Answers.Body: <p>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.</p>
  <p>If you need to know, you can read the code for each environment. Often it is described in a comment, or as constants.</p>
  <p>E.g. in FrozenLake-v0, <a href="https://github.com/openai/gym/blob/master/gym/envs/toy_text/frozen_lake.py#L10-L13" rel="nofollow noreferrer">you can find this code</a>:</p>
  <pre><code>LEFT = 0
  DOWN = 1
  RIGHT = 2
  UP = 3
  </code></pre>
  <blockquote>
  <p>If I <code>env.step(0)</code>, which direction is my agent moving?</p>
  </blockquote>
  <p>Left, according to those constant names at least.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-01T22:16:14.270Z
Answers.LastActivityDate: 2021-06-15T08:17:17.380Z
Answers.LastEditDate: 2021-06-15T08:17:17.380Z
Answers.UserDisplayName: Neil Slater
Body: <p>In a <code>gym</code> 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:</p>
  
  <pre><code>import gym
  env = gym.make("FrozenLake-v0")
  env.action_space
  </code></pre>
  
  <p>returns <code>Discrete(4)</code>, showing that four actions are available. If I <code>env.step(0)</code>, which direction is my agent moving?</p>
  
Tags: <reinforcement-learning><gym>
Title: What is the mapping between actions and numbers in OpenAI's gym?
UserDisplayName: Llewlyn
ThreadText: # What is the mapping between actions and numbers in OpenAI's gym?
  
  (Asked by: username_0 on 2018-11-01)
  
  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")
  env.action_space
  
  returns Discrete(4), showing that four actions are available. If I env.step(0), which direction is my agent moving?
  
  **Tags:** reinforcement-learning, gym
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-01. Score: 2 | Accepted answer
  
  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
  RIGHT = 2
  UP = 3
  
  
  If I env.step(0), which direction is my agent moving?
  
  Left, according to those constant names at least.
  
  
  ---
  
  