How to check out actions available in OpenAI gym environment?

4.1k views Asked by At

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?

3

There are 3 answers

0
BenedictWilkins On

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()
0
Ali Pardhan On

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)
0
Jirayu Kaewprateep On

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)