I have made a WFC Algorithm not too dissimilar from this one https://www.youtube.com/watch?v=vjR5eCqT5yM. It takes in a set of tiles, weights for those tiles, and world conditions to generate a random rectangular world.
Using said set of tiles and weights, this was made.
There are edge cases where no tile can fit into a space, this is a fault of the tiles, none can fit in there. This is not a problem with the algorithm.
I invite Anyone to play around with it.
Wave Function Collapse.rbxl (61.2 KB)
If anyone has any insight on how to make the world less random, or stringy (I don’t like the grass randomly cutting through everything) Please share them with me.
General how it works
After making a world it choses a random part. Said part gets chosen from the list of possible parts weighted so some parts have a better than even chance to get chosen. After choosing, it checks to see if a part can fit next to it, if it cant, it is removed (this is how the edge cases happen). Then it choses a random part with the lowest amount of possible parts.
In Depth
Each side of a part has a name, checking which part fits looks at weather the bordering sides share a name, if they don’t, then they cant fit next to one another. Deserts cant be next to mountains, but deserts can be next to a desert mountain transition tile.
How the script decides when to remove a tile is strange. It would be nice to have a mountain next to a desert, reducing the amount of transition tiles needed. It needs to be worked on. Insights appreciated.
The itemlookup and weights module scripts contain dictionaries that are based upon the names of the tiles. and the itemlookup’s arrays are in order east,north,west,south. (it contains the side names)