'How to check out actions available in OpenAI gym environment?

It seems like the list of actions for Open AI Gym environments are not available to check out even in the documentation. For example, let's say you want to play Atari Breakout. The available actions will be right, left, up, and down.

print(env.action_space.n) If I print the number of actions available in action space, it prints 4 as I have expected. However, what I want to see is the list of actions such as right, up, punch(maybe, boxing-v1), jump etc... you name it.

Is there any way to check out?



Solution 1:[1]

This does not work for all environments in gym but it does work for the ALE environments:

import gym
env = gym.make("Breakout-v0")
env.unwrapped.get_action_meanings()

Solution 2:[2]

Here is what I do:

env = gym.make('CartPole-v1')
print(env.action_space.n)    # 2 
print(env.observation_space) # Box(-3.4028234663852886e+38, 3.4028234663852886e+38, (4,), float32)
observation = env.reset()    # n_observation = observation.shape[0] # 8 
help(env.unwrapped)

Solution 3:[3]

It is possible by game where Artati environment had Descrete 18 numbers that you may read from

print(env.env.get_action_meanings())
print(env.action_space.n)

Result:

A.L.E: Arcade Learning Environment (version +978d2ce)
[Powered by Stella]
['NOOP', 'FIRE', 'UP', 'RIGHT', 'LEFT', 'DOWN', 'UPRIGHT', 'UPLEFT', 'DOWNRIGHT', 'DOWNLEFT', 'UPFIRE', 'RIGHTFIRE', 'LEFTFIRE', 'DOWNFIRE', 'UPRIGHTFIRE', 'UPLEFTFIRE', 'DOWNRIGHTFIRE', 'DOWNLEFTFIRE']
Discrete(18)

Sample

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BenedictWilkins
Solution 2 Ali Pardhan
Solution 3 Martijn Pieters