<p>You can try to figure out what exactly does an action do using such script:</p>

<pre><code>action = 0  # modify this!
o = env.reset()
for i in xrange(5): # repeat one action for five times
    o = env.step(action)[0]
IPython.display.display(
    Image.fromarray(
        o[:,140:142]  # extract your bat
    ).resize((300, 300))  # bigger image, easy for visualization
)
</code></pre>

<p><code>action</code> 0 and 1 seems useless, as nothing happens to the racket.</p>

<p><code>action</code> 2 &amp; 4 makes the racket go up, and <code>action</code> 3 &amp; 5 makes the racket go down.</p>

<p>The interesting part is, when I run the script above for the same <code>action</code>(from 2 to 5) two times, I have different results. Sometimes the racket reaches the top(bottom) border, and sometimes it doesn't. I think there might be some randomness on the speed of the racket, so it might be hard to measure which type of UP(2 or 4) is faster.</p>

CC BY-SA 3.0
2017-02-08T02:29:23.717Z
2017-02-08T02:29:23.717Z
Icyblade
<p>There seems to be no difference between 2 &amp; 4 and 3 &amp; 5. The inconsistency mentioned by Icyblade is due to the mechanics of the Pong environment.</p>

<p>"Each action is repeatedly performed for a duration of k frames, where k is uniformly sampled from {2,3,4}" </p>

<p>So the action is just repeated a different number of times due to randomness</p>

CC BY-SA 3.0
2017-06-01T19:47:39.513Z
2017-06-01T19:47:39.513Z
jaidmin
<p>You can try the actions yourselves, but if you want another reference, <a href="https://github.com/openai/atari-py/blob/master/doc/manual/manual.pdf" rel="noreferrer">check out the documentation for ALE at GitHub</a>.</p>

<p>In particular, 0 means no action, 1 means fire, which is why they don't have an effect on the racket.</p>

<p>Here's a better way:</p>

<pre><code>env.unwrapped.get_action_meanings()
</code></pre>

CC BY-SA 3.0
2017-06-28T18:24:38.567Z
2017-07-23T20:45:52.550Z
2017-07-23T20:45:52.550Z
ComputerScientist
<p>Printing <code>action_space</code> for Pong-v0 gives <code>Discrete(6)</code> as output, i.e. <span class="math-container">$0, 1, 2, 3, 4, 5$</span> are actions defined in the environment as per the documentation. However, the game needs only 2 controls. Why do we have this discrepancy? Further, is that necessary to identify which number from 0 to 5 corresponds to which action in a gym environment?</p>

CC BY-SA 4.0
2020-11-25T11:05:11.280Z
Programming questions (including how to use a certain library or API) are off-topic here. This type of question is more appropriate for Stack Overflow, even though the question is still related to Artificial Intelligence/Reinforcement Learning. Here, we focus on the theoretical, social, and philosophical aspects of AI. Please, see https://ai.stackexchange.com/help/on-topic for more details.
nbro
<reinforcement-learning><environment><gym><action-spaces>
What do the different actions of the OpenAI gym's environment of 'Pong-v0' represent?
cur10us
# What do the different actions of the OpenAI gym's environment of 'Pong-v0' represent?

(Asked by: username_0 on 2016-12-10)

Printing `action_space` for Pong-v0 gives `Discrete(6)` as output, i.e. $0, 1, 2, 3, 4, 5$ are actions defined in the environment as per the documentation. However, the game needs only 2 controls. Why do we have this discrepancy? Further, is that necessary to identify which number from 0 to 5 corresponds to which action in a gym environment?

**Tags:** reinforcement-learning, environment, gym, action-spaces

> **Comments:**
> **username_1**: Programming questions (including how to use a certain library or API) are off-topic here. This type of question is more appropriate for Stack Overflow, even though the question is still related to Artificial Intelligence/Reinforcement Learning. Here, we focus on the theoretical, social, and philosophical aspects of AI. Please, see https://ai.stackexchange.com/help/on-topic for more details.  

---

## 3 answers

### Answer by username_4 on 2017-06-28. Score: 8

You can try the actions yourselves, but if you want another reference, check out the documentation for ALE at GitHub.
In particular, 0 means no action, 1 means fire, which is why they don't have an effect on the racket.
Here's a better way:
env.unwrapped.get_action_meanings()


---

### Answer by username_2 on 2017-02-08. Score: 4

You can try to figure out what exactly does an action do using such script:
action = 0  # modify this!
o = env.reset()
for i in xrange(5): # repeat one action for five times
    o = env.step(action)[0]
IPython.display.display(
    Image.fromarray(
        o[:,140:142]  # extract your bat
    ).resize((300, 300))  # bigger image, easy for visualization
)

action 0 and 1 seems useless, as nothing happens to the racket.
action 2 & 4 makes the racket go up, and action 3 & 5 makes the racket go down.
The interesting part is, when I run the script above for the same action(from 2 to 5) two times, I have different results. Sometimes the racket reaches the top(bottom) border, and sometimes it doesn't. I think there might be some randomness on the speed of the racket, so it might be hard to measure which type of UP(2 or 4) is faster.


---

### Answer by username_3 on 2017-06-01. Score: 3

There seems to be no difference between 2 & 4 and 3 & 5. The inconsistency mentioned by username_2 is due to the mechanics of the Pong environment.

"Each action is repeatedly performed for a duration of k frames, where k is uniformly sampled from {2,3,4}"

So the action is just repeated a different number of times due to randomness


---

