Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwassathish authored Aug 29, 2024
2 parents 12d6533 + 715394f commit 798c696
Show file tree
Hide file tree
Showing 75 changed files with 183 additions and 65 deletions.
9 changes: 6 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ preferred-citation:
given-names: Pablo Samuel
- family-names: Terry
given-names: Jordan
journal: CoRR
title: Minigrid
volume: abs/2306.13831
title: "Minigrid & Miniworld: Modular & Customizable Reinforcement Learning Environments for Goal-Oriented Tasks"
type: inproceedings
year: 2023
conference:
name: "Neural Information Processing Systems (NeurIPS)"
publisher:
name: "Proceedings of the Conference on Neural Information Processing Systems (NeurIPS)"
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<img src="figures/door-key-curriculum.gif" width=200 alt="Figure Door Key Curriculum">
</p>

The Minigrid library contains a collection of discrete grid-world environments to conduct research on Reinforcement Learning. The environments follow the [Gymnasium]() standard API and they are designed to be lightweight, fast, and easily customizable.
The Minigrid library contains a collection of discrete grid-world environments to conduct research on Reinforcement Learning. The environments follow the [Gymnasium](https://github.com/Farama-Foundation/Gymnasium) standard API and they are designed to be lightweight, fast, and easily customizable.

The documentation website is at [minigrid.farama.org](https://minigrid.farama.org/), and we have a public discord server (which we also use to coordinate development work) that you can join here: [https://discord.gg/bnJ6kubTg6](https://discord.gg/bnJ6kubTg6)

Expand Down Expand Up @@ -43,11 +43,11 @@ The original `gym-minigrid` environments were created as part of work done at [M
To cite this project please use:

```bibtex
@article{MinigridMiniworld23,
author = {Maxime Chevalier-Boisvert and Bolun Dai and Mark Towers and Rodrigo de Lazcano and Lucas Willems and Salem Lahlou and Suman Pal and Pablo Samuel Castro and Jordan Terry},
title = {Minigrid \& Miniworld: Modular \& Customizable Reinforcement Learning Environments for Goal-Oriented Tasks},
journal = {CoRR},
volume = {abs/2306.13831},
@inproceedings{MinigridMiniworld23,
author = {Maxime Chevalier{-}Boisvert and Bolun Dai and Mark Towers and Rodrigo Perez{-}Vicente and Lucas Willems and Salem Lahlou and Suman Pal and Pablo Samuel Castro and Jordan Terry},
title = {Minigrid {\&} Miniworld: Modular {\&} Customizable Reinforcement Learning Environments for Goal-Oriented Tasks},
booktitle = {Advances in Neural Information Processing Systems 36, New Orleans, LA, USA},
month = {December},
year = {2023},
}
```
Expand Down
12 changes: 11 additions & 1 deletion docs/_scripts/gen_env_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
filtered_envs_by_type = {}
env_names = []
babyai_envs = {}
wfc_envs = {}

# Obtain filtered list
for env_spec in tqdm(all_envs):
Expand All @@ -32,6 +33,9 @@
curr_babyai_env = split[2]
babyai_env_name = curr_babyai_env.split(":")[1]
babyai_envs[babyai_env_name] = env_spec
elif len(split) > 2 and "wfc" in split[2]:
curr_wfc_env = env_spec.kwargs["wfc_config"]
wfc_envs[curr_wfc_env] = env_spec
elif env_module == "minigrid":
env_name = split[1]
filtered_envs_by_type[env_name] = env_spec
Expand All @@ -56,7 +60,13 @@
)
}

for env_name, env_spec in chain(filtered_envs.items(), filtered_babyai_envs.items()):
# Because they share a class, only the default (MazeSimple) environment should be kept
canonical_wfc_env_name = "MazeSimple"
filtered_wfc_envs = {canonical_wfc_env_name: wfc_envs[canonical_wfc_env_name]}

for env_name, env_spec in chain(
filtered_envs.items(), filtered_babyai_envs.items(), filtered_wfc_envs.items()
):
env = env_spec.make()

docstring = trim(env.unwrapped.__doc__)
Expand Down
33 changes: 31 additions & 2 deletions docs/_scripts/gen_envs_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,41 @@

import gymnasium

# Display bonus WFC presets
from minigrid.envs.wfc import WFCEnv
from minigrid.envs.wfc.config import (
WFC_PRESETS_INCONSISTENT,
WFC_PRESETS_SLOW,
register_wfc_presets,
)
from utils import env_name_format

register_wfc_presets(WFC_PRESETS_INCONSISTENT, gymnasium.register)
register_wfc_presets(WFC_PRESETS_SLOW, gymnasium.register)

# Read name from the actual class so it is updated if the class name changes
WFCENV_NAME = WFCEnv.__name__


def title_from_id(env_id):
words = []
for chunk in env_id.split("_"):
words.extend(env_name_format(chunk).split(" "))

return " ".join(w.title() for w in words)


def create_grid_cell(type_id, env_id, base_path):
# All WFCEnv environments should link to WFCEnv page
href = f"{base_path}{env_id if type_id != 'wfc' else WFCENV_NAME}"
return f"""
<a href="{base_path}{env_id}">
<a href="{href}">
<div class="env-grid__cell">
<div class="cell__image-container">
<img src="/_static/videos/{type_id}/{env_id}.gif">
</div>
<div class="cell__title">
<span>{' '.join(env_id.split('_')).title()}</span>
<span>{title_from_id(env_id)}</span>
</div>
</div>
</a>
Expand Down Expand Up @@ -64,6 +89,10 @@ def generate_page(env, limit=-1, base_path=""):
env_name = split[-1].split(":")[-1]
env_type = env_module if len(split) == 2 else split[-1].split(":")[0]

if env_name == WFCENV_NAME:
env_name = env_spec.kwargs["wfc_config"]
assert isinstance(env_name, str)

if env_module == "minigrid":
if env_type not in type_dict.keys():
type_dict[env_type] = []
Expand Down
6 changes: 6 additions & 0 deletions docs/_scripts/gen_gifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
# iterate through all envspecs
for env_spec in tqdm(gymnasium.envs.registry.values()):
# minigrid.envs:Env or minigrid.envs.babyai:Env
if not isinstance(env_spec.entry_point, str):
continue
split = env_spec.entry_point.split(".")
# ignore minigrid.envs.env_type:Env
env_module = split[0]
env_name = split[-1].split(":")[-1]
env_type = env_module if len(split) == 2 else split[-1].split(":")[0]

# Override env_name for WFC to include the preset name
if env_name == "WFCEnv":
env_name = env_spec.kwargs["wfc_config"]

if env_module == "minigrid" and env_name not in envs_completed:
os.makedirs(os.path.join(output_dir, env_type), exist_ok=True)
path = os.path.join(output_dir, env_type, env_name + ".gif")
Expand Down
4 changes: 3 additions & 1 deletion docs/_scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def trim(docstring):

def env_name_format(str):
# KeyCorridorEnv
split = re.findall(r"[A-Z](?:[a-z]+|[A-Z]*(?=[A-Z]|$))", str)
split = re.findall(r"[A-Z](?:[a-z]+[0-9]*|[A-Z]*[0-9]*(?=[A-Z]|$))", str)
if not split:
split.append(str)
# ['Key', 'Corridor', 'Env']
split = filter(lambda x: x.upper() != "ENV", split)
return " ".join(split)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/Dungeon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/DungeonLessRooms.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/DungeonMazeScaled.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/DungeonRooms.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/DungeonSpirals.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/Maze.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/MazeKnot.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/MazePaths.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/MazeSimple.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/MazeSpirals.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/MazeWall.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/Mazelike.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/ObstaclesAngular.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/ObstaclesBlackdots.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/ObstaclesHogs2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/ObstaclesHogs3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/RoomsFabric.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/RoomsMagicOffice.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/RoomsOffice.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/Skew2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/SkewCave.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/SkewLake.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/videos/wfc/WFCEnv.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/content/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ There is a UI application which allows you to manually control the agent with th
./minigrid/manual_control.py
```

The environment being run can be selected with the `--env` option, eg:
The environment being run can be selected with the `--env-id` option, eg:

```bash
./minigrid/manual_control.py --env MiniGrid-Empty-8x8-v0
./minigrid/manual_control.py --env-id MiniGrid-Empty-8x8-v0
```

## Installation
Expand Down
3 changes: 3 additions & 0 deletions docs/content/publications.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ firstpage:


List of publications & submissions using Minigrid or BabyAI (please open a pull request to add missing entries):
- [DRED: Zero-Shot Transfer in Reinforcement Learning via Data-Regularised Environment Design](https://arxiv.org/abs/2402.03479) (University of Edinburgh, ICML 2024)
- [Conviction-Based Planning for Sparse Reward Reinforcement Learning Problems](https://prl-theworkshop.github.io/prl2024-icaps/papers/8.pdf)(UQÀM, PRL @ ICAPS 2024)
- [Learning from Active Human Involvement through Proxy Value Propagation](https://metadriverse.github.io/pvp/)(UCLA, NeurIPS Spotlight 2023)
- [Go Beyond Imagination: Maximizing Episodic Reachability with World Models](https://arxiv.org/pdf/2308.13661.pdf) (UMich, ICML 2023)
- [Hierarchies of Reward Machines](https://arxiv.org/abs/2205.15752) (Imperial College London, ILASP, Universitat Pompeu Fabra, ICML 2023)
- [Minimal Value-Equivalent Partial Models for Scalable and Robust Planning in Lifelong Reinforcement Learning](https://arxiv.org/abs/2301.10119) (Mila, McGill University, CoLLAs 2023)
- [DEIR: Efficient and Robust Exploration through Discriminative-Model-Based Episodic Intrinsic Rewards](https://arxiv.org/abs/2304.10770) (U-Tokyo, Google Brain, IJCAI 2023)
Expand Down
18 changes: 18 additions & 0 deletions docs/environments/wfc/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
firstpage:
lastpage:
---

## WFC Environments

```{raw} html
:file: list.html
```

```{toctree}
:hidden:
:caption: Wave Function Collapse Environments
WFCEnv
```
11 changes: 6 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ env.close()
To cite this project please use:

```bibtex
@article{MinigridMiniworld23,
author = {Maxime Chevalier-Boisvert and Bolun Dai and Mark Towers and Rodrigo de Lazcano and Lucas Willems and Salem Lahlou and Suman Pal and Pablo Samuel Castro and Jordan Terry},
title = {Minigrid \& Miniworld: Modular \& Customizable Reinforcement Learning Environments for Goal-Oriented Tasks},
journal = {CoRR},
volume = {abs/2306.13831},
@inproceedings{MinigridMiniworld23,
author = {Maxime Chevalier{-}Boisvert and Bolun Dai and Mark Towers and Rodrigo Perez{-}Vicente and Lucas Willems and Salem Lahlou and Suman Pal and Pablo Samuel Castro and Jordan Terry},
title = {Minigrid {\&} Miniworld: Modular {\&} Customizable Reinforcement Learning Environments for Goal-Oriented Tasks},
booktitle = {Advances in Neural Information Processing Systems 36, New Orleans, LA, USA},
month = {December},
year = {2023},
}
```
Expand Down Expand Up @@ -74,6 +74,7 @@ api/wrapper
environments/minigrid/index
environments/babyai/index
environments/wfc/index
```

```{toctree}
Expand Down
9 changes: 2 additions & 7 deletions minigrid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from minigrid import minigrid_env, wrappers
from minigrid.core import roomgrid
from minigrid.core.world_object import Wall
from minigrid.envs.wfc.config import WFC_PRESETS
from minigrid.envs.wfc.config import WFC_PRESETS, register_wfc_presets

__version__ = "2.3.1"

Expand Down Expand Up @@ -568,12 +568,7 @@ def register_minigrid_envs():

# WaveFunctionCollapse
# ----------------------------------------
for name in WFC_PRESETS.keys():
register(
id=f"MiniGrid-WFC-{name}-v0",
entry_point="minigrid.envs.wfc:WFCEnv",
kwargs={"wfc_config": name},
)
register_wfc_presets(WFC_PRESETS, register)

# BabyAI - Language based levels - GoTo
# ----------------------------------------
Expand Down
1 change: 0 additions & 1 deletion minigrid/core/world_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class WorldObj:

"""
Base class for grid world objects
"""
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/core/levelgen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Copied and adapted from https://github.com/mila-iqia/babyai
"""

from __future__ import annotations

from minigrid.core.constants import COLOR_NAMES
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/core/roomgrid_level.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Copied and adapted from https://github.com/mila-iqia/babyai
"""

from __future__ import annotations

from minigrid.core.roomgrid import RoomGrid
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/core/verifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Copied and adapted from https://github.com/mila-iqia/babyai
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/goto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copied and adapted from https://github.com/mila-iqia/babyai.
Levels described in the Baby AI ICLR 2019 submission, with the `Go to` instruction.
"""

from __future__ import annotations

from minigrid.envs.babyai.core.levelgen import LevelGen
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copied and adapted from https://github.com/mila-iqia/babyai.
Levels described in the Baby AI ICLR 2019 submission, with the `Open` instruction.
"""

from __future__ import annotations

from minigrid.core.constants import COLOR_NAMES
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copied and adapted from https://github.com/mila-iqia/babyai.
Levels described in the Baby AI ICLR 2019 submission, with different instructions than those in other files.
"""

from __future__ import annotations

from minigrid.envs.babyai.core.roomgrid_level import RoomGridLevel
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copied and adapted from https://github.com/mila-iqia/babyai.
Levels described in the Baby AI ICLR 2019 submission, with the `Pick up` instruction.
"""

from __future__ import annotations

from minigrid.envs.babyai.core.levelgen import LevelGen
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/putnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copied and adapted from https://github.com/mila-iqia/babyai.
Levels described in the Baby AI ICLR 2019 submission, with the `Put Next` instruction.
"""

from __future__ import annotations

from minigrid.envs.babyai.core.roomgrid_level import RoomGridLevel
Expand Down
1 change: 1 addition & 0 deletions minigrid/envs/babyai/unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copied and adapted from https://github.com/mila-iqia/babyai.
Levels described in the Baby AI ICLR 2019 submission, with the `Unlock` instruction.
"""

from __future__ import annotations

from minigrid.core.constants import COLOR_NAMES
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/blockedunlockpickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class BlockedUnlockPickupEnv(RoomGrid):

"""
## Description
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/crossing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class CrossingEnv(MiniGridEnv):

"""
## Description
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/distshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class DistShiftEnv(MiniGridEnv):

"""
## Description
Expand Down
3 changes: 1 addition & 2 deletions minigrid/envs/doorkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class DoorKeyEnv(MiniGridEnv):

"""
## Description
Expand Down Expand Up @@ -91,7 +90,7 @@ def _gen_grid(self, width, height):
self.place_agent(size=(splitIdx, height))

# Place a door in the wall
doorIdx = self._rand_int(1, width - 2)
doorIdx = self._rand_int(1, height - 2)
self.put_obj(Door("yellow", is_locked=True), splitIdx, doorIdx)

# Place a yellow key on the left side
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class FetchEnv(MiniGridEnv):

"""
## Description
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/fourrooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class FourRoomsEnv(MiniGridEnv):

"""
## Description
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/keycorridor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class KeyCorridorEnv(RoomGrid):

"""
## Description
Expand Down
Loading

0 comments on commit 798c696

Please sign in to comment.