Using the Wave Function Collapse Algorithm for Infinite Procedural Cities

Have a look at the concept of a game by Marian where users walk through an infinite city that is procedurally generated as they walk.

Have a look at the concept of a game by Marian where users walk through an infinite city that is procedurally generated as they walk. The whole thing is generated from a set of blocks with the help of the Wave Function Collapse algorithm.

The concept is based on a talk by Oskar Stålberg who used the WFC algorithm to generate levels in Bad North. The algorithm here is said to choose which modules to select for each slot in the world. “The array of slots is considered a wave function in an unobserved state. That means that each slot has a set of possible modules that could be put there. In the language of quantum mechanics, one could say “The slot is in superposition of all modules”. The world starts in a completely unobserved state where every module is possible in any slot,” pointed out the artist. Then, one by one, each slot is collapsed, so one module from the set of possible modules is selected at random. The process is said to be followed by a step of constraint propagation. “For each module, only a subset of modules are allowed to be placed adjacent to it. Whenever a slot is collapsed, the sets of modules that are still possible to be placed in nearby slots need to be updated.”

Make sure to learn more about the project here. You can now download a playable build of the game on itch.io or get the source code on GitHub.

Join discussion

Comments 0

    You might also like

    We need your consent

    We use cookies on this website to make your browsing experience better. By using the site you agree to our use of cookies.Learn more