Hacker News new | ask | show | jobs
by linkdd 101 days ago
This is not Wave Function Collapse. This is a constraint solver.

The goal of the original algorithm ( https://github.com/mxgmn/WaveFunctionCollapse ) is to infer the constraints from a sample, and then run a constraint solver.

Hard-coding the constraints skips the whole point of the algorithm (which is also badly named by the way).

3 comments

I didn't want to nitpick terminology, but yes, the tile-placement algorithm here is just a way of solving constraint satisfaction problems with DFS using a "minimum remaining values" heuristic [0]. The original use case for generating textures [1] is different in that the constraints are implicit in the input bitmap, but this project is a more straightforward tile placement with explicit constraints.

I think this algorithm is more efficient for generating maps with only local (adjacency) constraints, but setting this up as an integer linear program and plugging it into a constraint solver is more generalizable (say, if you wanted to enforce a constraint that rivers had to flow across the whole map and could not loop).

But I agree "wave function collapse" is not really the best name, for two reasons:

- the original repository mentions "it doesn't do the actual quantum mechanics, but it was inspired by QM", but it implies something QM-related.

- as an ORIE major in college that loved optimization, I think constraint satisfaction problems are really cool and actually somewhat approachable! So calling the heuristic something else like "wave function collapse" might limit people from finding previous work and known improvements (e.g. forward checking).

[0] https://www.cs.cornell.edu/courses/cs4700/2011fa/lectures/05...

[1] https://github.com/mxgmn/WaveFunctionCollapse

Colloquially this is what gamedevs mean when they refer to WaveFunctionCollapse (though the constraints may or may not be inferred from tiles or 3D models, depending on the implementation). It may not match the academic terminology exactly
Note that the original algorithm is model synthesis. WFC is just a minor tweak on it