|
@@ -1,29 +1,19 @@
|
|
|
-__author__ = "Feng Gu"
|
|
|
-__email__ = "contact@fenggu.me"
|
|
|
-
|
|
|
-"""
|
|
|
- isort:skip_file
|
|
|
-"""
|
|
|
+from __future__ import annotations
|
|
|
|
|
|
import os
|
|
|
import re
|
|
|
+from itertools import chain
|
|
|
|
|
|
from gymnasium.envs.registration import registry
|
|
|
from tqdm import tqdm
|
|
|
-from utils import trim
|
|
|
-from itertools import chain
|
|
|
|
|
|
-from utils import env_name_format
|
|
|
+from utils import env_name_format, trim
|
|
|
|
|
|
readme_path = os.path.join(
|
|
|
os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
|
|
|
"README.md",
|
|
|
)
|
|
|
|
|
|
-LAYOUT = "env"
|
|
|
-
|
|
|
-pattern = re.compile(r"(?<!^)(?=[A-Z])")
|
|
|
-
|
|
|
all_envs = list(registry.values())
|
|
|
|
|
|
filtered_envs_by_type = {}
|
|
@@ -67,9 +57,9 @@ filtered_babyai_envs = {
|
|
|
}
|
|
|
|
|
|
for env_name, env_spec in chain(filtered_envs.items(), filtered_babyai_envs.items()):
|
|
|
- made = env_spec.make()
|
|
|
+ env = env_spec.make()
|
|
|
|
|
|
- docstring = trim(made.unwrapped.__doc__)
|
|
|
+ docstring = trim(env.unwrapped.__doc__)
|
|
|
|
|
|
# minigrid.envs:Env or minigrid.envs.babyai:Env
|
|
|
split = env_spec.entry_point.split(".")
|
|
@@ -95,11 +85,13 @@ for env_name, env_spec in chain(filtered_envs.items(), filtered_babyai_envs.item
|
|
|
|
|
|
formatted_env_name = env_name_format(env_name)
|
|
|
|
|
|
+ # Front matter
|
|
|
front_matter = f"""---
|
|
|
autogenerated:
|
|
|
title: {formatted_env_name}
|
|
|
---
|
|
|
"""
|
|
|
+ # Title and gif
|
|
|
title = f"# {formatted_env_name}"
|
|
|
gif = (
|
|
|
"```{figure} "
|
|
@@ -110,6 +102,19 @@ title: {formatted_env_name}
|
|
|
"""
|
|
|
)
|
|
|
|
|
|
+ # Environment attributes
|
|
|
+ action_space_table = env.action_space.__repr__().replace("\n", "")
|
|
|
+ observation_space_table = env.observation_space.__repr__().replace("\n", "")
|
|
|
+ env_attributes = f"""
|
|
|
+| | |
|
|
|
+|---|---|
|
|
|
+| Action Space | `{re.sub(' +', ' ', action_space_table)}` |
|
|
|
+| Observation Space | `{re.sub(' +', ' ', observation_space_table)}` |
|
|
|
+| Reward Range | `{env.reward_range}` |
|
|
|
+| Creation | `gymnasium.make("{env_spec.id}")` |
|
|
|
+"""
|
|
|
+
|
|
|
+ # Create Markdown file content
|
|
|
if docstring is None:
|
|
|
docstring = "No information provided"
|
|
|
all_text = f"""{front_matter}
|
|
@@ -118,6 +123,8 @@ title: {formatted_env_name}
|
|
|
|
|
|
{gif}
|
|
|
|
|
|
+{env_attributes}
|
|
|
+
|
|
|
{docstring}
|
|
|
"""
|
|
|
file = open(v_path, "w+", encoding="utf-8")
|