The Wave Function Collapse algorithm

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ต.ค. 2023
  • Generating random worlds using the wave function collapse algorithm.
    This video explains how the WFC algorithm works, and explains how to implement the WFC algorithm in python code.
    ☕️ ☕️ No coffee, no coding! 🔥 🔥
    If you like to support my work with a small donation:
    www.buymeacoffee.com/CodingQuest
    Thank you!!
    You can find the source code, and tile set here:
    github.com/CodingQuest2023/Al...
    Music: Imagine by Auixe is licensed under a Creative Commons License.
    creativecommons.org/licenses/...
    Support by RFM - NCM: bit.ly/2xGHypM
    Music: Imagine by Auixe
    Soundcloud: / auixe
    TH-cam: / @auixemusic4618

ความคิดเห็น • 230

  • @maple201
    @maple201  +296

    If you want to make sure your world is traversible, you could start by seeding the map with random meandering pathways of grass before running wavefunction collapse.

  • @Stratelier

    A neat property of this generation method is that you can "seed" the map with fixed landmarks, and it will fill in the rest of the space on its own.

  • @yellingintothewind

    You can also make less noisy maps by dynamically weighting the valid terrain based on proximity to similar terrain. So if the lowest entropy tile can be grass, grass to forrest, or grass to water, instead of being 1:1:1 weights (or predefined weights for the whole map), it can be the number of grass, forrest, or water tiles within say 3 tiles from the current tile. This lets you generate larger lakes, for example, while still being mostly grassland.

  • @TheBlenderblob

    you have 30 seconds to explain how this is any different to a markov chain.

  • @Tiemen2023

    He talks a Dutch version of the English language

  • @flameofthephoenix8395

    Personally, I think a full water tile should make other full water tiles more likely so as to get bigger ponds/oceans.

  • @anon_y_mousse

    One tiny tip, try making an IntFlag inheriting Enum for the cardinal directions and set their values as North = 1, South = -2, East = 2, West = -3. Then to set the opposite direction you can just use ~direction and it'll work. You can even type check by doing if direction in Cardinal.

  • @TalicZealot

    Cool generator. One thing that came to mind is what about removing getLowestEntropy and instead using a priority queue, containing the adjusted nodes. This way we don't iterate over the entire grid every step and we get a fast min value.

  • @markmanning2921

    had to stop watching when you said "implemented in python" because i literally spent 3 months trying to learn that and i just rejected everything about it outright. can you do it again in C??? :)

  • @williamdrum9899

    Isn't this essentially reverse Minesweeper

  • @Kitsuneko111

    This ended up on my recommended and I decided to bite the bullet and learn about the big scary name algorithm at 3am. This video explains it so clearly and cleanly at such a nice pace I think I already understand it perfectly which is amazing! I already summarised it to a friend as “it’s like doing a jigsaw by looking at the similar sides and then picking a random piece that seems to fit” 😂

  • @Rohan2300

    An idea I've been playing with is to create a world of "object impermanence" where we use Wave Function Collapse in a semi-continuous fashion during gameplay. Basically anywhere you're not looking is in a state of flux, and when you look at it, it temporarily pins it down.

  • @arejaybee

    Spent an hour debugging because I made my direction enum NORTH, SOUTH, EAST, WEST instead of NORTH, EAST, SOUTH, WEST. I'm kinda glad I did because I got a very deep understanding of how all of these functions and maps are tied together. Thank you for this! I got it working in kotlin :)

  • @shanerooney7288

    Another suggestion for added functionality:

  • @kevnar

    I once used wave function collapse for a procedural melody maker about 15 years ago. I didn't even know the algorithm existed. I just set up a system that decides what notes can come next, based on the current note. For example, if it's the 4th note in the scale, it has a higher probability to go to the 1, 5, or 8th note, and a lower probability to go to 2, 3, and 6. And so it just kept plinking along through the endless melodies. Great things happen when you're bored and curious.

  • @NosAltarion

    Fantastic work. Thanks a lot. One of my student is a lot into game dev and I'll be sure to redirect him towards your video so he's motivated to dig a bit deeper in his coding classes

  • @user-yf7pi9hy5b

    This is something I would find very interesting to implement using F#. I am developing a simulation program in .NET for a research that I'm conducting, and generating terrains with diverse and realistic environment factors is one of the main problems I have to tackle. This video gave me great insight!

  • @obszczymucha1337

    Very nice production and explanation. Thank you!

  • @InCognite

    Thank you for uploading this video! Now I finally understand how wave function collapse works both in theory and code and managed to port it into my own project.

  • @habbokoreiapix

    Thanks to your video i've got to make my version of wfc finally work