Farama-Foundation / Minigrid

Simple and easily configurable grid world environments for reinforcement learning
https://minigrid.farama.org/
Other
2.09k stars 604 forks source link

Wave Function Collapse Environments #371

Closed jysdoran closed 11 months ago

jysdoran commented 1 year ago

Description

This PR is still work in progress.

This PR implements a new feature for Minigrid that allows procedural generation of environments using the Wave Function Collapse algorithm (adapted from this python implementation)

I tried to port the relevant git history of both external repository sources but it has made things a bit messy. Pull requests usually have a squash on merge function so it probably won't affect the main branch but I can go in and try to squash some commits together before then too. Most of the relevant adaptation changes are by me at the end of the commit history.

TODO:

Type of change

Please delete options that are not relevant.

Screenshots

These are some example environments generated by the SimpleMaze preset:

image image

Checklist:

pseudo-rnd-thoughts commented 1 year ago

@jysdoran You need to add imageio to the install_requirement in pyproject.toml

jysdoran commented 1 year ago

@jysdoran You need to add imageio to the install_requirement in pyproject.toml

I added imageio and networkx as optional dependencies under wfc but it must be testing all the registered environments which includes the new maze environment. Is there a way to get the CI system to install those dependencies or skip testing them when the required dependencies aren't installed?

Given that it's just two packages it also makes sense to add them to the main requirements like you say.

pseudo-rnd-thoughts commented 1 year ago

You will need to update the pip install https://github.com/Farama-Foundation/Minigrid/blob/19d68829eb55dc75cf302af4b5cedfc1867b253d/py.Dockerfile#L14 to pip install .[wfc, testing]

jysdoran commented 1 year ago

You will need to update the pip install

https://github.com/Farama-Foundation/Minigrid/blob/19d68829eb55dc75cf302af4b5cedfc1867b253d/py.Dockerfile#L14

to pip install .[wfc, testing]

@pseudo-rnd-thoughts Thanks for the tip, I have updated the dockerfile but it seems to be having trouble identifying the wfc extra. I have tested a local installation with pip install -e .[wfc] which seems work fine with just the toml change. I also noticed these requirements.txt and test_requirements.txt files - would I need one for wfc?

pseudo-rnd-thoughts commented 1 year ago

@jysdoran It looks like there is an issue with the test_wrappers.py, could you see if you can solve it otherwise, could you remove the wfc-environment from the tests

pseudo-rnd-thoughts commented 1 year ago

@jysdoran Hey, how is this going? It seems that the CI failed because RuntimeError: Could not generate a valid pattern within 100 attempts. Could we see if we can resolve this issue along with the two requested changes

Then I think we are close to merging the PR

jysdoran commented 1 year ago

@pseudo-rnd-thoughts, I think everything is passing and should be ready to go. I refactored it such that the environments are registered but the test cases are skipped. I had to add a dummy class to the wfc/__init__.py, let me know if you think there's a better solution because I'm not sure.