The “Wavefunction Collapse” generation algorithm explained clearly (2018)
robertheaton.com
robertheaton.com
The original author of "wave function collapse" also has "convchain" [0] which is similarly "just" using Monte Carlo Markov Chains to sample the space. It's also a kind of "staple" algorithm for physicists, theoretical computer scientists, etc but I guess hasn't caught on as much as WFC.
Note that WFC has major problems when the tile set is too constrained. There's a SO question about it [1] and I also happen to have written a small article about it as well [2]().
[0] https://github.com/mxgmn/ConvChain
[1] https://stackoverflow.com/questions/72721299/why-can-the-wav...
[2] https://www.fxhash.xyz/article/lessons-learned-from-implemen...
() trigger warning, it's an NFT but please don't let that stop you from reading
This is not to say that people don't do this or make compromises like running it multiple times, if it fails, but Norvig's solution is doing proper search.
For those reasons I still liked the article.
But the idea of extracting constraints from a sample images and using those to generate variants is neat.
Here's a nice presentation from him explaining it: https://www.youtube.com/watch?v=0bcZb-SsnrA
The Wavefunction Collapse Algorithm Explained - https://news.ycombinator.com/item?id=18744696 - Dec 2018 (44 comments)
The Wavefunction Collapse Algorithm explained - https://news.ycombinator.com/item?id=18742295 - Dec 2018 (3 comments)
Infinite procedurally-generated city with the Wave Function Collapse algorithm - https://news.ycombinator.com/item?id=18443311 - Nov 2018 (141 comments)
Show HN: Wave function collapse algorithm - https://news.ycombinator.com/item?id=12612246 - Sept 2016 (122 comments)
[0] https://www.gamedeveloper.com/blogs/how-townscaper-works-a-s... [1] https://news.ycombinator.com/item?id=31799818
Unfortunately I could never really get it to be fast enough. There are an enormous number of tiles in StarCraft, 15,000+ for some tilesets, and people want to generate maps of up to 256x256 tiles. This is a huge state space and under these conditions the algorithm very often gets stuck in a local minima. I've tried so many different heuristics to get it to work but it doesn't work reliably enough to be a truly useful tool in this situation unfortunately.
There are many explanations out there about how this algorithm works, more so than many other algorithms. I think the reason for that is because from hearing the basic high level idea of this algorithm most people are able to then go and implement it and then that makes for an interesting blog post (I could do the same after implementing, I think). What almost all of these blog posts are missing is how to make it fast, and how to implement back tracking efficiently. I had to try a lot of things to get to where I am now and I don't feel like I've fully explored the space of possible implementations despite trying a lot of different approaches.
Here are some example generated maps: https://media.discordapp.net/attachments/583406212272619571/... https://i.imgur.com/LK5a6jU.jpg https://cdn.discordapp.com/attachments/583406212272619571/10... https://cdn.discordapp.com/attachments/583406212272619571/99... https://cdn.discordapp.com/attachments/583406212272619571/99...
The initial tile/pixel grid starts with the tiles/pixels being all possible values.
The algorithm selects a random tile with a preference for low-entropy tiles/pixels (i.e. with a low number of possible values). The chosen tile is the set to a value from its possible values ("superpositions").
The adjacent tiles/pixels are then updated ("collapsed") based on the rules/constraits of the system (e.g. if there is a wall to the left of the tile, there must be a wall on the right edge). This collapse is propagated until there are no more tiles/pixels to update. If a tile/pixel during the collapse has a single value then it is assigned that value.
The process repeats until all tiles/pixels have a single value.
There can be cases where a collapse reaches a state where it is in an invalid state or cannnot be collapsed further. Various implementations of the algorithm will then reject the generation and redo it from the beginning -- similar to the rejection sampling you mentioned.
It would be good to be able to
a) determine in bounded time whether any solution exists at all
b) use a deterministic procedure to find a solution
"Redo from the beginning" seems like cracking a cipher by brute force.
I can't prove it but I think this is roughly the same thing as the circuit satisfiability problem, which is np-complete. So, I think the best thing you can do there is a very large exponential time bound.
b) use a deterministic procedure to find a solution
You can solve this problem deterministically with depth first search. But I found that to be pretty slow and generate not very aesthetically interesting results most of the time.
As a calculation tool, like the algorithm in this thread, sure, but not as something that really happens.
[1]: https://en.wikipedia.org/wiki/Delayed-choice_quantum_eraser
https://en.wikipedia.org/wiki/Consistent_histories
That is, there is no collapse. QM is a description of the quantum level of the world relative to our fixed sized, such that it doesn't really make sense to ask "what is really happening" since "what is really happening" is relative to what we can measure and ask from a human perspective. The probabilisitic nature is the description we have to describe systems at the quantum scale since it doesn't really make sense to ask the question what a quantum system looks like at a quantum scale, since measurement devices are inherently classical.
I guess you can say it's sorta like taking some algorithm for some problem, caching all possible inputs, and thus knowing the full solution to that problem but not really knowing the "true" algorithm that has no memory space optimizations. Some might say the problem should have a more "real" solution, but the infinite cache solution might be all we have and it doesn't mean the solution is worthless.
While this may seam unsatisfactory to some, I think QM is a very consistent description to much physics, and alternatives like LQG are inherently problematic as it violates Lorentz invariance since it chooses a privileged reference frame (the reference frame with the smallest length metric). A lot of the hate comes from some physicists who want to introduce their own theories, want to full status and glory of being the next Einstein who disrupted physics, but will never address any criticism of their theories, berate others who work on QM or string theory for not wanting to work on their framework, and essentially saying those who are working on QM/theory don't deserve their jobs nor funding.
But something is happening. Really.
Sorry, physics doesn't care that you find some descriptions of the world troubling. Some might find the magnetic field troubling since the divergence of the magnetic field is zero. Some might find the fact that mass and energy are equivalent as troubling.
That's an uncharitable interpretation. People have an objection to speculations like many-worlds because they aren't corroborated by observation, and by nature can't be (iiuc), and are therefore unscientific (though not necessarily untrue). Well-established physicists like Sabine Hossenfelder hold this position and it's not as clear-cut as "the facts don't care about your feelings" like some make it out to be.
The disagreement with MWI and the general disdain for QM are separate issues. MWI is an interpretation that doesn't necessarily invalidate the framework, but attempts to extend it. However there's also been a general disdain for QM from various folk who attempt to completely replace it.
Whether Sabine Hossenfelder likes a theory or not is not really an argument, given you're arguing from authority. As an example of her clickbaity title where she doesn't really seem to respect QM:
https://backreaction.blogspot.com/2019/05/quantum-mechanics-...
I think it's well known in the theory community QM can be updated for a more complete framework (carefully obviously), but the idea that QM is "completely wrong" because it's incomplete or introduces some complexities she doesn't like, is completely laughable. It's akin to saying classical mechanics is "completely wrong" because it doesn't predict quantum behavior (despite many anti-QM people claiming QM is wrong because they want to impose their classical understanding onto the quantum world) and then ignoring modern engineering, which uses classical mechanics to describe buildings, cars, machines, etc...
Fair point, I guess I didn't sense any disdain from the conversation so I didn't intend to comment on that.
> there's also been a general disdain for QM from various folk who attempt to completely replace it.
Too bad, it's as proven as any other theory out there. I wasn't responding to this as I didn't see any in the conversation, maybe I missed it.
I was responding to the criticism that someone received for pointing out that what quantum mechanics describes (things being in a superposition of states) doesn't match what we observe (things being in one state at a time).
> Whether Sabine Hossenfelder likes a theory or not is not really an argument
Whether actual scientists hold a view is not an argument (nor did I try to use it as one), but it is relevant to pointless random online arguments because it can help us spend our time better and not waste it on debunking things that nobody who knows what they're talking about actually believes, as I was trying to help you do. You yourself said
> I think many "top" physicists (those with high citation counts in theory), generally believe in consistent histories
so your criticism applies to both of us or neither.
> the idea that QM is "completely wrong"
Who are you quoting here? The article you linked doesn't say that QM is "completely wrong" (just that it's not as good as QFT), and neither does anyone in the HN discussion, so I'm not sure what text you're referring to.
> because it's incomplete or introduces some complexities she doesn't like
Actually Hossenfelder is a well-known critic of the idea that simplicity and beauty are requirements of truth, and your remarks aren't supported by the text of the article, so I'm not sure what you're getting at here either.
I don't agree here, argument from authority is not an appropriate argument. If you do not have particulars for an argument, then you shouldn't really have a strong opinion on the topic.
> Who are you quoting here? The article you linked doesn't say that QM is "completely wrong" (just that it's not as good as QFT), and neither does anyone in the HN discussion, so I'm not sure what text you're referring to.
? The article I linked has a headline that's clearly misleading, and not only that, QFT is BASED on QM. You start with some Lagrangian and fields, impose QM restrictions via commutation relations, and perform calculations. What exactly do you think QFT is?
> Actually Hossenfelder is a well-known critic of the idea that simplicity and beauty are requirements of truth, and your remarks aren't supported by the text of the article, so I'm not sure what you're getting at here either.
What exactly are you trying to argue here? You started off dismissing my comments, and now you're defending Sabine for "beauty" and "truth". Beauty and truth relative to her, Sabine? Okay?
Does Tegmark shut up and calculate or extensively discuss the metaphysical meaning and reality of his "mathematical universe hypothesis" - whatever it is? I suspect the latter.