
DeBroglie – Generate tile-based maps using wave function collapse - tobr
https://boristhebrave.github.io/DeBroglie/
======
hesdeadjim
Oh also here is the original creator of the algorithm that this implementation
is based on:

[https://github.com/mxgmn/WaveFunctionCollapse](https://github.com/mxgmn/WaveFunctionCollapse)

Even more examples up there.

------
wcarss
I wrote a js wave function collapse implementation earlier this year and
really enjoyed the process and its results. Constraint support is a feature
I'm still looking forward to adding in the future, so it's pretty neat to see
how others have tackled similar things.

This algorithm is really amazing -- it's effectively very similar to a markov
chain to generate map/image data.

~~~
platz
> The coefficients in these superpositions are real numbers, not complex
> numbers, so it doesn't do the actual quantum mechanics, but it was inspired
> by QM.

I'm not sure how to think about this algorithm. Is it just applied statistics?

~~~
wcarss
I've never done any applied statistics that I know of, so I'm not sure!

For a 2D map the loose layout of the algorithm is this: construct a 2D array
of blank tiles. Choose a tile at random from the set of most-constrained tiles
(this is currently all of them as they are all equally unconstrained) and give
it a value according to some distribution. Constrain its neighbors' potential
values and update whatever system you use to track most-constrained-tiles for
selection, then repeat until no unset tiles remain.

Depending on the complexity of the distribution (# of tile types and
absoluteness of neighbor relations), you may end up with a contradiction where
an unset tile has no possibilities. At this point you could progressively
backtrack, throw the whole set away, or fudge something, depending on what
matters to you in life.

You can end up with some very cool things!

The problem has some neat aspects to consider in how to represent tiles, how
to track constraints, how to efficiently update your selector, how to design
your distributions, etc! There are a ton of avenues to explore.

I make no claims on the goodness of this example or its implementation, but I
wrote a small game to use/test my wfc code here:
[https://wcarss.ca/jabiru/](https://wcarss.ca/jabiru/) \-- the maps generated
are entirely outputs of the algorithm.

------
sbuttgereit
I think the article title here is a little wanting... I was expecting
something a little different.

~~~
tobr
For background, here is an earlier HN thread about wave function collapse.

[https://news.ycombinator.com/item?id=12612246](https://news.ycombinator.com/item?id=12612246)

------
tobr
I suggest checking out the "Features" page:

[https://boristhebrave.github.io/DeBroglie/articles/features....](https://boristhebrave.github.io/DeBroglie/articles/features.html)

------
bojackstorkman
This is really neat. The stylization of the hexagonal tile sets reminds me of
a tabletop game I played years ago called Heroscape. Is there any chance that
it was inspired by that?

~~~
scotteh
Not sure about the inspiration, but I believe it's these:

[https://opengameart.org/content/pixel-hex-tilesets-
enhanced](https://opengameart.org/content/pixel-hex-tilesets-enhanced)

------
hesdeadjim
Been working with this implementation of WFC in Unity and it’s been a lot of
fun. The game Bad North that just came out also uses this technique heavily
for 3D island generation.

------
dmarlow
This is really neat. Did you create this for a game?

~~~
BorisTheBrave
Author here. No. I saw some neat stuff from the author of WFC[1], and realized
it combined perfectly with another proc gen algorithm I'd designed earlier[2].
Hence why this is the only implementation I've seen with non-local
constraints[3]

[1]:
[https://github.com/mxgmn/WaveFunctionCollapse](https://github.com/mxgmn/WaveFunctionCollapse)
[2]: [https://www.boristhebrave.com/2018/04/28/random-paths-via-
ch...](https://www.boristhebrave.com/2018/04/28/random-paths-via-chiseling/)
[3]:
[https://boristhebrave.github.io/DeBroglie/articles/features....](https://boristhebrave.github.io/DeBroglie/articles/features.html#constraints)

------
trainingaccount
Pedantic note: wave functions do not collapse; decoherence occurs.

------
The_rationalist
Not directly related, but for People interested in fundamental physics,
classical mechanism is becoming very relevant for explaining particles.

    
    
      «in the deterministic collapse theory of 2016 [29] the nonlocal absolute phase constants of the wavepackets were taken as hidden variables (cf. [30]). Collapse occurs when two wavepackets spatially overlap and satisfy a mathematical criterion, which demands that their phase constants very nearly coincide. The wavepackets then collapse to the overlap volume. In a measurement this mimics the action of a point particle. The phase constants are pseudorandom numbers, in the sense of the deterministic chaos theory, and the Born rules are derived under the assumption that their distribution is uniform.   » 
     
    
     « Physicists report that quantum behavior can be explained with classical physics for a single particle, but not for multiple particles as in quantum entanglement and related nonlocality phenomena ("spooky action at a distance" ["gruselige Action in einiger Entfernung" (german)],[344] according to Albert Einstein) »

[https://www.eurekalert.org/pub_releases/2018-10/thni-
wii1011...](https://www.eurekalert.org/pub_releases/2018-10/thni-
wii101118.php)

And another hidden variable theory explain quantum entanglement.

Thus, classical mechanism deterministically explain ALL of quantum mechanics !
What still needs to be done is to unify those three local hidden variable
theories and wouldn't that create the first theory of Everything ? A thing
that quantum mechanics will never by design be able to do by being
incompatible with general relativity.

Let's be clear, probabilities distributions (quantum mechanics) are a Nice map
of the territory. But the map isn't the territory ans the territory IS
superdeterministic like classical mechanics.

Also, I believe that local hidden variable theories are deeply underresearched
because mainstream scientists have not updated their belief on them since 40
years... I guess too that many quantum scientists are afraid of dropping the
Nice absurd Idea of free will...

~~~
mef51
I thought Bell's theorem ruled out local hidden variable theories?
[https://en.wikipedia.org/wiki/Bell%27s_theorem](https://en.wikipedia.org/wiki/Bell%27s_theorem)

~~~
gus_massa
From
[https://en.wikipedia.org/wiki/Pilot_wave_theory#Principles](https://en.wikipedia.org/wiki/Pilot_wave_theory#Principles)

> _The theory brings to light nonlocality that is implicit in the non-
> relativistic formulation of quantum mechanics and uses it to satisfy Bell 's
> theorem._

[Disclaimer: I don't like pilot wave theory.]

