Live data from Hacker News

Building a Procedural Hex Map with Wave Function Collapse

felixturner.github.io

81–90 of 92 posts

Re: Building a Procedural Hex Map with Wave Function Collapse

#81
post #80

Hex math is weird. Since there are 6 directions instead of 4, there's no simple mapping between hex positions and 2D x,y coordinates. There is, a hexagonal grid is isomorphic to a [skewed] rectangular grid, i.e. it can also be indexed with a coordinate pair (u, v). The neighbours are at offsets (+1, 0), (-1, 0), (0, +1), and (0, -1) - just as in a rectangular grid - and the two additional neighbours are at (+1, -1) a…

Amit has a pretty good overview of the (many) ways to map coordinates to hexes: https://www.redblobgames.com/grids/hexagons/

Re: Building a Procedural Hex Map with Wave Function Collapse

#82
post #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).

Colloquially this is what gamedevs mean when they refer to WaveFunctionCollapse (though the constraints may or may not be inferred from tiles or 3D models, depending on the implementation). It may not match the academic terminology exactly

Re: Building a Procedural Hex Map with Wave Function Collapse

#83

It's beautiful. But also pretty unsatisfying in a way. Roads don't make sense. Rivers barely make sense. There's no higher-scale structure - the reason why most games with incremental procedural generation usually feel stale after a while, and always static. Every planet is different, yet feels the same. (Dwarf Fortress is the one procedural game I know - besides maybe its more faithful clones - which isn't static. B…

Noita is also procedural, but not static, although I'm not sure if that's what you're talking about.

Re: Building a Procedural Hex Map with Wave Function Collapse

#84

It's beautiful. But also pretty unsatisfying in a way. Roads don't make sense. Rivers barely make sense. There's no higher-scale structure - the reason why most games with incremental procedural generation usually feel stale after a while, and always static. Every planet is different, yet feels the same. (Dwarf Fortress is the one procedural game I know - besides maybe its more faithful clones - which isn't static. B…

As I recall, a lot goes into DF's world generation, including erosion simulation and the like to achieve a realistic result. That game is the embodiment of over-engineering, after all.

Re: Building a Procedural Hex Map with Wave Function Collapse

#85
As others have said, this is more of a constraint programming system than Wave Function Collapse. Whatever one wants to call it, I liked it.

For guiding the search, you might want to consider search steps that select only one feature, for example that a pair of adjacent tiles should be connected by a road, and just propagate that information. That could be used as a way to guide the search on high-level features first, and then later realize the plans by doing the normal search.

Re: Building a Procedural Hex Map with Wave Function Collapse

#86
post #80

Hex math is weird. Since there are 6 directions instead of 4, there's no simple mapping between hex positions and 2D x,y coordinates. There is, a hexagonal grid is isomorphic to a [skewed] rectangular grid, i.e. it can also be indexed with a coordinate pair (u, v). The neighbours are at offsets (+1, 0), (-1, 0), (0, +1), and (0, -1) - just as in a rectangular grid - and the two additional neighbours are at (+1, -1) a…

Amit has a pretty good overview of the (many) ways to map coordinates to hexes: https://www.redblobgames.com/grids/hexagons/

That is one of the first results I found and it is probably a great resource if you want to dive into the topic, but it also lacks an image of the rectangular - or rhombic - grid on top of the hexagonal tiling which I think is visually much clearer than those interactive maps highlighting only the axes of the cell under the cursor. But I understand why they made the choice, other coordinate systems do not admit the same type of visualization while the interactive maps are universal in that sense.

Re: Building a Procedural Hex Map with Wave Function Collapse

#88
post #8

Love this. As an aside, if the author reads this, did you consider using bitfields for the superposition state (ie, what options are available for a tile)? I did a wfc implementation a while back and moved to bitfields after a while.. the speedup was incredible. It became faster to just recompute a chunk from scratch than backtrack because the inner loop was nearly completely branchless. I think my chunks were 100 ti…

> I did a wfc implementation a while back and moved to bitfields after a while.. the speedup was incredible. Yeah, my WFC bot (which happens to generate Carcassonne maps in an amusing coincidence) eventually ended up using https://github.com/bits-and-blooms/bitset which improved things hugely. > It became faster to just recompute a chunk from scratch Kinda what mine does - every now and again[0] it stacks the current…

I read an 'i hate myself' post one time where someone encountered a variable named leghands. Obviously, it had once read legendHandles, and had since been helpfully shortened by the author.

Re: Building a Procedural Hex Map with Wave Function Collapse

#89
post #47

[flagged]

This sentiment is quickly becoming the most annoying low-effort comment on HN. If you don't want to read it, don't read it. If something about the writing offends you, then describe it, so we can talk about it.

I’m pretty sure AI-written comments hold that crown. I have described what bothers me about the writing, and also a proposed solution. Post the prompt, not the slop.

Re: Building a Procedural Hex Map with Wave Function Collapse

#90
post #47

Earlier quoted context omitted.

This sentiment is quickly becoming the most annoying low-effort comment on HN. If you don't want to read it, don't read it. If something about the writing offends you, then describe it, so we can talk about it.

I’m pretty sure AI-written comments hold that crown. I have described what bothers me about the writing, and also a proposed solution. Post the prompt, not the slop.

> I have described what bothers me about the writing

No you haven't, you've made an unprovable claim about how the writing was accomplished without pointing out a single feature of the writing itself.

Too long? OK, but homebrew gamedev articles often are. Skimming was a good skill before AI and still is.

Bad writing? Again -- hobbyist posts don't exactly win awards. I suspected possibly some AI myself but not to the extent you're baselessly asserting: I really doubt there was a single prompt in any case. The article is structured like any other.

If it were content-free clickbait or something, the complaint would hold water. As it is this is a reasonably interesting article that has generated a large and fun discussion on HN, so even if you _could_ prove AI use, so what?

Post reply on HN