NetHack's Gnomish Mines grow their caves with cellular automata

Dungeon Generation in the Gnomish Mines of NetHack

Most of NetHack unfolds in square rooms, but the Gnomish Mines generate organic caves: seed 40% of the grid as floor, then run four passes of cellular automata. Pass 1 clusters tiles in place, passes 3 and 4 erode corners and tiny islands, and the author still can't work out what pass 2 — which turns a cell to rock when exactly five neighbors are floor — is meant to accomplish.

Pass 2 though… It turns cells to rock if they have exactly 5 floor neighbors (i.e. 3 rock neighbors). I'm still struggling to understand what purpose this is intended to achieve. Any ideas?
  1. OkayPhysicist

    I think pass two is intended to introduce additional regions of concavity (mostly by replacing straight lines), which in effect introduces a bunch of inflection points, helping creating the organic "spiny" feel, as opposed to a "bubbly" feel. Without it, the resulting caves look a bit more like if you spilled liquid on a waxy surface, and less like thorns.

    If you go into the javascript and replace "for(let p=0;p<3;p++)" with "for(let p=1;p<3;p++)", and then re-execute the block in the console, you can generate run through a bunch of generations without step 2

  2. ImJasonH

    All that work for some miscreant dwarf archeologist with a pick-axe (me) to show up and dig it to hell for a bunch of worthless glass.

  3. Rooster61

    Oh wow. I had no idea this was based on cellular automata. It really does give a totally different feel versus the other sections of the dungeon.

More from this day

2026-10-22