Live data from Hacker News

Building a Procedural Hex Map with Wave Function Collapse

felixturner.github.io

51–60 of 92 posts

Re: Building a Procedural Hex Map with Wave Function Collapse

#51
post #34

"WebGPU is not available on your device or browser.". Other 3d demos works fine though. Tried Firefox and Opera on mobile.

what's your device? guessing android? new? old? Has Firefox shipped WebGPU on Android? MDN says no, though it does claim Opera has.

Re: Building a Procedural Hex Map with Wave Function Collapse

#52

This is fun and neat, and looks fantastic, but the generated maps are basically nonsensical, aren't they? Landmasses and waterways and roads and buildings and forests and so on that don't make any logical sense for their placement. I say this having had a couple of fun "hex-based strategy game hobby projects" over the years (sidenote -- trying to cover a sphere in hexes is actually a non-trivial matter). Invariably I…

> This is fun and neat, and looks fantastic, but the generated maps are basically nonsensical, aren't they? WFC lets you address that though with extra constraints. e.g. my bot today generated a church inside a river loop[0] - completely useless! But I could add a rule that says "if you place the church-above-river tile, the tile above that cannot be anything horizontally blocking" (obviously after tagging any releva…

not trying to be contrarian but a church inside a river loop sounds like a super sacred church that requires a pilgrimage to visit.

That said, there's an Apple TV video of a castle on an island where my first thought was "why does this exist?"

https://vimeo.com/657386068

Re: Building a Procedural Hex Map with Wave Function Collapse

#53
post #22
post #18

Earlier quoted context omitted.

Is it the em dashes? I didn't get the feeling it was AI generated at all

It's current year, of course they used AI to help [0], and it does feel like the article was AI assited. "This map isn't flat — it has 5 levels of elevation." "The ocean isn't just a blue plane — it has animated caustic sparkles" "The fundamental issue:" and "The key constraint:" I still enjoyed the article. [0] https://github.com/felixturner/hex-map-wfc/commit/1679be

At what point is this style going to become human style? Kids use LLMs to learn, pick up their patterns, repeat them.

Re: Building a Procedural Hex Map with Wave Function Collapse

#55
Interesting. In my little project I only need one generation of hex tiled terrain but based on certain lore and vision for thousands of objects with different lore. I tell LLM to research the lore and paint the terrain using json in chunks. Some results are shit, some results are great. Still, it would be impossible manually. I can always do another pass for unsatisfying results with different prompt engineering.

Re: Building a Procedural Hex Map with Wave Function Collapse

#56

Earlier quoted context omitted.

> This is fun and neat, and looks fantastic, but the generated maps are basically nonsensical, aren't they? WFC lets you address that though with extra constraints. e.g. my bot today generated a church inside a river loop[0] - completely useless! But I could add a rule that says "if you place the church-above-river tile, the tile above that cannot be anything horizontally blocking" (obviously after tagging any releva…

not trying to be contrarian but a church inside a river loop sounds like a super sacred church that requires a pilgrimage to visit. That said, there's an Apple TV video of a castle on an island where my first thought was "why does this exist?" https://vimeo.com/657386068

> "why does this exist?"

"Though hidden from the sea, the castle controls access to Loch Shiel" says Wikipedia. Which is a sensible thing for a castle to do back in the olden times.

Plus it's a tidal island - you can just walk across. Don't even need a drawbridge (although I guess that makes defending attacks from inland a bit tricky.)

https://en.wikipedia.org/wiki/Castle_Tioram

Re: Building a Procedural Hex Map with Wave Function Collapse

#57
This is not Wave Function Collapse. This is a constraint solver.

The goal of the original algorithm ( https://github.com/mxgmn/WaveFunctionCollapse ) is to infer the constraints from a sample, and then run a constraint solver.

Hard-coding the constraints skips the whole point of the algorithm (which is also badly named by the way).

Re: Building a Procedural Hex Map with Wave Function Collapse

#58
I used something similar for my Super Mario Maker 2 level viewer (eg https://www.smm2-viewer.com/courses/1HH-CJ8-KYF)

In the level data, the start/goal tiles (approx 10x10 blocks of solid ground under the player and goal) and slopes aren't represented by their tile offset in the level data -- whilst all other "ground" tiles are. Instead, for slopes you're only told the start and end coordinates, and they often overlap.

So to render the slopes correctly I had to work out all the rules for which tiles were allowed next to each other, and solve some ambiguity rules -- I figured out that shallow slopes take precedence over steep ones. Eventually I cracked it, but it took quite a week or so of iteration to figure it out.

Re: Building a Procedural Hex Map with Wave Function Collapse

#59
post #19

Reminds me of Jasper Flick's Unity tutorial on hex terrain [0] which is similarly wonderfully detailed. Interesting contrast: this project uses premade tiles and constraint solving to match tile boundaries, while that one dynamically generates tile boundaries (geometries, blending, etc.) on the fly. Both enjoyable reads! [0] https://catlikecoding.com/unity/tutorials/hex-map/

This is an amazing resource, thanks for sharing

Re: Building a Procedural Hex Map with Wave Function Collapse

#60

The post glosses over the "backtracking" and says they just limit it to 500 steps but actually constraint programming is an extremely interesting and complicated field with lots of cool algorithms and tricks. In this case we could solve it with Knuth's Algorithm X [1] with dancing links, which is a special kind of backtracking. Algorithm X should, in theory, be able to solve the border region described in the article…

Thanks for the feedback. Feel free to drop a PR :)
Post reply on HN