This is coolest algorithm I've ever used: Wave Function Collapse
Vložit
- čas přidán 5. 08. 2024
- The wave function collapse algorithm can produce outputs based on constrains in a sample input - it looks a lot like machine learning, but the algorithm is actually relatively easy to follow and produces very impressive results.
Robert's code: robertheaton.com/2018/12/17/w...
My adaptation of Robert's code to TypeScript: gist.github.com/joshuamorony/...
Get weekly content and tips exclusive to my newsletter (plus get access to the complete archive of tips): mobirony.ck.page/4a331b9076
Learn Angular with Ionic: ionicstart.com
0:00 Introduction
1:05 A Simple Tiled Model
4:05 Examples
#javascript #algorithm #gamedev
- More tutorials: eliteionic.com
- Follow me on Twitter: / joshuamorony
New newsletter goes out tomorrow: mobirony.ck.page/4a331b9076 (subscribe to get access to my complete archive of tips from previous newsletters)
Never have I ever thought quantum physics concepts will be applied to a "non quantum" system in such a way, this is incredible!
What's really mind blowing about this is how it scales up dimensionally!
You can for instance have your game world generated as shown, but you can also apply a WFC over time, where sometimes a house gets placed, then becomes abandoned, then becomes ruins as constraints based on the previous state.
At the 5th dimension, you can see all the N possible variations of how that terrain could evolve over time. It's a really remarkable system.
@@therandomdude9868Can you please explain more or provide sources/examples I don't understand.
@@MilkGlue-xg5vj Theres a series of videos called "Imagining Ten Dimensions" which describes at a theoretical level what I'm talking about, but I'm not sure if there are many good examples of wave function collapse over time.
1. Start with the following tileset: ocean, beach, grass, forest
2. Add the following ruleset: ocean can be next to ocean and beach, beach can be next to grass, beach, ocean. etc. etc.
3. Lets imagine this generates an island, this is the first frame.
4. Add the following ruleset: ocean can only be placed where the previous frame had ocean or beach (erosion occurred), beach can only be placed where the previous frame had beach or land, etc. etc.
4. Use the same rules to generate another frame, and repeat to have an island which slowly erodes away into the ocean.
Did you came across that algorithm randomly or are you working on something specific?
I'm working on a game and was looking into procedural terrain generation when I came across it (was originally looking at using Perlin noise)
Lol, I've been working on a wangtiles library myself!
I'm almost upset about this video coming up on my feed! 😂 😂
I've never experimented with Wang tiles - had you already heard of the WFC algorithm and do you have any opinions on differences?
@@JoshuaMorony Well I tried replying with source material, but my links are blocked 🙄, look up the 2017 article from Isaac Dykeman. The name of the article is: "Procedural Worlds from Simple Tiles"
Hey, very nice video!
Can you tell me what the game at 0:33 is called?
Townscaper