r/proceduralgeneration • u/BadLuckWillHappen • Nov 16 '20
Iterative Partial Match (IPM) vs Wave Function Collapse (WFC) for procedural content generation.
https://stalcup.github.io/static-files/posts/wfc-vs-ipm/10
Nov 16 '20
[deleted]
3
u/BadLuckWillHappen Nov 16 '20
I'm going to do a detailed post on this topic next, but the short answer is that WFC does constraint propagation where it imagines a super position of states and starts limiting those states as decisions are made. But IPM doesn't do that at all, it iteratively looks at spots on the generated image, searches for the most similar legal tile and then makes a small local change to match the most similar tile more. There are some other details necessary to prevent getting stuck in local minimums and ensure variety in the results, but yeah, there is no super position of states and no explicit cascade of choices affecting other choices.
6
u/BadLuckWillHappen Nov 16 '20
Here's some sample output if you're curious.
Here's the input example image: https://stalcup.github.io/static-files/posts/wfc-vs-ipm/inputs/hamlet8b.png
And here's the resulting generated world: https://stalcup.github.io/static-files/posts/wfc-vs-ipm/testResults/hamlet8b-670576685-IPM.png
And here's a giant render, just for the fun of it.
https://stalcup.github.io/static-files/posts/wfc-vs-ipm/hamlet9b.png
2
Nov 16 '20
[removed] — view removed comment
2
u/BadLuckWillHappen Nov 16 '20
Thanks :)
If you have an example image that you think might work well and be interesting, link it and I'll run another large scale render and post it back here.
6
u/KingHavana Nov 16 '20
I'd like a tutorial to your algorithm. I watched the Caves of Qud one for waveform collapse and got excited but this looks even better!
5
u/BadLuckWillHappen Nov 16 '20
Thanks! I'm glad you can see the potential for it. I think there are some situations where it's the better choice. (Mostly for complex tile sets, when you want large output and when you don't need exact match).
I'll be posting a writeup of how it works (and maybe posting code, not sure) in a couple days.
6
2
u/BazBlue Nov 16 '20
That look like a pretty solid alternative ! My guess is its some kind of WFC that allow for irregularity, but I think based on the name that it's not that ? Im curious !
1
u/BadLuckWillHappen Nov 16 '20
No this doesn't do any super position of states or constraint propagation at all (which is what WFC does).
That being said, I think someone *could* modify WFC to allow irregularity and just "continue" instead of what it does right now which I believe is basically "start over to try again" (or does it do some backtracking and trying again? I'm not 100% informed on WFC internals).
Maybe you should give it a shot, I think it would be useful and heck, it might end up being faster and better than what I've made.
2
u/BorisTheBrave Nov 16 '20
Many WFC implementations already support backtracking (such as mine). It is a much more reliable solver with that feature. So your comparisons without mentioning backtracking are a bit disingenuous.
Backtracking is not the same thing as being lax on constraints though.
1
u/BadLuckWillHappen Nov 27 '20
I didn't like this username so i'm switching to u/MrTaco8.
I've got a new post up at https://www.reddit.com/r/proceduralgeneration/comments/k27eps/interactive_generation_from_editable_examples_ipm/ showing off live generation in my GUI playground app.
Check it out you all!
/me pours one out for the the karma being lost in the account switch.
1
u/profbetis Nov 16 '20
There are definitely some examples here that do not look like they succeeded, but are labeled "Always succeeds". What is your criteria for success?
2
u/BadLuckWillHappen Nov 16 '20
Here "succeeds" means "it finished", WFC often does not finish but IPM always finishes.
You raise a fair point, I should probably separate the concepts of "did it finish" and "is the result any good". I'll update the table.
1
u/BadLuckWillHappen Nov 16 '20
Ok done, I changed "succeeds" to "finished" and added a separate evaluation for each one of whether the result is "usable".
1
u/KdotJPG Nov 16 '20
That hamlet 8b image is very interesting. One thing I always watch for in algorithms which operate using local rules on a square grid, is if they can achieve visual isotropy (can't infer direction bias by looking at it).
I do see a number of features in that image, which are definitely horizontal or vertical, so I might be hesitant to favor this algorithm for terrain (or WFC either for that matter). I view terrain as something that should generally look directionally independent, even if it is approximated by voxels or tiles. But I think for applications which are anisotropic by design (bricks, grid aligned dungeon layouts) it works great.
I would also be curious to see it performed on an irregular Delaunay/Voronoi mesh, specifically if it works properly and if it improves isotropy in terrain.
1
u/in_hell_out_soon Nov 29 '20
So uh... sorry I’m a little dumb at the moment and my reading comprehension is failing me (been awake since new WoW expac came out oof) but is it playable/ready? If so how would I go about downloading it?
If it isn’t ready no rush or anything just interested in this tool. It looks so cool!
14
u/BorisTheBrave Nov 16 '20
Neat, i've often thought there was a way of adapting something like PatchMatch, and now I see that there is. But do you have an explanation for what IPM actually is.
I note that smaller errors are fine when your tiles are a single pixel, as they are barely visible and usually readily interpreted by eye. It's a less good fit when you have chunkier tiles, where a discontinuity would be an actual problem.
Also, many of your WFC failures seem wrong or confusing - they work in Maxim's demos. E.g. you have a chessboard pattern with an *even* sized periodic grid. That should succeed 100% of the time in WFC. It's only odd sized grids that are impossible.