Browse Source

Documentation Update (#261)

Co-authored-by: Mark Towers <mark.m.towers@gmail.com>
Feng 2 years ago
parent
commit
eb9d4f6ee3
73 changed files with 298 additions and 513 deletions
  1. 3 3
      .github/workflows/gh-pages.yml
  2. 2 2
      .gitignore
  3. 0 7
      README.md
  4. 0 9
      docs/.gitignore
  5. 0 0
      docs/_static/figures/BlockedUnlockPickup.png
  6. 0 0
      docs/_static/figures/DistShift1.png
  7. 0 0
      docs/_static/figures/DistShift2.png
  8. 0 0
      docs/_static/figures/KeyCorridorS3R1.png
  9. 0 0
      docs/_static/figures/KeyCorridorS3R2.png
  10. 0 0
      docs/_static/figures/KeyCorridorS3R3.png
  11. 0 0
      docs/_static/figures/KeyCorridorS4R3.png
  12. 0 0
      docs/_static/figures/KeyCorridorS5R3.png
  13. 0 0
      docs/_static/figures/KeyCorridorS6R3.png
  14. 0 0
      docs/_static/figures/LavaCrossingS11N5.png
  15. 0 0
      docs/_static/figures/LavaCrossingS9N1.png
  16. 0 0
      docs/_static/figures/LavaCrossingS9N2.png
  17. 0 0
      docs/_static/figures/LavaCrossingS9N3.png
  18. 0 0
      docs/_static/figures/LavaGapS6.png
  19. 0 0
      docs/_static/figures/ObstructedMaze-1Dl.png
  20. 0 0
      docs/_static/figures/ObstructedMaze-1Dlh.png
  21. 0 0
      docs/_static/figures/ObstructedMaze-1Dlhb.png
  22. 0 0
      docs/_static/figures/ObstructedMaze-1Q.png
  23. 0 0
      docs/_static/figures/ObstructedMaze-2Dl.png
  24. 0 0
      docs/_static/figures/ObstructedMaze-2Dlh.png
  25. 0 0
      docs/_static/figures/ObstructedMaze-2Dlhb.png
  26. 0 0
      docs/_static/figures/ObstructedMaze-2Q.png
  27. 0 0
      docs/_static/figures/ObstructedMaze-4Q.png
  28. 0 0
      docs/_static/figures/SimpleCrossingS11N5.png
  29. 0 0
      docs/_static/figures/SimpleCrossingS9N1.png
  30. 0 0
      docs/_static/figures/SimpleCrossingS9N2.png
  31. 0 0
      docs/_static/figures/SimpleCrossingS9N3.png
  32. 0 0
      docs/_static/figures/Unlock.png
  33. 0 0
      docs/_static/figures/UnlockPickup.png
  34. 0 0
      docs/_static/figures/door-key-curriculum.gif
  35. 0 0
      docs/_static/figures/door-key-env.png
  36. 0 0
      docs/_static/figures/dynamic_obstacles.gif
  37. 0 0
      docs/_static/figures/empty-env.png
  38. 0 0
      docs/_static/figures/fetch-env.png
  39. 0 0
      docs/_static/figures/four-rooms-env.png
  40. 0 0
      docs/_static/figures/gotodoor-6x6.mp4
  41. 0 0
      docs/_static/figures/gotodoor-6x6.png
  42. 0 0
      docs/_static/figures/multi-room.gif
  43. 0 42
      docs/_templates/base.html
  44. 0 207
      docs/_templates/page.html
  45. 0 0
      docs/api/.placeholder
  46. 39 0
      docs/api/wrapper.md
  47. 77 0
      docs/api/wrappers.md
  48. 0 3
      docs/conf.py
  49. 0 0
      docs/content/.placeholder
  50. 1 1
      docs/content/basic_usage.md
  51. 1 1
      docs/content/pubs.md
  52. 0 0
      docs/environments/.placeholder
  53. 46 0
      docs/environments/babyAI_index.md
  54. 39 0
      docs/environments/index.md
  55. 16 11
      docs/index.md
  56. 1 2
      docs/requirements.txt
  57. 0 83
      docs/scripts/gen_index.py
  58. 21 140
      docs/scripts/gen_mds.py
  59. 2 0
      minigrid/envs/blockedunlockpickup.py
  60. 8 0
      minigrid/envs/crossing.py
  61. 5 2
      minigrid/envs/distshift.py
  62. 2 0
      minigrid/envs/doorkey.py
  63. 2 0
      minigrid/envs/dynamicobstacles.py
  64. 2 0
      minigrid/envs/empty.py
  65. 2 0
      minigrid/envs/fetch.py
  66. 2 0
      minigrid/envs/fourrooms.py
  67. 2 0
      minigrid/envs/gotodoor.py
  68. 7 0
      minigrid/envs/keycorridor.py
  69. 2 0
      minigrid/envs/lavagap.py
  70. 2 0
      minigrid/envs/multiroom.py
  71. 10 0
      minigrid/envs/obstructedmaze.py
  72. 2 0
      minigrid/envs/unlock.py
  73. 2 0
      minigrid/envs/unlockpickup.py

+ 3 - 3
.github/workflows/gh-pages.yml

@@ -16,13 +16,13 @@ jobs:
       - uses: actions/setup-python@v4
       - uses: actions/setup-python@v4
 
 
       - name: Install dependencies
       - name: Install dependencies
-        run: pip install -r docs/requirements.txt && git clone https://github.com/Farama-Foundation/MiniGrid.git && pip install ./MiniGrid
+        run: pip install -r docs/requirements.txt
 
 
       - name: Register Envs
       - name: Register Envs
-        run: cd MiniGrid && pip install -e .
+        run: pip install -e .
 
 
       - name: Build Envs Docs
       - name: Build Envs Docs
-        run: python docs/scripts/gen_mds.py && python docs/scripts/gen_index.py
+        run: python docs/scripts/gen_mds.py
 
 
       - name: Build
       - name: Build
         run: sphinx-build -b dirhtml -v docs _build
         run: sphinx-build -b dirhtml -v docs _build

+ 2 - 2
.gitignore

@@ -16,5 +16,5 @@ _site
 __pycache__
 __pycache__
 .vscode/
 .vscode/
 /docs/environments/*.md
 /docs/environments/*.md
-/docs/content/*.md
-/docs/api/*.md
+!docs/environments/index.md
+!docs/environments/babyAI_index.md

+ 0 - 7
README.md

@@ -30,7 +30,6 @@ Please use this bibtex if you want to cite this repository in your publications:
   howpublished = {\url{https://github.com/Farama-Foundation/MiniGrid}},
   howpublished = {\url{https://github.com/Farama-Foundation/MiniGrid}},
 }
 }
 ```
 ```
-<br>
 
 
 List of publications & submissions using Minigrid or BabyAI (please open a pull request to add missing entries):
 List of publications & submissions using Minigrid or BabyAI (please open a pull request to add missing entries):
 - [History Compression via Language Models in Reinforcement Learning.](https://proceedings.mlr.press/v162/paischer22a.html) (Johannes Kepler University Linz, PMLR 2022)
 - [History Compression via Language Models in Reinforcement Learning.](https://proceedings.mlr.press/v162/paischer22a.html) (Johannes Kepler University Linz, PMLR 2022)
@@ -75,7 +74,6 @@ List of publications & submissions using Minigrid or BabyAI (please open a pull
 - [BabyAI: First Steps Towards Grounded Language Learning With a Human In the Loop](https://arxiv.org/abs/1810.08272) (Mila, ICLR, Oct 2018)
 - [BabyAI: First Steps Towards Grounded Language Learning With a Human In the Loop](https://arxiv.org/abs/1810.08272) (Mila, ICLR, Oct 2018)
 
 
 This environment has been built as part of work done at [Mila](https://mila.quebec). The Dynamic obstacles environment has been added as part of work done at [IAS in TU Darmstadt](https://www.ias.informatik.tu-darmstadt.de/) and the University of Genoa for mobile robot navigation with dynamic obstacles.
 This environment has been built as part of work done at [Mila](https://mila.quebec). The Dynamic obstacles environment has been added as part of work done at [IAS in TU Darmstadt](https://www.ias.informatik.tu-darmstadt.de/) and the University of Genoa for mobile robot navigation with dynamic obstacles.
-<br>
 
 
 ## Installation
 ## Installation
 
 
@@ -92,7 +90,6 @@ git clone https://github.com/Farama-Foundation/MiniGrid
 cd MiniGrid
 cd MiniGrid
 pip install -e .
 pip install -e .
 ```
 ```
-<br>
 
 
 ## Basic Usage
 ## Basic Usage
 
 
@@ -119,7 +116,6 @@ A sample training command is:
 cd torch-rl
 cd torch-rl
 python3 -m scripts.train --env MiniGrid-Empty-8x8-v0 --algo ppo
 python3 -m scripts.train --env MiniGrid-Empty-8x8-v0 --algo ppo
 ```
 ```
-<br>
 
 
 ## Wrappers
 ## Wrappers
 
 
@@ -149,7 +145,6 @@ env = RGBImgPartialObsWrapper(env) # Get pixel observations
 env = ImgObsWrapper(env) # Get rid of the 'mission' field
 env = ImgObsWrapper(env) # Get rid of the 'mission' field
 obs, _ = env.reset() # This now produces an RGB tensor only
 obs, _ = env.reset() # This now produces an RGB tensor only
 ```
 ```
-<br>
 
 
 ## Design
 ## Design
 
 
@@ -184,7 +179,6 @@ You can define your own reward function by creating a class derived
 from `MiniGridEnv`. Extending the environment with new object types or new actions
 from `MiniGridEnv`. Extending the environment with new object types or new actions
 should be very easy. If you wish to do this, you should take a look at the
 should be very easy. If you wish to do this, you should take a look at the
 [minigrid/minigrid.py](minigrid/minigrid.py) source file.
 [minigrid/minigrid.py](minigrid/minigrid.py) source file.
-<br>
 
 
 ## Included Environments
 ## Included Environments
 
 
@@ -192,7 +186,6 @@ The environments listed below are implemented in the [minigrid/envs](/minigrid/e
 Each environment provides one or more configurations registered with OpenAI gym. Each environment
 Each environment provides one or more configurations registered with OpenAI gym. Each environment
 is also programmatically tunable in terms of size/complexity, which is useful for curriculum learning
 is also programmatically tunable in terms of size/complexity, which is useful for curriculum learning
 or to fine-tune difficulty.
 or to fine-tune difficulty.
-<br>
 
 
 ### Empty environment
 ### Empty environment
 
 

+ 0 - 9
docs/.gitignore

@@ -1,9 +0,0 @@
-.DS_Store
-_site
-.jekyll-cache
-__pycache__
-_build/
-.vscode/
-
-environments/
-!environments/index.md

docs/_static/img/figures/BlockedUnlockPickup.png → docs/_static/figures/BlockedUnlockPickup.png


docs/_static/img/figures/DistShift1.png → docs/_static/figures/DistShift1.png


docs/_static/img/figures/DistShift2.png → docs/_static/figures/DistShift2.png


docs/_static/img/figures/KeyCorridorS3R1.png → docs/_static/figures/KeyCorridorS3R1.png


docs/_static/img/figures/KeyCorridorS3R2.png → docs/_static/figures/KeyCorridorS3R2.png


docs/_static/img/figures/KeyCorridorS3R3.png → docs/_static/figures/KeyCorridorS3R3.png


docs/_static/img/figures/KeyCorridorS4R3.png → docs/_static/figures/KeyCorridorS4R3.png


docs/_static/img/figures/KeyCorridorS5R3.png → docs/_static/figures/KeyCorridorS5R3.png


docs/_static/img/figures/KeyCorridorS6R3.png → docs/_static/figures/KeyCorridorS6R3.png


docs/_static/img/figures/LavaCrossingS11N5.png → docs/_static/figures/LavaCrossingS11N5.png


docs/_static/img/figures/LavaCrossingS9N1.png → docs/_static/figures/LavaCrossingS9N1.png


docs/_static/img/figures/LavaCrossingS9N2.png → docs/_static/figures/LavaCrossingS9N2.png


docs/_static/img/figures/LavaCrossingS9N3.png → docs/_static/figures/LavaCrossingS9N3.png


docs/_static/img/figures/LavaGapS6.png → docs/_static/figures/LavaGapS6.png


docs/_static/img/figures/ObstructedMaze-1Dl.png → docs/_static/figures/ObstructedMaze-1Dl.png


docs/_static/img/figures/ObstructedMaze-1Dlh.png → docs/_static/figures/ObstructedMaze-1Dlh.png


docs/_static/img/figures/ObstructedMaze-1Dlhb.png → docs/_static/figures/ObstructedMaze-1Dlhb.png


docs/_static/img/figures/ObstructedMaze-1Q.png → docs/_static/figures/ObstructedMaze-1Q.png


docs/_static/img/figures/ObstructedMaze-2Dl.png → docs/_static/figures/ObstructedMaze-2Dl.png


docs/_static/img/figures/ObstructedMaze-2Dlh.png → docs/_static/figures/ObstructedMaze-2Dlh.png


docs/_static/img/figures/ObstructedMaze-2Dlhb.png → docs/_static/figures/ObstructedMaze-2Dlhb.png


docs/_static/img/figures/ObstructedMaze-2Q.png → docs/_static/figures/ObstructedMaze-2Q.png


docs/_static/img/figures/ObstructedMaze-4Q.png → docs/_static/figures/ObstructedMaze-4Q.png


docs/_static/img/figures/SimpleCrossingS11N5.png → docs/_static/figures/SimpleCrossingS11N5.png


docs/_static/img/figures/SimpleCrossingS9N1.png → docs/_static/figures/SimpleCrossingS9N1.png


docs/_static/img/figures/SimpleCrossingS9N2.png → docs/_static/figures/SimpleCrossingS9N2.png


docs/_static/img/figures/SimpleCrossingS9N3.png → docs/_static/figures/SimpleCrossingS9N3.png


docs/_static/img/figures/Unlock.png → docs/_static/figures/Unlock.png


docs/_static/img/figures/UnlockPickup.png → docs/_static/figures/UnlockPickup.png


docs/_static/img/figures/door-key-curriculum.gif → docs/_static/figures/door-key-curriculum.gif


docs/_static/img/figures/door-key-env.png → docs/_static/figures/door-key-env.png


docs/_static/img/figures/dynamic_obstacles.gif → docs/_static/figures/dynamic_obstacles.gif


docs/_static/img/figures/empty-env.png → docs/_static/figures/empty-env.png


docs/_static/img/figures/fetch-env.png → docs/_static/figures/fetch-env.png


docs/_static/img/figures/four-rooms-env.png → docs/_static/figures/four-rooms-env.png


docs/_static/img/figures/gotodoor-6x6.mp4 → docs/_static/figures/gotodoor-6x6.mp4


docs/_static/img/figures/gotodoor-6x6.png → docs/_static/figures/gotodoor-6x6.png


docs/_static/img/figures/multi-room.gif → docs/_static/figures/multi-room.gif


+ 0 - 42
docs/_templates/base.html

@@ -1,42 +0,0 @@
-{% extends "furo/base.html" %}
-
-{%- block regular_scripts -%}
-{{ super() }}
-
-<script>
-    (() => {
-        if (!localStorage.getItem("shownCookieAlert")) {
-            const boxElem = document.createElement("div");
-            boxElem.classList.add("cookie_alert");
-            const containerElem = document.createElement("div");
-            containerElem.classList.add("cookie_container");
-            const textElem = document.createElement("p");
-            textElem.innerHTML = `This page uses <a href="https://analytics.google.com/">
-                                Google Analytics</a> to collect statistics. You can disable it by blocking
-                                the JavaScript coming from www.google-analytics.com.`;
-                                containerElem.appendChild(textElem);
-            const closeBtn = document.createElement("button");
-            closeBtn.innerHTML = `<?xml version="1.0" ?><svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;}</style></defs><title/><g id="cross"><line class="cls-1" x1="7" x2="25" y1="7" y2="25"/><line class="cls-1" x1="7" x2="25" y1="25" y2="7"/></g></svg>`
-            closeBtn.onclick = () => {
-                localStorage.setItem("shownCookieAlert", "true");
-                boxElem.style.display = "none";
-            }
-            containerElem.appendChild(closeBtn);
-            boxElem.appendChild(containerElem);
-            document.body.appendChild(boxElem);
-        }
-    })()
-
-</script>
-
-<!-- Google tag (gtag.js) -->
-<script async src="https://www.googletagmanager.com/gtag/js?id=G-JGXSLW7N06"></script>
-<script>
-  window.dataLayer = window.dataLayer || [];
-  function gtag(){dataLayer.push(arguments);}
-  gtag('js', new Date());
-
-  gtag('config', 'G-JGXSLW7N06');
-</script>
-
-{%- endblock regular_scripts -%}

File diff suppressed because it is too large
+ 0 - 207
docs/_templates/page.html


+ 0 - 0
docs/api/.placeholder


+ 39 - 0
docs/api/wrapper.md

@@ -0,0 +1,39 @@
+---
+title: Wrapper
+lastpage:
+---
+
+## Wrapper
+Wraps an environment to allow a modular transformation of the :meth:`step` and :meth:`reset` methods. This class is the base class for all wrappers. The subclass could override some methods to change the behavior of the original environment without touching the original code. Note: Don't forget to call ``super().__init__(env)`` if the subclass overrides :meth:`__init__`.
+
+MiniGrid is built to support tasks involving natural language and sparse rewards.
+The observations are dictionaries, with an 'image' field, partially observable
+view of the environment, a 'mission' field which is a textual string
+describing the objective the agent should reach to get a reward, and a 'direction'
+field which can be used as an optional compass. Using dictionaries makes it
+easy for you to add additional information to observations
+if you need to, without having to encode everything into a single tensor.
+
+There are a variety of wrappers to change the observation format available in [minigrid/wrappers.py](/minigrid/wrappers.py). 
+If your RL code expects one single tensor for observations, take a look at `FlatObsWrapper`. 
+There is also an `ImgObsWrapper` that gets rid of the 'mission' field in observations, leaving only the image field tensor.
+
+Please note that the default observation format is a partially observable view of the environment using a
+compact and efficient encoding, with 3 input values per visible grid cell, 7x7x3 values total.
+These values are **not pixels**. If you want to obtain an array of RGB pixels as observations instead,
+use the `RGBImgPartialObsWrapper`. You can use it as follows:
+
+```python
+import gymnasium as gym
+from minigrid.wrappers import RGBImgPartialObsWrapper, ImgObsWrapper
+
+env = gym.make('MiniGrid-Empty-8x8-v0')
+env = RGBImgPartialObsWrapper(env) # Get pixel observations
+env = ImgObsWrapper(env) # Get rid of the 'mission' field
+obs, _ = env.reset() # This now produces an RGB tensor only
+```
+
+```{toctree}
+:hidden:
+wrappers
+```

+ 77 - 0
docs/api/wrappers.md

@@ -0,0 +1,77 @@
+---
+title: Wrappers
+tocdepth: 2
+lastpage:
+---
+
+# Action Bonus
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.ActionBonus
+```
+
+# Dict Observation Space
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.DictObservationSpaceWrapper
+```
+
+# Direction Obs
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.DirectionObsWrapper
+```
+
+# FlatObs
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.FlatObsWrapper
+```
+
+# Fully Obs
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.FullyObsWrapper
+```
+
+# Observation
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.ObservationWrapper
+```
+
+# One Hot Partial Obs
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.OneHotPartialObsWrapper
+```
+
+# Reseed
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.ReseedWrapper
+```
+
+# RGB Img Obs
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.RGBImgObsWrapper
+```
+
+# State Bonus
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.StateBonus
+```
+
+# Symbolic Obs
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.SymbolicObsWrapper
+```
+
+# View Size
+
+```{eval-rst}
+.. autoclass:: minigrid.wrappers.ViewSizeWrapper
+```

+ 0 - 3
docs/conf.py

@@ -43,7 +43,6 @@ extensions = [
     "sphinx.ext.autodoc",
     "sphinx.ext.autodoc",
     "sphinx.ext.githubpages",
     "sphinx.ext.githubpages",
     "myst_parser",
     "myst_parser",
-    "notfound.extension",
 ]
 ]
 
 
 source_suffix = {
 source_suffix = {
@@ -90,5 +89,3 @@ html_context["slug"] = "minigrid"
 
 
 html_static_path = ["_static"]
 html_static_path = ["_static"]
 html_css_files = []
 html_css_files = []
-
-notfound_urls_prefix = None

+ 0 - 0
docs/content/.placeholder


+ 1 - 1
docs/content/basic_usage.md

@@ -19,7 +19,7 @@ The environment being run can be selected with the `--env` option, eg:
 ./minigrid/manual_control.py --env MiniGrid-Empty-8x8-v0
 ./minigrid/manual_control.py --env MiniGrid-Empty-8x8-v0
 ```
 ```
 
 
-## Reinforcement Learning
+## Training an Agent
 
 
 If you want to train an agent with reinforcement learning, I recommend using the code found in the [torch-rl](https://github.com/lcswillems/torch-rl) repository. 
 If you want to train an agent with reinforcement learning, I recommend using the code found in the [torch-rl](https://github.com/lcswillems/torch-rl) repository. 
 This code has been tested and is known to work with this environment. The default hyper-parameters are also known to converge.
 This code has been tested and is known to work with this environment. The default hyper-parameters are also known to converge.

+ 1 - 1
docs/content/pubs.md

@@ -3,7 +3,7 @@ layout: "contents"
 title: Publications
 title: Publications
 firstpage:
 firstpage:
 ---
 ---
-#List of Publications
+# List of Publications
 
 
 
 
 List of publications & submissions using Minigrid or BabyAI (please open a pull request to add missing entries):
 List of publications & submissions using Minigrid or BabyAI (please open a pull request to add missing entries):

+ 0 - 0
docs/environments/.placeholder


+ 46 - 0
docs/environments/babyAI_index.md

@@ -0,0 +1,46 @@
+---
+firstpage:
+lastpage:
+---
+
+## BabyAI Environments
+
+```{toctree}
+:hidden:
+:caption: BabyAI Environments
+action_obj_door
+boss_level
+find_obj
+go_to_imp_unlock
+go_to_local
+go_to_obj
+go_to_obj_door
+go_to_obj_maze
+go_to_red_ball
+go_to_red_ball_grey
+go_to_red_ball_no_dists
+go_to_red_blue_ball
+go_to_seq
+key_in_box
+mini_boss_level
+move_two_across
+one_room
+open
+open_door_loc
+open_doors_order
+open_red_blue_doors_debug
+open_red_door
+pickup
+pickup_above
+pickup_dist_debug
+pickup_loc
+put_next
+put_next_local
+synth
+synth_loc
+synth_seq
+unblock_pickup
+unlock_local_dist
+unlock_pickup_dist
+unlock_to_unlock
+```

+ 39 - 0
docs/environments/index.md

@@ -0,0 +1,39 @@
+---
+firstpage:
+lastpage:
+---
+
+## Included Environments
+
+The environments listed below are implemented in the [minigrid/envs](/minigrid/envs) directory.
+Each environment provides one or more configurations registered with OpenAI gym. Each environment
+is also programmatically tunable in terms of size/complexity, which is useful for curriculum learning
+or to fine-tune difficulty.
+
+```{toctree}
+:hidden:
+:caption: Minigrid Environments
+boss_level_no_unlock
+blocked_unlock_pickup
+simple_crossing
+dist_shift
+door_key
+dynamic
+empty
+fetch
+four_rooms
+go_to_door
+go_to_object
+key_corridor
+lava_gap
+locked_room
+memory
+multi_room
+obstructed_maze
+playground
+put_near
+red_blue_doors
+unlock
+unlock_pickup
+
+```

+ 16 - 11
docs/index.md

@@ -3,10 +3,9 @@ hide-toc: true
 firstpage:
 firstpage:
 lastpage:
 lastpage:
 ---
 ---
+## Minigrid (formerly gym-minigrid) contains simple and easily configurable grid world environments for reinforcement learning
 
 
-# MiniGrid is a simple and easily configurable grid world environments for reinforcement learning
-
-[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/)
+[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://pre-commit.com/) 
 [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
 [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
 
 
 There are other gridworld Gymnasium environments out there, but this one is
 There are other gridworld Gymnasium environments out there, but this one is
@@ -17,11 +16,10 @@ laptop, which means you can run your experiments faster. A known-working RL
 implementation can be found [in this repository](https://github.com/lcswillems/torch-rl).
 implementation can be found [in this repository](https://github.com/lcswillems/torch-rl).
 
 
 Requirements:
 Requirements:
-
--   Python 3.7 to 3.10
--   OpenAI Gym v0.26
--   NumPy 1.18+
--   Matplotlib (optional, only needed for display) - 3.0+
+- Python 3.7 to 3.10
+- Gymnasium v0.26
+- NumPy 1.18+
+- Matplotlib (optional, only needed for display) - 3.0+
 
 
 Please use this bibtex if you want to cite this repository in your publications:
 Please use this bibtex if you want to cite this repository in your publications:
 
 
@@ -57,18 +55,25 @@ pip install -e .
 :hidden:
 :hidden:
 :caption: Introduction
 :caption: Introduction
 
 
-content/installation
 content/basic_usage
 content/basic_usage
-api/wrappers
-content/pubs
+content/publications
+```
+
+```{toctree}
+:hidden:
+:caption: Wrappers
+
+api/wrapper
 ```
 ```
 
 
+
 ```{toctree}
 ```{toctree}
 :hidden:
 :hidden:
 :caption: Environments
 :caption: Environments
 
 
 environments/design
 environments/design
 environments/index
 environments/index
+environments/babyAI_index
 ```
 ```
 
 
 ```{toctree}
 ```{toctree}

+ 1 - 2
docs/requirements.txt

@@ -3,5 +3,4 @@ sphinx-notfound-page
 myst-parser
 myst-parser
 git+https://github.com/Farama-Foundation/Celshast#egg=furo
 git+https://github.com/Farama-Foundation/Celshast#egg=furo
 moviepy
 moviepy
-pygame
-pygments==2.11.2
+pygame

+ 0 - 83
docs/scripts/gen_index.py

@@ -1,83 +0,0 @@
-__author__ = "Feng Gu"
-__email__ = "contact@fenggu.me"
-
-"""
-   isort:skip_file
-"""
-
-import os
-
-readme_path = os.path.join(
-    os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
-    "README.md",
-)
-
-output_path = os.path.join(
-    os.path.dirname(os.path.dirname(__file__)),
-    "index.md",
-)
-
-sections = []
-all_text = """---
-hide-toc: true
-firstpage:
-lastpage:
----\n"""
-
-index_toctree = """
-```{toctree}
-:hidden:
-:caption: Introduction
-
-content/installation
-content/basic_usage
-content/pubs
-```
-
-```{toctree}
-:hidden:
-:caption: Wrappers
-
-api/wrappers
-```
-
-
-```{toctree}
-:hidden:
-:caption: Environments
-
-environments/design
-environments/index
-```
-
-```{toctree}
-:hidden:
-:caption: Development
-
-Github <https://github.com/Farama-Foundation/MiniGrid>
-Donate <https://farama.org/donations>
-Contribute to the Docs <https://github.com/Farama-Foundation/MiniGrid/blob/master/.github/PULL_REQUEST_TEMPLATE.md>
-```
-
-"""
-# gen index.md
-with open(readme_path) as f:
-    readme = f.read()
-
-    """
-    sections = [description, publications, installation, basic usage, wrappers, design, included environments&etc]
-    """
-    sections = readme.split("<br>")
-    all_text += sections[0]
-    all_text += sections[2]
-all_text += index_toctree
-
-with open(output_path, "w") as f:
-    f.write(all_text)
-
-
-"""
-1. gen index.md
-2. gen /environments/index.md
-3. gen /environments/design.md
-"""

+ 21 - 140
docs/scripts/gen_mds.py

@@ -1,5 +1,3 @@
-import minigrid.wrappers
-
 __author__ = "Feng Gu"
 __author__ = "Feng Gu"
 __email__ = "contact@fenggu.me"
 __email__ = "contact@fenggu.me"
 
 
@@ -7,13 +5,13 @@ __email__ = "contact@fenggu.me"
    isort:skip_file
    isort:skip_file
 """
 """
 
 
-import inspect
 import os
 import os
 import re
 import re
 
 
 from gymnasium.envs.registration import registry
 from gymnasium.envs.registration import registry
 from tqdm import tqdm
 from tqdm import tqdm
 from utils import trim
 from utils import trim
+from itertools import chain
 
 
 readme_path = os.path.join(
 readme_path = os.path.join(
     os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
     os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
@@ -28,6 +26,7 @@ all_envs = list(registry.values())
 
 
 filtered_envs_by_type = {}
 filtered_envs_by_type = {}
 env_names = []
 env_names = []
+babyai_envs = {}
 
 
 # Obtain filtered list
 # Obtain filtered list
 for env_spec in tqdm(all_envs):
 for env_spec in tqdm(all_envs):
@@ -35,11 +34,18 @@ for env_spec in tqdm(all_envs):
     split = env_spec.entry_point.split(".")
     split = env_spec.entry_point.split(".")
     # ignore gymnasium.envs.env_type:Env
     # ignore gymnasium.envs.env_type:Env
     env_module = split[0]
     env_module = split[0]
-    if env_module != "minigrid":
+
+    if len(split) > 2 and "babyai" in split[2]:
+        curr_babyai_env = split[2]
+        babyai_env_name = curr_babyai_env.split(":")[1]
+        babyai_envs[babyai_env_name] = env_spec
+    elif env_module == "minigrid":
+        env_name = split[1]
+        filtered_envs_by_type[env_name] = env_spec
+    # if env_module != "minigrid":
+    else:
         continue
         continue
 
 
-    env_name = split[1]
-    filtered_envs_by_type[env_name] = env_spec
 
 
 filtered_envs = {
 filtered_envs = {
     env[0]: env[1]
     env[0]: env[1]
@@ -49,7 +55,15 @@ filtered_envs = {
     )
     )
 }
 }
 
 
-for env_name, env_spec in filtered_envs.items():
+filtered_babyai_envs = {
+    env[0]: env[1]
+    for env in sorted(
+        babyai_envs.items(),
+        key=lambda item: item[1].entry_point.split(".")[1],
+    )
+}
+
+for env_name, env_spec in chain(filtered_envs.items(), filtered_babyai_envs.items()):
     made = env_spec.make()
     made = env_spec.make()
 
 
     docstring = trim(made.unwrapped.__doc__)
     docstring = trim(made.unwrapped.__doc__)
@@ -87,136 +101,3 @@ title: {title_env_name}
     file = open(v_path, "w+", encoding="utf-8")
     file = open(v_path, "w+", encoding="utf-8")
     file.write(all_text)
     file.write(all_text)
     file.close()
     file.close()
-
-
-# gen /environments/index.md
-index_texts = """---
-firstpage:
-lastpage:
----
-
-"""
-env_index_toctree = """
-```{toctree}
-:hidden:
-"""
-sections = []
-
-with open(readme_path) as f:
-    readme = f.read()
-
-    """
-    sections = [description, publications, installation, basic usage, wrappers, design, included environments&etc]
-    """
-    sections = readme.split("<br>")
-    index_texts += sections[6]
-    index_texts += env_index_toctree
-
-    for env_name in env_names:
-        index_texts += env_name + "\n"
-
-    index_texts += """\n```\n"""
-    f.close()
-
-output_path = os.path.join(
-    os.path.dirname(os.path.dirname(__file__)),
-    "environments",
-    "index.md",
-)
-
-# output index.md
-with open(output_path, "w+") as f:
-    f.write(index_texts)
-    f.close()
-
-# gen /environments/design.md
-design_path = os.path.join(
-    os.path.dirname(os.path.dirname(__file__)),
-    "environments",
-    "design.md",
-)
-
-design_texts = """---
-layout: "contents"
-title: Design
-firstpage:
----\n"""
-
-design_texts += sections[5]
-
-with open(design_path, "w+") as f:
-    f.write(design_texts)
-    f.close()
-
-
-# gen /environments/wrappers.md
-
-wrappers_path = os.path.join(
-    os.path.dirname(os.path.dirname(__file__)),
-    "api",
-    "wrappers.md",
-)
-
-wrappers_texts = (
-    """---
-title: Wrappers
-lastpage:
----\n"""
-    + sections[4]
-    + "\n"
-)
-
-for name, obj in inspect.getmembers(minigrid.wrappers):
-    if inspect.isclass(obj) and obj.__doc__ is not None:
-        formatted_doc = " ".join(trim(obj.__doc__).split())
-        wrappers_texts += f"""## {name}
-{formatted_doc}\n\n"""
-
-with open(wrappers_path, "w+") as f:
-    f.write(wrappers_texts)
-    f.close()
-
-
-# gen content/pubs.md
-
-pubs_path = os.path.join(
-    os.path.dirname(os.path.dirname(__file__)),
-    "content",
-    "pubs.md",
-)
-
-pubs_texts = (
-    """---
-layout: "contents"
-title: Publications
-firstpage:
----\n#List of Publications\n"""
-    + sections[1]
-    + "\n"
-)
-
-with open(pubs_path, "w+") as f:
-    f.write(pubs_texts)
-    f.close()
-
-# gen content/basic_usage.md
-
-pubs_path = os.path.join(
-    os.path.dirname(os.path.dirname(__file__)),
-    "content",
-    "basic_usage.md",
-)
-
-pubs_texts = (
-    """---
-layout: "contents"
-title: Basic Usage
-firstpage:
----\n"""
-    + sections[3]
-    + "\n"
-)
-
-with open(pubs_path, "w+") as f:
-    f.write(pubs_texts)
-    f.close()

+ 2 - 0
minigrid/envs/blockedunlockpickup.py

@@ -7,6 +7,8 @@ from minigrid.core.world_object import Ball
 class BlockedUnlockPickupEnv(RoomGrid):
 class BlockedUnlockPickupEnv(RoomGrid):
 
 
     """
     """
+    ![BlockedUnlockPickup](../_static/figures/BlockedUnlockPickup.png)
+
     ### Description
     ### Description
 
 
     The agent has to pick up a box which is placed in another room, behind a
     The agent has to pick up a box which is placed in another room, behind a

+ 8 - 0
minigrid/envs/crossing.py

@@ -11,6 +11,14 @@ from minigrid.minigrid_env import MiniGridEnv
 class CrossingEnv(MiniGridEnv):
 class CrossingEnv(MiniGridEnv):
 
 
     """
     """
+    ![LavaCrossingS9N1](../_static/figures/LavaCrossingS9N1.png)<br />
+    ![LavaCrossingS9N2](../_static/figures/LavaCrossingS9N2.png)<br />
+    ![LavaCrossingS9N3](../_static/figures/LavaCrossingS9N3.png)<br />
+    ![LavaCrossingS11N5](../_static/figures/LavaCrossingS11N5.png)<br />
+    ![SimpleCrossingS9N1](../_static/figures/SimpleCrossingS9N1.png)<br />
+    ![SimpleCrossingS9N2](../_static/figures/SimpleCrossingS9N2.png)<br />
+    ![SimpleCrossingS9N3](../_static/figures/SimpleCrossingS9N3.png)<br />
+    ![SimpleCrossingS11N5](../_static/figures/SimpleCrossingS11N5.png)<br />
     ### Description
     ### Description
 
 
     Depending on the `obstacle_type` parameter:
     Depending on the `obstacle_type` parameter:

+ 5 - 2
minigrid/envs/distshift.py

@@ -7,10 +7,13 @@ from minigrid.minigrid_env import MiniGridEnv
 class DistShiftEnv(MiniGridEnv):
 class DistShiftEnv(MiniGridEnv):
 
 
     """
     """
+    ![DistShift1](../_static/figures/DistShift1.png)<br />
+    ![DistShift2](../_static/figures/DistShift2.png)
+
     ### Description
     ### Description
 
 
-    This environment is based on one of the DeepMind [AI safety gridworlds]
-    (https://github.com/deepmind/ai-safety-gridworlds). The agent starts in the
+    This environment is based on one of the DeepMind [AI safety gridworlds](https://github.com/deepmind/ai-safety-gridworlds).
+    The agent starts in the
     top-left corner and must reach the goal which is in the top-right corner,
     top-left corner and must reach the goal which is in the top-right corner,
     but has to avoid stepping into lava on its way. The aim of this environment
     but has to avoid stepping into lava on its way. The aim of this environment
     is to test an agent's ability to generalize. There are two slightly
     is to test an agent's ability to generalize. There are two slightly

+ 2 - 0
minigrid/envs/doorkey.py

@@ -7,6 +7,8 @@ from minigrid.minigrid_env import MiniGridEnv
 class DoorKeyEnv(MiniGridEnv):
 class DoorKeyEnv(MiniGridEnv):
 
 
     """
     """
+    ![door-key-curriculum](../_static/figures/door-key-curriculum.gif)<br />
+    ![door-key-env](../_static/figures/door-key-env.png)
     ### Description
     ### Description
 
 
     This environment has a key that the agent must pick up in order to unlock a
     This environment has a key that the agent must pick up in order to unlock a

+ 2 - 0
minigrid/envs/dynamicobstacles.py

@@ -10,6 +10,8 @@ from minigrid.minigrid_env import MiniGridEnv
 
 
 class DynamicObstaclesEnv(MiniGridEnv):
 class DynamicObstaclesEnv(MiniGridEnv):
     """
     """
+    ![dynamic_obstacles](../_static/figures/dynamic_obstacles.gif)
+
     ### Description
     ### Description
 
 
     This environment is an empty room with moving obstacles.
     This environment is an empty room with moving obstacles.

+ 2 - 0
minigrid/envs/empty.py

@@ -6,6 +6,8 @@ from minigrid.minigrid_env import MiniGridEnv
 
 
 class EmptyEnv(MiniGridEnv):
 class EmptyEnv(MiniGridEnv):
     """
     """
+    ![empty-env](../_static/figures/empty-env.png)
+
     ### Description
     ### Description
 
 
     This environment is an empty room, and the goal of the agent is to reach the
     This environment is an empty room, and the goal of the agent is to reach the

+ 2 - 0
minigrid/envs/fetch.py

@@ -8,6 +8,8 @@ from minigrid.minigrid_env import MiniGridEnv
 class FetchEnv(MiniGridEnv):
 class FetchEnv(MiniGridEnv):
 
 
     """
     """
+    ![fetch-env](../_static/figures/fetch-env.png)
+
     ### Description
     ### Description
 
 
     This environment has multiple objects of assorted types and colors. The
     This environment has multiple objects of assorted types and colors. The

+ 2 - 0
minigrid/envs/fourrooms.py

@@ -7,6 +7,8 @@ from minigrid.minigrid_env import MiniGridEnv
 class FourRoomsEnv(MiniGridEnv):
 class FourRoomsEnv(MiniGridEnv):
 
 
     """
     """
+    ![four-rooms-env](../_static/figures/four-rooms-env.png)
+
     ### Description
     ### Description
 
 
     Classic four room reinforcement learning environment. The agent must
     Classic four room reinforcement learning environment. The agent must

+ 2 - 0
minigrid/envs/gotodoor.py

@@ -7,6 +7,8 @@ from minigrid.minigrid_env import MiniGridEnv
 
 
 class GoToDoorEnv(MiniGridEnv):
 class GoToDoorEnv(MiniGridEnv):
     """
     """
+    ![gotodoor-6x6](../_static/figures/gotodoor-6x6.png)<br />
+    [Video](../_static/figures/gotodoor-6x6.mp4)
     ### Description
     ### Description
 
 
     This environment is a room with four doors, one on each wall. The agent
     This environment is a room with four doors, one on each wall. The agent

+ 7 - 0
minigrid/envs/keycorridor.py

@@ -6,6 +6,13 @@ from minigrid.core.roomgrid import RoomGrid
 class KeyCorridorEnv(RoomGrid):
 class KeyCorridorEnv(RoomGrid):
 
 
     """
     """
+    ![KeyCorridorS3R1](../_static/figures/KeyCorridorS3R1.png)<br />
+    ![KeyCorridorS3R2](../_static/figures/KeyCorridorS3R2.png)<br />
+    ![KeyCorridorS3R3](../_static/figures/KeyCorridorS3R3.png)<br />
+    ![KeyCorridorS4R3](../_static/figures/KeyCorridorS4R3.png)<br />
+    ![KeyCorridorS5R3](../_static/figures/KeyCorridorS5R3.png)<br />
+    ![KeyCorridorS6R3](../_static/figures/KeyCorridorS6R3.png)
+
     ### Description
     ### Description
 
 
     This environment is similar to the locked room environment, but there are
     This environment is similar to the locked room environment, but there are

+ 2 - 0
minigrid/envs/lavagap.py

@@ -9,6 +9,8 @@ from minigrid.minigrid_env import MiniGridEnv
 class LavaGapEnv(MiniGridEnv):
 class LavaGapEnv(MiniGridEnv):
 
 
     """
     """
+    ![LavaGapS6](../_static/figures/LavaGapS6.png)
+
     ### Description
     ### Description
 
 
     The agent has to reach the green goal square at the opposite corner of the
     The agent has to reach the green goal square at the opposite corner of the

+ 2 - 0
minigrid/envs/multiroom.py

@@ -16,6 +16,8 @@ class MultiRoom:
 class MultiRoomEnv(MiniGridEnv):
 class MultiRoomEnv(MiniGridEnv):
 
 
     """
     """
+    ![multi-room](../_static/figures/multi-room.gif)
+
     ### Description
     ### Description
 
 
     This environment has a series of connected rooms with doors that must be
     This environment has a series of connected rooms with doors that must be

+ 10 - 0
minigrid/envs/obstructedmaze.py

@@ -7,6 +7,16 @@ from minigrid.core.world_object import Ball, Box, Key
 class ObstructedMazeEnv(RoomGrid):
 class ObstructedMazeEnv(RoomGrid):
 
 
     """
     """
+    ![ObstructedMaze-1Dl](../_static/figures/ObstructedMaze-1Dl.png)<br />
+    ![ObstructedMaze-1Dlh](../_static/figures/ObstructedMaze-1Dlh.png)<br />
+    ![ObstructedMaze-1Dlhb](../_static/figures/ObstructedMaze-1Dlhb.png)<br />
+    ![ObstructedMaze-1Q](../_static/figures/ObstructedMaze-1Q.png)<br />
+    ![ObstructedMaze-2Dl](../_static/figures/ObstructedMaze-2Dl.png)<br />
+    ![ObstructedMaze-2Dlh](../_static/figures/ObstructedMaze-2Dlh.png)<br />
+    ![ObstructedMaze-2Dlhb](../_static/figures/ObstructedMaze-2Dlhb.png)<br />
+    ![ObstructedMaze-2Q](../_static/figures/ObstructedMaze-2Q.png)<br />
+    ![ObstructedMaze-4Q](../_static/figures/ObstructedMaze-4Q.png)<br />
+
     ### Description
     ### Description
 
 
     The agent has to pick up a box which is placed in a corner of a 3x3 maze.
     The agent has to pick up a box which is placed in a corner of a 3x3 maze.

+ 2 - 0
minigrid/envs/unlock.py

@@ -5,6 +5,8 @@ from minigrid.core.roomgrid import RoomGrid
 class UnlockEnv(RoomGrid):
 class UnlockEnv(RoomGrid):
 
 
     """
     """
+    ![Unlock](../_static/figures/Unlock.png)
+
     ### Description
     ### Description
 
 
     The agent has to open a locked door. This environment can be solved without
     The agent has to open a locked door. This environment can be solved without

+ 2 - 0
minigrid/envs/unlockpickup.py

@@ -6,6 +6,8 @@ from minigrid.core.roomgrid import RoomGrid
 class UnlockPickupEnv(RoomGrid):
 class UnlockPickupEnv(RoomGrid):
 
 
     """
     """
+    ![UnlockPickup](../_static/figures/UnlockPickup.png)
+
     ### Description
     ### Description
 
 
     The agent has to pick up a box which is placed in another room, behind a
     The agent has to pick up a box which is placed in another room, behind a