import os import re from collections import defaultdict import gymnasium as gym from gymnasium.envs.registration import find_highest_version, get_env_id from utils import trim filtered_envs = defaultdict(list) exclude_env_names = [ "GymV21Environment", "GymV26Environment", "FrozenLake8x8", "LunarLanderContinuous", "BipedalWalkerHardcore", "phys2d/CartPole", "phys2d/Pendulum", "tabular/Blackjack", "tabular/CliffWalking", ] for env_spec in gym.registry.values(): if get_env_id(env_spec.namespace, env_spec.name, None) not in exclude_env_names: highest_version = find_highest_version(env_spec.namespace, env_spec.name) env_id = get_env_id(env_spec.namespace, env_spec.name, highest_version) env_spec = gym.spec(env_id) if ( isinstance(env_spec.entry_point, str) and "gymnasium" in env_spec.entry_point ): env_module = env_spec.entry_point.split(".")[2] if env_spec not in filtered_envs[env_module]: filtered_envs[env_module].append(env_spec) # print(filtered_envs.keys()) for env_module, env_specs in filtered_envs.items(): env_module_name = env_module.replace("_", " ").title() print(env_module_name) env_specs = sorted(env_specs, key=lambda spec: spec.name) for i, env_spec in enumerate(env_specs): print(f"\t{i=}, {env_spec.name}") env = gym.make(env_spec) env_docstring = trim(env.unwrapped.__doc__) assert env_docstring snake_env_name = re.sub(r"(?