OpenAI Documentations


#1

i can’t find the meaning of the methods of the env. For example, what does env.action_space.n mean and from where can i find that out?

I know env.action_space.n is the number of possible actions that can be taken in the environment. But still i can’t find the documentation of the class methods that I’m actually looking for? I’m looking for open ai docs like sklearn and tensorflow has their documentations describing their wrapper functions.


Universe environments
#2

Not to put myself forward as an expert on openai documentation but I came across a link a little while ago which included a neat little program to iterate through the gym registry and print out features of the environments. I added a few features to provide some richer output for for action descriptions. The code is listed below. The output is a pipe-delimited string which pastes nicely into LibreOfficeCalc. The sources for the original program and for the simple enhancements are included as comments in the code listing. Kudos to the original poster. There is also a link to an Atari document which might give some insight to at least Atari environments.

I also found a way to include listings for universe environments, although universe doesn’t provided nearly as much detail for its env features. Maybe just the env_id listing is of some interest. There are over 700 gym environments and about 2K universe environments, which probably gives an indication of how hard it would be to maintain detailed documentation on each environment. Iterating through all these envs took several minutes, even with an I7 quad processor. Commenting out the “import universe” line would shorten the run time considerably, although it still will take some time to run. Lastly there seems to be a lot of overlap between the gym and universe envs. It is TBD whether the richer gym env feature descriptions would apply for similarly named universe envs.

`
import gym
import numpy as np
import universe # loads universe envs into gym registry
                # much less details for universe envs and adds 2K+ envs
                # comment out universe import if uneeded

# mostly combination of links 1 & 2 w/ action_space.sample() simple sampling provided
# 1. https://github.com/openai/gym/issues/106#issuecomment-226675545
# 2. https://ai.stackexchange.com/questions/2449/what-are-different-actions-in-action-space-of-environment-of-pong-v0-game-from
# other refs:
# 3. https://discuss.openai.com/t/is-there-information-on-what-actions-and-observations-really-are/1259
#   esoteric games such as physics games (eg. Ant) don't seem to implement get_action_meanings()
#   can't test w/o getting mujoco trial or paid license
# 4. https://github.com/openai/atari-py/blob/master/doc/manual/manual.pdf

def SampleActionSpace(env):
    env_sample = []
    for i in range(100):
        ass = env.action_space.sample()
        env_sample.append(env.action_space.sample())
    return "[" + str(round(np.min(env_sample), 1)) + "..." + str(round(np.max(env_sample), 1)) + "]"


class NullE:
    def __init__(self):
        self.observation_space = self.action_space = self.reward_range = "N/A"

envall = gym.envs.registry.all()

table = \
    "Environment Id|Observation Space|Action Space|Reward Range|tStepL|Trials|rThresh|Action Meanings\n"

for e in envall:
    action_meanings = "N/A"
    try:
        env = e.make()
        action_meanings = "N/A"
        try:
            action_meanings = env.unwrapped.get_action_meanings()
        except:
            act_space = str(env.action_space)
            if "universe" not in act_space and "Tuple" not in act_space:
                action_meanings = SampleActionSpace(env)
    except:
        env = NullE()
        continue  # Skip these for now
    table += '{}|{}|{}|{}|{}|{}|{}|{}\n'.format(e.id,  # |{}|{}|{}
                                                  env.observation_space, env.action_space, env.reward_range,
                                                  e.timestep_limit, e.trials, e.reward_threshold,
                                                  str(action_meanings))  # ,
print(table)
`