This is an implementation of "Wave Function Collapse" that I wrote in my final semester of school. Wave Function Collapse, at least as far as this program is concerned, is tileset based system where every tile is indeterminate and can intelligently determine all possible tiles that it could be based on its surroundings and adjacency rules. Big thanks to Oskar Stålberg for his procedural generation work in this area.
I went to architecture school, not programming school, so I make no claims about the quality of this code. I don't really remember how it all works and I never intended to publish this.
When running, press Q to show a list of options.
With this particular implementation, there are "modules," which are the individual pieces that can be placed to form the final image, and "slots," which are the places that tiles are placed. You can have as many tiles as you want, and the number of slots is determined by the size of the final image.
Each tile has a numerical ID to each edge. This is how adjacency rules work - these IDs have to match with every neighboring pair of tiles. If a tile has a "1" edge, the tile neighboring that edge also needs a "1" touching it.
Near the top of the code is defined a large array of Module objects. There is an int[] of 4 numbers that defines the edge IDs, then a name for the module (which tells the program what .svg to associate with that module), and finally a number from 0 to 1 which is a weight for the random tile picker. Edges are ordered counter-clockwise, starting on the right.
The particular module set this comes with is something I developed for an installation in Mainframe Studios in Des Moines, Iowa (USA). The patterns were sewn into fabric molds and used for casting large plaster panels. See more: https://www.instagram.com/p/BwqEnkGgK5K/
The provided module set (and all .svg files) in this project are Copyright 2020 Ian Spadin, All Rights Reserved. If you want to use them in a project, contact me.
The code itself and any use of it is provided under CC BY 4.0: https://creativecommons.org/licenses/by/4.0/ (i.e. Do whatever you want with it, but credit me.) Let me know what you make with it, I'd love to see it!