Live data from Hacker News

Building a Procedural Hex Map with Wave Function Collapse

felixturner.github.io

31–40 of 92 posts

Re: Building a Procedural Hex Map with Wave Function Collapse

#31
post #23

Earlier quoted context omitted.

Which is based on the board game of the same name. https://boardgamegeek.com/boardgame/370591/dorfromantik-the-...

The other way around.

Oh, wow, TIL. Both were released in 2022 but the video game already had an alpha release in 2021.

Re: Building a Procedural Hex Map with Wave Function Collapse

#32
Years and years ago (pre-smart phone), I built a mobile map and navigation product. Labeling streets was one of the more interesting side quests and the solution I found took a similar approach of generating a large number of candidates, picking one solution, and iterating. It worked quite well in practice.

Re: Building a Procedural Hex Map with Wave Function Collapse

#33

Super awesome, love the tilt-shift camera effect! I was also wishing I could zoom in to human size and run around HAHAHA

I started on a simple coop top-down pirate game yesterday when this popped up. I will probably switch the map generation to be using something like this tbh

Re: Building a Procedural Hex Map with Wave Function Collapse

#35

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…

there's also a bunch of dedicated constraint programming solvers / high level modelling languages for these kinds of constraint-y combinatorial optimisation problems

e.g. https://www.minizinc.org/ offers a high level modelling language that can target a few different solver backends

might be pretty good results to completely ignore writing a custom algorithm and drop in an existing industrial-grade constraint programming solver, model your procgen problem using a high level language, and use the existing solver to find you random solutions (or exhaustively enumerate them). then more time to iterate on changing the problem definition to produce more interesting maps rather than getting bogged down writing a solver.

Re: Building a Procedural Hex Map with Wave Function Collapse

#37
post #35

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…

there's also a bunch of dedicated constraint programming solvers / high level modelling languages for these kinds of constraint-y combinatorial optimisation problems e.g. https://www.minizinc.org/ offers a high level modelling language that can target a few different solver backends might be pretty good results to completely ignore writing a custom algorithm and drop in an existing industrial-grade constraint program…

Yeah, you can also use Clingo [0] which is pretty popular and people have tried it specifically with WFC content generation [1]. You can even run it in the browser easily [2].

[0] https://potassco.org/clingo/

[1] https://adamsmith.as/papers/tog-wfc.pdf

[2] https://potassco.org/clingo/run/

Re: Building a Procedural Hex Map with Wave Function Collapse

#39
Fun fact: because WFC is graph-based, you can do stuff like creating a graph where it uses time as a dimension, so you can create animations that “wrap” in time.

In this rabbit example I made 8 years ago, the WFC solver ensures that the animation must loop, which means you will always end up with an equal number of births and deaths.

https://xcancel.com/MattRix/status/979020989181890560

Re: Building a Procedural Hex Map with Wave Function Collapse

#40
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 ended up with "to make a map from scratch, first you create the universe" where I'd go through all of the ages, compute waterflows and precipitation, and on and on. Maybe I made the requirements too unreasonable and that's precisely why I never yielded a working game from it.

Post reply on HN