Wave Function Collapse

This little demo project is a loose Godot implementation of Wave Function Collapse algorithm. Wave Function Collapse is an algorithm for procedural generation of images (or levels / meshes / geometry / poetry, etc.) that are locally similar to the input. This implementation uses the tiled model of the algorithm and builds tiles connections automatically by analyzing border pixels colors.

Controls

  • Select width and height of the simulation by using sliders on top-left.
  • Select tiles from the list of tiles to activate them. Active tiles (and their rotations) are used in the simulation. At least two compatible tiles are required for this to work.
  • You can zoom with mouse wheel and pan with middle mouse button.
  • If you ever lose the view you can use Reset View button to get back to the default camera settings.
  • Run/Stop button runs the simulation. There must be at least two compatible tiles selected in order for this to work.
  • Reset button clears the simulation.

Experimental Features

Using "Danger Zone" checkbox you can access some experimental features, like unlocking the grid size limits or providing your own tile images for the simulation.

Note that none of these features were tested and they most likely to cause bugs, crashes, or freeze the application.

If you increased the size of the grid beyond limitations and can't see the simulation, try zooming out until you see it.

If you intend to use custom tile images be aware of the following limitations:

  • File loading is supported only in Windows builds. Web version has no access to your hard drive.
  • Supported file format is PNG
  • Images must be square
  • Images must have the same size. Size of the default tiles is 9x9 px
  • Adjacency rules are formed based on the color of border pixels

Ignoring any of these will most probably drive the application into non-recoverable state. Just reload it.

StatusPrototype
PlatformsHTML5, Windows
Rating
Rated 5.0 out of 5 stars
(3 total ratings)
AuthorThe Game Is Simple
GenreSimulation
Made withGodot
TagsGodot, Procedural Generation, wave-function-collapse
Average sessionA few minutes
LanguagesEnglish
InputsMouse

Download

Download
wave-function-collapse-in-godot-win64.zip 15 MB
Version 1 Sep 04, 2022

Comments

Log in with itch.io to leave a comment.

(+1)

This is really cool! Is the source available anywhere? I've been looking into implementing this myself and would be really interested in seeing how you did this.

Source of this particular implementation is not available, it’s messy, slow and not optimized, and there are still one bug I couldn’t fix.

If you want to implement WFC, I would rather suggest directly porting original source code rather than writing from scratch as I did: https://github.com/mxgmn/WaveFunctionCollapse

That's very reasonable, thank you for the reply! Looking forward to seeing what you do in the future.

(+2)

Running 1,12 & 13  yields an interesting result 

(+1)

You can get a lot of interesting results finding specific combinations.

Providing you own tiles unlock it even further, but it’s a bit unstable :)