diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md
index 18229f1bc..8ef0ed409 100644
--- a/.github/ISSUE_TEMPLATE/bug.md
+++ b/.github/ISSUE_TEMPLATE/bug.md
@@ -24,4 +24,4 @@ Add any other context about the problem here.
### Checklist
-- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/MiniGrid/issues) in the repo (**required**)
\ No newline at end of file
+- [ ] I have checked that there is no similar [issue](https://github.com/Farama-Foundation/MiniGrid/issues) in the repo (**required**)
diff --git a/.github/ISSUE_TEMPLATE/proposal.md b/.github/ISSUE_TEMPLATE/proposal.md
index 52d7617e0..3e51601ec 100644
--- a/.github/ISSUE_TEMPLATE/proposal.md
+++ b/.github/ISSUE_TEMPLATE/proposal.md
@@ -6,7 +6,7 @@ title: "[Proposal] Proposal title"
-### Proposal
+### Proposal
A clear and concise description of the proposal.
diff --git a/docker_entrypoint b/.github/docker/docker_entrypoint
old mode 100644
new mode 100755
similarity index 100%
rename from docker_entrypoint
rename to .github/docker/docker_entrypoint
diff --git a/py.Dockerfile b/.github/docker/py.Dockerfile
similarity index 73%
rename from py.Dockerfile
rename to .github/docker/py.Dockerfile
index f51bff278..a964dcb2d 100644
--- a/py.Dockerfile
+++ b/.github/docker/py.Dockerfile
@@ -1,5 +1,7 @@
# A Dockerfile that sets up a full Gym install with test dependencies
ARG PYTHON_VERSION
+ARG GYMNASIUM_VERSION
+ARG NUMPY_VERSION
FROM python:$PYTHON_VERSION
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -8,12 +10,10 @@ RUN apt-get -y update \
&& apt-get install --no-install-recommends -y \
xvfb
-COPY . /usr/local/minigrid/
+COPY ../.. /usr/local/minigrid/
WORKDIR /usr/local/minigrid/
RUN pip install .[wfc,testing] --no-cache-dir
-
-RUN ["chmod", "+x", "/usr/local/minigrid/docker_entrypoint"]
+RUN pip install gymnasium$GYMNASIUM_VERSION numpy$NUMPY_VERSION
ENTRYPOINT ["/usr/local/minigrid/docker_entrypoint"]
-
diff --git a/.github/stale.yml b/.github/stale.yml
index 52d6499f1..9df564020 100644
--- a/.github/stale.yml
+++ b/.github/stale.yml
@@ -59,4 +59,4 @@ only: issues
# issues:
# exemptLabels:
-# - confirmed
\ No newline at end of file
+# - confirmed
diff --git a/.github/workflows/build-docs-dev.yml b/.github/workflows/build-docs-dev.yml
index 194ce26e7..82e393cbf 100644
--- a/.github/workflows/build-docs-dev.yml
+++ b/.github/workflows/build-docs-dev.yml
@@ -46,4 +46,4 @@ jobs:
with:
folder: _build
target-folder: main
- clean: false
\ No newline at end of file
+ clean: false
diff --git a/.github/workflows/build-docs-version.yml b/.github/workflows/build-docs-version.yml
index 631e87271..0d33f1414 100644
--- a/.github/workflows/build-docs-version.yml
+++ b/.github/workflows/build-docs-version.yml
@@ -59,4 +59,4 @@ jobs:
folder: _build
clean-exclude: |
*.*.*/
- main
\ No newline at end of file
+ main
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index 359512921..000000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: build
-on: [pull_request, push]
-
-permissions:
- contents: read
-
-jobs:
- build:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
- steps:
- - uses: actions/checkout@v2
- - run: |
- docker build -f py.Dockerfile \
- --build-arg PYTHON_VERSION=${{ matrix.python-version }} \
- --tag minigrid-docker .
- - name: Run tests
- run: docker run minigrid-docker pytest --ignore tests/test_wfc
- - name: Run doctest
- run: docker run minigrid-docker pytest --doctest-modules minigrid/
diff --git a/.github/workflows/manual-build-docs-version.yml b/.github/workflows/manual-build-docs-version.yml
index a99cba639..7a5e7a1af 100644
--- a/.github/workflows/manual-build-docs-version.yml
+++ b/.github/workflows/manual-build-docs-version.yml
@@ -71,4 +71,4 @@ jobs:
folder: _build
clean-exclude: |
*.*.*/
- main
\ No newline at end of file
+ main
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index a5f32d32b..c804d9a48 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -17,4 +17,4 @@ jobs:
- uses: actions/setup-python@v5
- run: pip install pre-commit
- run: pre-commit --version
- - run: pre-commit run --all-files
\ No newline at end of file
+ - run: pre-commit run --all-files
diff --git a/.github/workflows/build-publish.yml b/.github/workflows/publish.yml
similarity index 100%
rename from .github/workflows/build-publish.yml
rename to .github/workflows/publish.yml
diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml
new file mode 100644
index 000000000..3368c0769
--- /dev/null
+++ b/.github/workflows/pytest.yml
@@ -0,0 +1,37 @@
+name: build
+on: [pull_request, push]
+
+permissions:
+ contents: read
+
+jobs:
+ build-latest:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
+ steps:
+ - uses: actions/checkout@v4
+ - run: |
+ docker build -f .github/docker/py.Dockerfile \
+ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \
+ --build-arg GYMNASIUM_VERSION=">=1.0" \
+ --build-arg NUMPY_VERSION=">=2.0" \
+ --tag minigrid-docker .
+ - name: Run tests
+ run: docker run minigrid-docker pytest
+ - name: Run doctest
+ run: docker run minigrid-docker pytest --doctest-modules minigrid/
+
+ build-old:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - run: |
+ docker build -f .github/docker/py.Dockerfile \
+ --build-arg PYTHON_VERSION="3.10" \
+ --build-arg GYMNASIUM_VERSION="<1.0" \
+ --build-arg NUMPY_VERSION="<2.0" \
+ --tag minigrid-docker .
+ - name: Run tests
+ run: docker run minigrid-docker pytest
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4aa0eefff..25d16b0c6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,17 +1,33 @@
---
repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v5.0.0
+ hooks:
+ - id: check-symlinks
+ - id: destroyed-symlinks
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-yaml
+ - id: check-toml
+ - id: check-ast
+ - id: check-added-large-files
+ - id: check-merge-conflict
+ - id: check-executables-have-shebangs
+ - id: check-shebang-scripts-are-executable
+ - id: detect-private-key
+ - id: debug-statements
- repo: https://github.com/python/black
- rev: 23.12.1
+ rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
- rev: v2.2.6
+ rev: v2.3.0
hooks:
- id: codespell
args:
- --ignore-words-list=linz
- repo: https://github.com/PyCQA/flake8
- rev: 7.0.0
+ rev: 7.1.1
hooks:
- id: flake8
args:
@@ -36,18 +52,18 @@ repos:
# - --convention=google
# additional_dependencies: ["toml"]
- repo: https://github.com/asottile/pyupgrade
- rev: v3.15.0
+ rev: v3.19.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- - repo: local
- hooks:
- - id: pyright
- name: pyright
- entry: pyright
- language: node
- pass_filenames: false
- types: [python]
- additional_dependencies: ["pyright@1.1.383"]
- args:
- - --project=pyproject.toml
+# - repo: local
+# hooks:
+# - id: pyright
+# name: pyright
+# entry: pyright
+# language: node
+# pass_filenames: false
+# types: [python]
+# additional_dependencies: ["pyright@1.1.383"]
+# args:
+# - --project=pyproject.toml
diff --git a/CNAME b/CNAME
deleted file mode 100644
index 2c6659ddf..000000000
--- a/CNAME
+++ /dev/null
@@ -1 +0,0 @@
-minigrid.farama.org
diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst
index f91dd916a..069422654 100644
--- a/CODE_OF_CONDUCT.rst
+++ b/CODE_OF_CONDUCT.rst
@@ -65,4 +65,3 @@ Attribution
-----------
This Code of Conduct is adapted from `Python's Code of Conduct `_, which is under a `Creative Commons License
`_.
-
diff --git a/README.md b/README.md
index 285c195e3..360d7298c 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
-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 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)
@@ -24,7 +24,7 @@ To install the Minigrid library use `pip install minigrid`.
We support Python 3.7, 3.8, 3.9, 3.10 and 3.11 on Linux and macOS. We will accept PRs related to Windows, but do not officially support it.
# Environments
-The included environments can be divided in two groups. The original `Minigrid` environments and the `BabyAI` environments.
+The included environments can be divided in two groups. The original `Minigrid` environments and the `BabyAI` environments.
## Minigrid
The list of the environments that were included in the original `Minigrid` library can be found in the [documentation](https://minigrid.farama.org/environments/minigrid/). These environments have in common a triangle-like agent with a discrete action space that has to navigate a 2D map with different obstacles (Walls, Lava, Dynamic obstacles) depending on the environment. The task to be accomplished is described by a `mission` string returned by the observation of the agent. These mission tasks include different goal-oriented and hierarchical missions such as picking up boxes, opening doors with keys or navigating a maze to reach a goal location. Each environment provides one or more configurations registered with Gymansium. Each environment is also programmatically tunable in terms of size/complexity, which is useful for curriculum learning or to fine-tune difficulty.
@@ -34,7 +34,7 @@ These environments have been imported from the [BabyAI](https://github.com/mila-
natural-looking instructions (e.g. “put the red ball next to the box on your left”) that command the the agent to navigate the world (including unlocking doors) and move objects to specified locations in order to accomplish the task.
# Training an Agent
-The [rl-starter-files](https://github.com/lcswillems/torch-rl) is a repository with examples on how to train `Minigrid` environments with RL algorithms. This code has been tested and is known to work with this environment. The default hyper-parameters are also known to converge.
+The [rl-starter-files](https://github.com/lcswillems/torch-rl) is a repository with examples on how to train `Minigrid` environments with RL algorithms. This code has been tested and is known to work with this environment. The default hyper-parameters are also known to converge.
# Citation
diff --git a/docs/_scripts/gen_env_docs.py b/docs/_scripts/gen_env_docs.py
index 782f44428..cba8e6c4e 100644
--- a/docs/_scripts/gen_env_docs.py
+++ b/docs/_scripts/gen_env_docs.py
@@ -4,17 +4,20 @@
import re
from itertools import chain
-from gymnasium.envs.registration import registry
+import gymnasium
from tqdm import tqdm
+import minigrid
from utils import env_name_format, trim
+gymnasium.register_envs(minigrid)
+
readme_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
"README.md",
)
-all_envs = list(registry.values())
+all_envs = list(gymnasium.registry.values())
filtered_envs_by_type = {}
env_names = []
@@ -120,7 +123,6 @@
|---|---|
| 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}")` |
"""
diff --git a/docs/_scripts/gen_gifs.py b/docs/_scripts/gen_gifs.py
index 60f89aa0c..bdeda04c9 100644
--- a/docs/_scripts/gen_gifs.py
+++ b/docs/_scripts/gen_gifs.py
@@ -7,6 +7,10 @@
from PIL import Image
from tqdm import tqdm
+import minigrid
+
+gymnasium.register_envs(minigrid)
+
# snake to camel case: https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case # noqa: E501
pattern = re.compile(r"(?
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
```
-
diff --git a/docs/release_notes.md b/docs/release_notes.md
index f242b3838..ac465379a 100644
--- a/docs/release_notes.md
+++ b/docs/release_notes.md
@@ -9,4 +9,4 @@ title: Release Notes
:github: https://github.com/Farama-Foundation/Minigrid/releases
:pypi: https://pypi.org/project/minigrid/
:changelog-url:
-```
\ No newline at end of file
+```
diff --git a/minigrid/envs/wfc/wfclogic/control.py b/minigrid/envs/wfc/wfclogic/control.py
index fbb2c6a5b..cc075ff2e 100644
--- a/minigrid/envs/wfc/wfclogic/control.py
+++ b/minigrid/envs/wfc/wfclogic/control.py
@@ -177,9 +177,9 @@ def execute_wfc(
np_random.random(wave.shape[1:]) * 0.1
)
- pattern_heuristic: Callable[
- [NDArray[np.bool_], NDArray[np.bool_]], int
- ] = lexicalPatternHeuristic
+ pattern_heuristic: Callable[[NDArray[np.bool_], NDArray[np.bool_]], int] = (
+ lexicalPatternHeuristic
+ )
if choice_heuristic == "rarest":
pattern_heuristic = makeRarestPatternHeuristic(encoded_weights, np_random)
if choice_heuristic == "weighted":
@@ -188,9 +188,9 @@ def execute_wfc(
pattern_heuristic = makeRandomPatternHeuristic(encoded_weights, np_random)
logger.debug(loc_heuristic)
- location_heuristic: Callable[
- [NDArray[np.bool_]], tuple[int, int]
- ] = lexicalLocationHeuristic
+ location_heuristic: Callable[[NDArray[np.bool_]], tuple[int, int]] = (
+ lexicalLocationHeuristic
+ )
if loc_heuristic == "anti-entropy":
location_heuristic = makeAntiEntropyLocationHeuristic(choice_random_weighting)
if loc_heuristic == "entropy":
diff --git a/minigrid/envs/wfc/wfclogic/tiles.py b/minigrid/envs/wfc/wfclogic/tiles.py
index 87a7e0a0b..9283eaaef 100644
--- a/minigrid/envs/wfc/wfclogic/tiles.py
+++ b/minigrid/envs/wfc/wfclogic/tiles.py
@@ -31,9 +31,7 @@ def image_to_tiles(img: NDArray[np.integer], tile_size: int) -> NDArray[np.integ
return tiles
-def make_tile_catalog(
- image_data: NDArray[np.integer], tile_size: int
-) -> tuple[
+def make_tile_catalog(image_data: NDArray[np.integer], tile_size: int) -> tuple[
dict[int, NDArray[np.integer]],
NDArray[np.int64],
NDArray[np.int64],
diff --git a/minigrid/envs/wfc/wfclogic/utilities.py b/minigrid/envs/wfc/wfclogic/utilities.py
index c90fd4de1..d05c72a72 100644
--- a/minigrid/envs/wfc/wfclogic/utilities.py
+++ b/minigrid/envs/wfc/wfclogic/utilities.py
@@ -67,12 +67,12 @@ def tile_grid_to_image(
# be able to show empty cells.
pixel = tile_catalog[tile][u, v]
# TODO: will need to change if using an image with more than 3 channels
- new_img[
- (i * tile_size[0]) + u, (j * tile_size[1]) + v
- ] = np.resize(
- pixel,
- new_img[
- (i * tile_size[0]) + u, (j * tile_size[1]) + v
- ].shape,
+ new_img[(i * tile_size[0]) + u, (j * tile_size[1]) + v] = (
+ np.resize(
+ pixel,
+ new_img[
+ (i * tile_size[0]) + u, (j * tile_size[1]) + v
+ ].shape,
+ )
)
return new_img
diff --git a/pyproject.toml b/pyproject.toml
index 7e41b2e5c..32f9d6623 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
name = "minigrid"
description = "Minimalistic gridworld reinforcement learning environments."
readme = "README.md"
-requires-python = ">= 3.7"
+requires-python = ">= 3.8"
authors = [{ name = "Farama Foundation", email = "contact@farama.org" }]
license = { text = "MIT License" }
keywords = ["Memory, Environment, Agent, RL, Gymnasium"]
@@ -16,11 +16,11 @@ classifiers = [
"Development Status :: 4 - Beta", # change to `5 - Production/Stable` when ready
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
]
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index b928113c2..000000000
--- a/requirements.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-numpy>=2.0.0
-gymnasium>=1.0.0
-pygame>=2.2.0
diff --git a/test_requirements.txt b/test_requirements.txt
deleted file mode 100644
index 82ede69c5..000000000
--- a/test_requirements.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-pytest>=7.0.1
-pytest-mock>=3.10.0
\ No newline at end of file
diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py
index 8930285d5..182469743 100644
--- a/tests/test_wrappers.py
+++ b/tests/test_wrappers.py
@@ -173,11 +173,13 @@ def test_main_wrappers(wrapper, env_spec):
# DictObservationSpaceWrapper and FlatObsWrapper are not compatible with BabyAI levels
# See minigrid/wrappers.py for more details
pytest.skip()
+
env = env_spec.make()
env = wrapper(env)
- for _ in range(10):
- env.reset()
- env.step(0)
+
+ env.reset(seed=123)
+ env.step(0)
+
env.close()