Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wave Function Collapse Environments #371

Merged
merged 229 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
229 commits
Select commit Hold shift + click to select a range
1ee7f7b
initial commit
ikarth Oct 13, 2019
5260f40
tiles
ikarth Oct 23, 2019
9b15265
reading tiles from an image
ikarth Oct 25, 2019
64e1301
documenting pattern code
ikarth Oct 25, 2019
d4f3fea
implementing tests
ikarth Oct 25, 2019
da132a8
tests for tile module
ikarth Oct 25, 2019
8a474c9
make linter stop complaining about commas and spaces
ikarth Oct 25, 2019
a571a75
Patterns (hashing numpy change)
ikarth Oct 26, 2019
c48b90a
testing patterns
ikarth Oct 27, 2019
aafc074
output from patterns plus cleanup
ikarth Oct 28, 2019
0893fa8
finished tests
ikarth Oct 28, 2019
0f457e6
started work on adjacency
ikarth Oct 28, 2019
419e0d1
also return pattern grid (needed for adjacency)
ikarth Oct 28, 2019
3fb234a
adjacencies implemented
ikarth Oct 28, 2019
222020b
cleaning up debugging code
ikarth Oct 28, 2019
d16c967
added control code, glued pipeline together
ikarth Oct 29, 2019
fb94545
from patterns back to tiles
ikarth Oct 29, 2019
9a3f17d
gluing pipeline together
ikarth Oct 29, 2019
1eff30f
patterns to tiles
ikarth Oct 31, 2019
4d84d04
hooking up the visualiations
ikarth Oct 31, 2019
1838c99
visualization of output
ikarth Oct 31, 2019
94ff558
adjacency visualization
ikarth Nov 1, 2019
3b125df
change recursive backtracking to loop
ikarth Nov 4, 2019
0f9033a
make loop primary
ikarth Nov 4, 2019
7598099
solver loop test
ikarth Nov 5, 2019
e00f86a
recursion depth
ikarth Nov 5, 2019
6106e93
merge
ikarth Nov 5, 2019
f85cf84
rotations and reflections
ikarth Nov 8, 2019
0399958
load commands from XML
ikarth Nov 8, 2019
897e46a
complete the cycle
ikarth Nov 9, 2019
ab9a3f4
works better if you actually tell it the correct pattern size
ikarth Nov 10, 2019
611335a
pass information about periodicity
ikarth Nov 10, 2019
d076341
add capability to graph call tree
ikarth Nov 10, 2019
552d8b9
output visualizations
ikarth Nov 10, 2019
c2edf67
increase recursion limit to allow larger images
ikarth Nov 10, 2019
712179b
remove debugging print()
ikarth Nov 10, 2019
b15056f
added log and vis directories
ikarth Nov 10, 2019
0393090
improved performance
ikarth Nov 13, 2019
3b55493
researching adjacency issue
ikarth Nov 14, 2019
3e76ed6
ground banning?
ikarth Nov 18, 2019
b591403
it helps if you actually pass the variable to the function
ikarth Nov 18, 2019
c5eaaa3
changing ground banning to a list of patterns to ban
ikarth Nov 18, 2019
ad4afb6
deal with images with more than three channels
ikarth Nov 18, 2019
192cd02
merge
ikarth Nov 18, 2019
174ee70
visualization
ikarth Nov 26, 2019
5da102b
fix transposition
ikarth Nov 26, 2019
e449a0b
added blurry previews
ikarth Nov 27, 2019
9fc88f7
tidying up and testing against reference
ikarth Nov 27, 2019
e707f32
testing entropy heuristic
ikarth Nov 27, 2019
2b75fd0
logging results
ikarth Nov 28, 2019
755b2eb
experiment setup
ikarth Nov 28, 2019
11b4177
fixing syntax errors
ikarth Nov 28, 2019
efba2c3
fixing syntax errors
ikarth Nov 28, 2019
2d223ea
move stat logging init to outer run code
ikarth Nov 28, 2019
446f0bf
change stat logging columns
ikarth Nov 28, 2019
671f3d2
change stat logging columns
ikarth Nov 28, 2019
37888f1
visualization toggle
ikarth Nov 28, 2019
b83dc9e
fix stat reporting bug that prevented solution from being returned
ikarth Nov 28, 2019
a8cb0c0
Merge branch 'master' of https://github.com/ikarth/wfc_2019f
ikarth Nov 28, 2019
c755c3b
allow multiple vis functions
ikarth Nov 29, 2019
dddc98f
add random location heuristic
ikarth Nov 29, 2019
c48782b
improved experiment code
ikarth Nov 29, 2019
e0dbd2a
Merge branch 'master' of https://github.com/ikarth/wfc_2019f
ikarth Nov 29, 2019
46350e0
fix nonetype error on contradiction
ikarth Nov 29, 2019
085f96e
fix contradiction stats reporting
ikarth Nov 29, 2019
a1e2d65
track filename in output log
ikarth Nov 30, 2019
e00ad54
search length limits
ikarth Nov 30, 2019
e6687df
added missing ]
ikarth Nov 30, 2019
469335f
fixed typo
ikarth Nov 30, 2019
0f6dc2b
added missing return statement
ikarth Nov 30, 2019
83bf03d
run full experiment
ikarth Dec 2, 2019
2183df3
properly pass in attempt limit
ikarth Dec 2, 2019
459283f
spirals and space filling curves
ikarth Dec 5, 2019
a1e60c1
experiment to compare spiral etc
ikarth Dec 5, 2019
a8d1877
fixed hilbert
ikarth Dec 7, 2019
5031020
anti-entropy and related experiments
ikarth Dec 8, 2019
dea2d12
resolve conflicts
ikarth Feb 27, 2020
e6b25a7
fix heuristic maker
ikarth Feb 27, 2020
c62f2bb
fix heuristic maker
ikarth Feb 27, 2020
416cb6f
colab file saving
ikarth Mar 2, 2020
09132cc
merge
ikarth Mar 2, 2020
130fa55
Added MostCommonPatternHeuristic()
ikarth Mar 6, 2020
54ed857
Fixed random tiebreaking in rarest/common pattern heuristic
ikarth Mar 7, 2020
f5a6a4f
Format with black
vallsv Jun 7, 2020
7a0507c
Refactor tests with pytest
vallsv Jun 7, 2020
a48a58d
Make the test pass
vallsv Jun 7, 2020
8eeb3ea
Clean up warnings
vallsv Jun 7, 2020
7b6f5fc
Merge pull request #2 from vallsv/rework-project
ikarth Aug 14, 2020
77261ce
fix incorrect wave sum calculation
ikarth Aug 14, 2020
9e8fc32
added more comments to solver
ikarth Jan 13, 2021
243ad52
Fix missing keyword in tests.
HexDecimal Feb 26, 2021
1da1877
Add type annotations to the main functions.
HexDecimal Dec 1, 2021
d5f4cfe
Mark wfc as a typed package.
HexDecimal Dec 1, 2021
2de9ed8
Fix breaking change in hilbertcurve library.
HexDecimal Dec 2, 2021
f3fe89b
Type hint image rendering functions.
HexDecimal Dec 2, 2021
e71e39a
Replace time.time() with better functions.
HexDecimal Dec 4, 2021
9e84f67
Merge pull request #6 from HexDecimal/typing
ikarth Dec 16, 2021
6c69308
Add Solver class and remove recursion from the main solver function.
HexDecimal Dec 6, 2021
16bb45f
Replace print calls with logger calls.
HexDecimal Mar 3, 2022
10d0164
Allow running WFC on images directly.
HexDecimal Mar 3, 2022
1a23276
Use better default parameters for execute_wfc.
HexDecimal Mar 3, 2022
d686d54
Set default tile size to 1.
HexDecimal Mar 4, 2022
e7f2ab2
Log contradictions at the warning level.
HexDecimal Mar 4, 2022
b18b28f
Remove iteration limit constraint.
HexDecimal Mar 4, 2022
eb968d0
Prevent casting pixel data to int64.
HexDecimal Mar 4, 2022
64e14ce
Merge pull request #10 from HexDecimal/frontend
ikarth Mar 5, 2022
a2ca7aa
feat: data generator and data loader implemented
francelico Apr 23, 2022
1aa1ed3
feat: VAE, utils and experiment scripts
francelico Apr 24, 2022
359c368
feat: auto create folder during data generation
francelico May 6, 2022
7d64612
feat: streamlined model and network generation, more control over plo…
francelico May 19, 2022
4103eaf
feat: latent visualisation in tensorboard, new datatransform, wrapped…
francelico May 20, 2022
812d94a
feat: finished tensorboard implementation, need to investigate why no…
francelico May 23, 2022
f63d6d2
feat: generation of multiroom layouts
francelico May 26, 2022
3177c09
feat: now plotting embeddings of generated samples from standard gaus…
francelico May 28, 2022
f04f724
feat: training interruption using keyboard, saving both best test and…
francelico Jun 13, 2022
1eb559e
refac: split MazeDatasetGenerator into GridNavDatasetGenerator and Ba…
francelico Jun 20, 2022
f376116
feat: encode_gridworld_to_grid()
francelico Jun 20, 2022
3916420
feat: encode_grid_to_gridworld(), improved save_dir naming
francelico Jun 21, 2022
1ea1af0
feat: encode_grid_to_gridworld() now handles Tensor inputs, axis orde…
francelico Jun 23, 2022
9e8f936
feat: can now generate datasets with multiple batches
francelico Jun 28, 2022
fba3bf4
refac: remove finished todos
francelico Jun 28, 2022
9398561
feat: encode_gridworld_to_graph()
francelico Jul 1, 2022
5c43d70
feat: reduced_adj encoding/decoding functions
francelico Jul 2, 2022
fd5921f
feat: graph data loader. Issue: runs out of memory (32G) at 9k graph.…
francelico Jul 2, 2022
7d7cbe5
feat: graph dataloader and encode_graph_to_gridworld()
francelico Jul 3, 2022
b669f24
feat: GNN model is running, review later
francelico Jul 4, 2022
25eac10
feat: function to specify allowable permutations in graph space. todo…
francelico Jul 5, 2022
bf9f30e
feat: added features to graph representations, modified encoding func…
francelico Jul 27, 2022
e29bcae
WIP: refactoring of fit_model() to reduce code duplication, started i…
francelico Aug 1, 2022
1373e6d
WIP: carry on implementing multihead GraphDecoder, reverted GraphVAE.…
francelico Aug 3, 2022
7794e6e
feat: finished implementation of GraphVAE and hydra, code running but…
francelico Aug 6, 2022
d786537
feat: GraphVAE class tested for mode 1 (adjacency only) and mode 2 (a…
francelico Aug 7, 2022
4f7ab7f
feat: Pytorch Lightning integration, refactoring of transforms, data_…
francelico Aug 9, 2022
2cc3ea0
feat: implemented ImageLogger callback, logging generated gridworlds …
francelico Aug 10, 2022
dc5a721
feat: implemented probabilistic gridworld layout encoding and heatmap…
francelico Aug 11, 2022
12325b5
fix: reimplemented gridworld_to_img() to have correct colors, and no …
francelico Aug 11, 2022
5bee67e
WIP: refact: dataset generation conf in hydra
francelico Aug 17, 2022
8903dc2
refact: get_batches_metadata() and get_dataset_metadata() implemented…
francelico Aug 17, 2022
812ed14
feats: label descriptors, graph metrics and hydra compatible data gen…
francelico Aug 19, 2022
b1c2090
refact:minor
francelico Aug 19, 2022
e4aa776
refact:minor
francelico Aug 19, 2022
e382d8d
refact: minor logging
francelico Aug 19, 2022
68aad45
feats: logging reconstruction properties, encode_decoder_output_to_gr…
francelico Aug 19, 2022
da8ff10
bugfix: prevent computation of impossible paths as solvable, improved…
francelico Aug 20, 2022
d3e378d
feat: added option to always construct valid & solvable layouts, refa…
francelico Aug 20, 2022
259ae28
fix: force_valid_goal(): prevent goal to be placed on start and minor…
francelico Aug 21, 2022
52ca2df
feat: check_unique() function and logging of uniqueness
francelico Aug 21, 2022
7471fc0
feat: latent interpolation, new logging metrics tested. fix: prevent …
francelico Aug 23, 2022
fb8df4d
fix: various bugfixes ahead of launching slurm experiments
francelico Aug 23, 2022
6af0e1f
refac: a lot more logging to narrow down issue
francelico Aug 24, 2022
318683c
feat: logging level as a parameter, more logging
francelico Aug 24, 2022
3d27d41
fix: more logging, moving arrays to cpu at the start of check_validit…
francelico Aug 24, 2022
e7caa11
fix: bug was due to using the reduced A instead of the full A when ch…
francelico Aug 24, 2022
34bc53d
fix: fixed numerous bugs in training pipeline due to last commit.
francelico Sep 1, 2022
01bdfeb
fix: valid tasks were incorrectly converted to invalid, valid but not…
francelico Sep 2, 2022
890d351
fix: added missing config parameters, removed some log statements, Z …
francelico Sep 6, 2022
155d9b2
feat: ready to run experiments for 15x15 gridworlds
francelico Sep 12, 2022
2807632
feat: encode_gridworld_to_minigrid() and moved Minigrid mappings to u…
francelico Sep 13, 2022
c211bf3
fix:minor
francelico Sep 13, 2022
12ba481
refact: relative_imports.patch applied permanently
francelico Oct 31, 2022
fb2ee3d
feat: implemented and tested minigrid_to_dense_graph(), dense_graph_t…
francelico Nov 6, 2022
2eba7ca
fix: nodes are ordered correctly when building the grid_graph
francelico Nov 6, 2022
375c247
fix: tested and validated all new functions except to_graph() (will b…
francelico Nov 7, 2022
1d4472c
feat: created config files for dense graph encodings
francelico Nov 8, 2022
64c9b35
implementing wave function collapse for data generation, removed draf…
francelico Nov 11, 2022
42a4136
WIP
francelico Nov 15, 2022
192bc0d
feat: finished implementation of WFC, all task structures are generat…
francelico Nov 17, 2022
5cf96a2
feat: graphVAE fully implemented and running with dense encoding
francelico Dec 6, 2022
b974296
feat: implemented multiprocessing for data_generators.py, as well as …
francelico Dec 10, 2022
dc2557f
multiprocessing issues, giving option to not use it at all for now. a…
francelico Dec 23, 2022
78c5d98
Fixed several issues with impl. of graphVAE with dense encoding.
francelico Dec 23, 2022
ce01ec6
minor change of output of wfc_control to make compatible with dataset…
francelico Dec 28, 2022
0e4ad2f
refact: remove dependencies on mazelib
francelico Jan 1, 2023
6cc35b3
fix: implemented a memory efficient mode not generating all layout im…
francelico Jan 13, 2023
d3fd3e3
refac: removed MazeBatch and MultiroomBatch classes
francelico Jan 13, 2023
94d931d
feat: updated data_generators.py and conf/ for very large dataset gen…
francelico Jan 13, 2023
bcd7a21
added unique_data flag in dataset meta
francelico Jan 13, 2023
66beb6b
feat: updated data_generators so that it can be restarted if some bat…
francelico Jan 16, 2023
d8e2fca
feat: now saving batch within each process to avoid too many files op…
francelico Jan 17, 2023
93b3dec
run: replaced ProcessPoolExecutor by BoundedProcessPoolExecutor, cann…
francelico Jan 17, 2023
d214c1c
run: temp hack to ensure we can generate and join datasets in parralel
francelico Jan 17, 2023
d147c01
feat: can now generate subdatasets from an existing dataset
francelico Jan 22, 2023
a279e85
fix: labels are now reset when generating a subdataset
francelico Jan 22, 2023
7a0d599
feat: 101x101 XL tasks generation, to_bitmap() transforms, fix: level…
francelico Jan 24, 2023
e80fb8e
refac: dataset_metadata is now an OmegaConf object and was cleaned up…
francelico Feb 12, 2023
7d60125
refac: removed unused multiprocessing package
francelico Feb 12, 2023
580586e
updated data generation for the escape cave task
francelico Feb 22, 2023
3b50226
feat and refact: updated graphVAE.py to be compatible with CaveEscape…
francelico Mar 7, 2023
78b8300
feat and fix: unit tests for cave escape generation and graph metrics…
francelico Mar 8, 2023
fa81282
feat: conversion of minigrid datasets to cave_escape. fixed several bugs
francelico Mar 9, 2023
31e2e87
refac: unit tests for graph_generation updated, added util functions …
francelico Mar 10, 2023
6c92a12
fix: various bug fixing
francelico Mar 10, 2023
e60043f
feat: finalised ce generation with or without source dataset, run_exp…
francelico Apr 5, 2023
7829c6a
refact: moved assemble_extra_data method to util to simplify imports
francelico Apr 22, 2023
bc8f62a
fix: not passing node_attr to minigrid_to_dense_graph or minigrid_lay…
francelico Apr 26, 2023
22a53f8
refact: split MinigridToCaveEscapeBatch.generate_data() to include a …
francelico Apr 26, 2023
172920f
feat: support for variable moss and lava densities, added various dat…
francelico May 6, 2023
23368fe
feat: calculate distribution metrics
francelico May 12, 2023
46696bd
bugfixes: minor
francelico May 13, 2023
48dd130
Merge relevant commits from 'ikarth/wfc_2019f/main' into wfc-filtered
jysdoran Jun 28, 2023
59a83e6
Merge relevant commits from francelico/maze_representations into wfc-…
jysdoran Jun 28, 2023
d15180a
Modify to integrate with minigrid
jysdoran Jun 28, 2023
a514fa2
Remove visualization and filename from wfclogic
jysdoran Jun 28, 2023
31bbbfe
Refactor to use retrying loop in wfclogic
jysdoran Jun 28, 2023
5d9beef
Randomise agent starting direction
jysdoran Jun 28, 2023
68cba45
Add comments to WFCConfig (and elsewhere)
jysdoran Jun 28, 2023
d14818f
Add optional dependencies to pyproject.toml
jysdoran Jun 28, 2023
7394a32
Refactor wfclogic tests to make imageio optional
jysdoran Jun 29, 2023
fb28958
Add new presets
jysdoran Jun 30, 2023
16ce8f4
Run and fix pre-commit
jysdoran Jun 30, 2023
4448967
Add wfc to CI installation dockerfile
jysdoran Jul 8, 2023
74d0bf1
Rename wfcroom.py because it's not a room like multiroom
jysdoran Jul 8, 2023
f22010f
Move inconsistent presets to their own collection
jysdoran Jul 8, 2023
55743ba
Run pre-commit
jysdoran Jul 8, 2023
d731bd8
Update py.Dockerfile
pseudo-rnd-thoughts Jul 9, 2023
1a1903b
Update pyproject.toml
pseudo-rnd-thoughts Jul 9, 2023
4423e47
Update pyproject.toml
pseudo-rnd-thoughts Jul 9, 2023
a6a9d15
Update pre-commit config to align flake with black formatting
jysdoran Jul 11, 2023
cbe51c1
Merge remote-tracking branch 'origin/wfc-filtered' into wfc-filtered
jysdoran Jul 11, 2023
c08e6ce
Add extra type annotations to hopefully pyright build issues
jysdoran Jul 11, 2023
bfb8f9a
Update config.py
pseudo-rnd-thoughts Jul 12, 2023
b0009b0
Update control.py
pseudo-rnd-thoughts Jul 12, 2023
2a857ca
Add 'maze' to dictwrapper extra words
jysdoran Jul 13, 2023
fe374cc
Merge branch 'wfc-filtered' of github.com:jysdoran/Minigrid into wfc-…
jysdoran Jul 13, 2023
5869e56
Pre-commit formatting
jysdoran Jul 13, 2023
59f2682
Minor polishing changes from code review
jysdoran Jul 22, 2023
456d948
Add docstring citing original python wfc repository
jysdoran Jul 22, 2023
f1bb1e3
Increase WFCEnv max_attempt limit
jysdoran Aug 16, 2023
9f8e238
Refactor tests and imports to throw import error on environment creation
jysdoran Aug 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: flake8
args:
- '--per-file-ignores=*/__init__.py:F401'
# - --ignore=
- --ignore=E203, W503
- --max-complexity=30
- --max-line-length=456
- --show-source
Expand Down
10 changes: 10 additions & 0 deletions minigrid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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

__version__ = "2.3.0"

Expand Down Expand Up @@ -565,6 +566,15 @@ def register_minigrid_envs():
entry_point="minigrid.envs:UnlockPickupEnv",
)

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

# BabyAI - Language based levels - GoTo
# ----------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion minigrid/core/world_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def decode(type_idx: int, color_idx: int, state: int) -> WorldObj | None:
obj_type = IDX_TO_OBJECT[type_idx]
color = IDX_TO_COLOR[color_idx]

if obj_type == "empty" or obj_type == "unseen":
if obj_type == "empty" or obj_type == "unseen" or obj_type == "agent":
return None

# State, 0: open, 1: closed, 2: locked
Expand Down
24 changes: 24 additions & 0 deletions minigrid/envs/wfc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import annotations

from minigrid.envs.wfc.config import (
WFC_PRESETS,
WFC_PRESETS_INCONSISTENT,
WFC_PRESETS_SLOW,
WFCConfig,
)

# This is wrapped in a try-except block so the presets can be accessed for registration
# Otherwise, importing here will fail when networkx is not installed
try:
from minigrid.envs.wfc.wfcenv import WFCEnv
except ImportError:

class WFCEnv:
"""Dummy class to give a helpful error message when dependencies are missing"""

def __init__(self, *args, **kwargs):
from gymnasium.error import DependencyNotInstalled

raise DependencyNotInstalled(
'WFC dependencies are missing, please run `pip install "minigrid[wfc]"`'
)
220 changes: 220 additions & 0 deletions minigrid/envs/wfc/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
from __future__ import annotations

from dataclasses import asdict, dataclass
from pathlib import Path

from typing_extensions import Literal

PATTERN_PATH = Path(__file__).parent / "patterns"


@dataclass
class WFCConfig:
"""Dataclass for holding WFC configuration parameters.

This controls the behavior of the WFC algorithm. The parameters are passed directly to the WFC solver.

Attributes:
pattern_path: Path to the pattern image that will be automatically loaded.
tile_size: Size of the tiles in pixels to create from the pattern image.
pattern_width: Size of the patterns in tiles to take from the pattern image. (greater than 3 is quite slow)
rotations: Number of rotations for each tile.
output_periodic: Whether the output should be periodic (wraps over edges).
input_periodic: Whether the input should be periodic (wraps over edges).
loc_heuristic: Heuristic for choosing the next tile location to collapse.
choice_heuristic: Heuristic for choosing the next tile to use between possible tiles.
backtracking: Whether to backtrack when contradictions are discovered.
"""

pattern_path: Path
tile_size: int = 1
pattern_width: int = 2
rotations: int = 8
output_periodic: bool = False
input_periodic: bool = False
loc_heuristic: Literal[
"lexical", "spiral", "entropy", "anti-entropy", "simple", "random"
] = "entropy"
choice_heuristic: Literal["lexical", "rarest", "weighted", "random"] = "weighted"
backtracking: bool = False

@property
def wfc_kwargs(self):
try:
from imageio.v2 import imread
except ImportError as e:
from gymnasium.error import DependencyNotInstalled

raise DependencyNotInstalled(
'imageio is missing, please run `pip install "minigrid[wfc]"`'
) from e
kwargs = asdict(self)
kwargs["image"] = imread(kwargs.pop("pattern_path"))[:, :, :3]
return kwargs


# Basic presets for WFC configurations (that should generate in <1 min)
WFC_PRESETS = {
jysdoran marked this conversation as resolved.
Show resolved Hide resolved
"MazeSimple": WFCConfig(
pattern_path=PATTERN_PATH / "SimpleMaze.png",
tile_size=1,
pattern_width=2,
output_periodic=False,
input_periodic=False,
),
"DungeonMazeScaled": WFCConfig(
pattern_path=PATTERN_PATH / "ScaledMaze.png",
tile_size=1,
pattern_width=2,
output_periodic=True,
input_periodic=True,
),
"RoomsFabric": WFCConfig(
pattern_path=PATTERN_PATH / "Fabric.png",
tile_size=1,
pattern_width=3,
output_periodic=False,
input_periodic=False,
),
"ObstaclesBlackdots": WFCConfig(
pattern_path=PATTERN_PATH / "Blackdots.png",
tile_size=1,
pattern_width=2,
output_periodic=False,
input_periodic=False,
),
"ObstaclesAngular": WFCConfig(
pattern_path=PATTERN_PATH / "Angular.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"ObstaclesHogs3": WFCConfig(
pattern_path=PATTERN_PATH / "Hogs.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
}

# Presets that take a large number of attempts to generate a consistent environment
WFC_PRESETS_INCONSISTENT = {
"MazeKnot": WFCConfig(
pattern_path=PATTERN_PATH / "Knot.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
), # This is not too inconsistent (often 10 attempts is enough)
"MazeWall": WFCConfig(
pattern_path=PATTERN_PATH / "SimpleWall.png",
tile_size=1,
pattern_width=2,
output_periodic=True,
input_periodic=True,
),
"RoomsOffice": WFCConfig(
pattern_path=PATTERN_PATH / "Office.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"ObstaclesHogs2": WFCConfig(
pattern_path=PATTERN_PATH / "Hogs.png",
tile_size=1,
pattern_width=2,
output_periodic=True,
input_periodic=True,
),
"Skew2": WFCConfig(
pattern_path=PATTERN_PATH / "Skew2.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
}

# Slow presets for WFC configurations (Most take about 2-4 min but some take 10+ min)
WFC_PRESETS_SLOW = {
"Maze": WFCConfig(
pattern_path=PATTERN_PATH / "Maze.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
), # This is unusually slow: ~20min per 25x25 room
"MazeSpirals": WFCConfig(
pattern_path=PATTERN_PATH / "Spirals.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"MazePaths": WFCConfig(
pattern_path=PATTERN_PATH / "Paths.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"Mazelike": WFCConfig(
pattern_path=PATTERN_PATH / "Mazelike.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"Dungeon": WFCConfig(
pattern_path=PATTERN_PATH / "DungeonExtr.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
), # ~10 mins
"DungeonRooms": WFCConfig(
pattern_path=PATTERN_PATH / "Rooms.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"DungeonLessRooms": WFCConfig(
pattern_path=PATTERN_PATH / "LessRooms.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"DungeonSpirals": WFCConfig(
pattern_path=PATTERN_PATH / "SpiralsNeg.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"RoomsMagicOffice": WFCConfig(
pattern_path=PATTERN_PATH / "MagicOffice.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
),
"SkewCave": WFCConfig(
pattern_path=PATTERN_PATH / "Cave.png",
tile_size=1,
pattern_width=3,
output_periodic=False,
input_periodic=False,
),
"SkewLake": WFCConfig(
pattern_path=PATTERN_PATH / "Lake.png",
tile_size=1,
pattern_width=3,
output_periodic=True,
input_periodic=True,
), # ~10 mins
}
Loading