
The Wavefunction Collapse Algorithm Explained - janvdberg
https://robertheaton.com/2018/12/17/wavefunction-collapse-algorithm/
======
rosstex
This seems similar to Constraint Satisfaction Problems.

[https://inst.eecs.berkeley.edu/~cs188/fa18/assets/notes/n2.p...](https://inst.eecs.berkeley.edu/~cs188/fa18/assets/notes/n2.pdf)

~~~
kaveh_h
Yes, but in this case the algorithm would need to figure out the constraints
from preexisting examples and so would you not need to program complex
constraints rules with probabilities by hand?

------
KirinDave
I read this months ago, and the impression I was left with is that this
technique is simply a fancily-named variant of any normal tree-based search
algorithm. You have constraints which can be represented on your search, and
then you attempt to navigate the hyperspace finding a configuration which
matches.

I really can't see how this isn't "wavefunction collapse" and is rather just,
"search."

But I feel like I must be missing something. If this isn't right, can someone
explain to me why it's not right?

------
madhadron
As I commented on the other thread on this article going right now, this is
better known as sampling from Markov random fields. There is a sizeable
literature dating back to the 1960's under that name.

------
erikpukinskis
Somewhat off topic, but one of my absolute favorite YouTube videos is this
[https://youtu.be/p7bzE1E5PMY](https://youtu.be/p7bzE1E5PMY) one by Udiprod
that shows visualizations of wave function collapse, with bite sized,
iterative explanation of all the concepts involved.

~~~
teacpde
Wow amazing simulation, that channel is also full of gold.

------
KennyCason
Very nice and clear write up. Looks like I know what I’m going to be
programming today. I particularly liked your example of how to sample existing
tiles to generate rules.

I’ve been wanting to work on a 2d game world generated off similar constraint
algorithms. But also allow some tiles with high entropy states to be able to
occasionally “flip” and propagate around, thus changing the world dynamically
as you’re walking around.

And I shall name it Wave Function Collapse since it’s clearly not
controversial.

------
tlarkworthy
I started an online interactive port of the original in Observable
[https://beta.observablehq.com/@tomlarkworthy/wave-
function-c...](https://beta.observablehq.com/@tomlarkworthy/wave-function-
collapse)

------
spacehome
Am I being a pedant if I think this algorithm has been misnamed for the
purposes of PR? It just looks like constraint satisfaction. What's quantum
about this? There's no constructive/destructive interference, which to my mind
is the crucial distinction between quantum and classical systems.

~~~
zero_iq
It's simply named only for the analogy with the Copenhagen Interpretation --
everything is in a 'superposition' (all options possible) until a single
'observation' is made, which causes a reduction in the available
possibilities, which propagates across the space/structure. That's as far as
the analogy goes.

This sort of loose analogy is a perfectly reasonable way to name things IMHO.

I don't hear anyone complaining that bubble sort doesn't consider buoyancy and
surface tension, or that the flood fill algorithm doesn't involve any actual
fuid dynamics.

I have my own theory on why people like to complain about this particular
analogy, but for the sake of not causing offence I will leave it there ;p

~~~
pizza
I think people are saying that the algorithm isn't cool enough for its name.

Bubbles aren't cool, so bubble sort must be rightly chided. /s

Quantum physics? Now that's cool, regardless of how much one knows about it.

I don't think the reason gets much deeper than that, barring any disagreements
that it is just plain misleading.

I guess you could argue to some degree that a name should be usefully
informative to an outsider or newbie. But that doesn't really apply to things
that have already established their cool factor, like 'deep learning',
'crypto', 'agile', 'serverless', etc..

~~~
Retra
I would object to the name on the basis of it influencing a misleading
association. A person's brain will jump from one idea to the next based on
familiar recall, and when people can't 'jump' to the correct association
because their brain is filled with bad ideas that have nothing to do with the
topic, then we all suffer for having to defend against it.

------
HoppyHaus
For how simple WFC seems to be portrayed, the only reference I can find is for
use in other code. Is there any simple, but still code, examples of this? Or
is it always quite a bit of work to get going?

~~~
BorisTheBrave
You might want to try my project DeBroglie
([https://boristhebrave.github.io/DeBroglie/](https://boristhebrave.github.io/DeBroglie/)).

It comes with a console application that runs WFC based on JSON config files,
so you can experiment with generation without writing any code.

------
elliot07
Great explanation.

Think it went over the basics a _bit_ too much. Would’ve liked to see a bit
more in depth. Great write up nonetheless.

------
meta_AU
The algorithm for the first example reads just like an implementation of a SAT
solver. Set a variable, propogate clauses, backtrack on conflict (learn new
'rule' from conflict).

------
klyrs
Neat. I wrote an algorithm very much like this... I mean, sure, it's just a
greedy search over a contraint-satisfaction problem... but I love the name and
I'm gonna use it.

------
buboard
is this even an efficient way to calculate possible arrangements of collapsed
quantum systems?

~~~
whatshisface
The algorithm is not related to quantum mechanics, although is is very cool.
Technically, before "collapse" what is there is a probably distribution
function, not a wavefunction.

------
ewngzen
I have no idea what this article is explaining

