A blog post breaking down how NetHack generates the Gnomish Mines levels using four passes of cellular automata, including an unbuffered clustering pass and erosion passes, with a puzzling second pass whose purpose the author questions.
# Dungeon Generation in the Gnomish Mines of NetHack
Source: [https://www.boristhebrave.com/2026/10/18/dungeon-generation-in-the-gnomish-mines-of-nethack/](https://www.boristhebrave.com/2026/10/18/dungeon-generation-in-the-gnomish-mines-of-nethack/)
[Skip to content](https://www.boristhebrave.com/2026/10/18/dungeon-generation-in-the-gnomish-mines-of-nethack/#content)
Ok, this one is really best explained with a visualiser:
NetHack’s level generation has a lot of interesting things, but I wanted to focus on the[Gnomish Mines](https://nethackwiki.com/wiki/Gnomish_Mines)because of their use of Cellular Automata\. This gives it an organic caves feel, while the majority of the game is spent in square rooms\.
It’s very straightforward:
- Randomly pick 40% of the cells to be floor
- Apply four passes of Cellular Automata
- Fix up disconnected caves with extra corridors
Let’s dive into the cellular automata specifically\. There’s only two states – floor or rock\. And each pass works by counting how many floor tiles are in the 8\-neighbor hood of each cell\.
Pass 1: 0\-2 → rock; 3\-4 → unchanged, 5\-8 → floor Pass 2: 0\-4 → unchanged; 5 → rock; 6\-8 → unchanged Pass 3: 0\-2 → rock; 3\-8 → unchanged\. Pass 4:*same as pass 3*
Interestingly, pass 1 is unbuffered\. Each cell is updated in place before moving to the next cell\. All the rest are buffered – all cells have new computed values, then the entire grid updated at once\.
Pass 1 creates floors near other floors, and creates rocks near other rocks\. I’d call this a “clustering” pass, that pushes the random tiles towards wide open areas of tiles\. The unbuffering is important here so that you don’t flop\-flop, turning something rock→floor near something turning floor→rock\.
Passes 3 and 4 are erosion routines, it’s a very common use of cellular automata\. If you have 6\-8 rocks nearby, then you also become a rock\. That tends to smooth out corners, and delete tiny islands\.
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?
Reverse Minesweeper is a logic puzzle game that generates grids with tunable difficulty using a deduction-based solver, offering five tiers from Easy to Insane.
A developer describes embedding a peer-to-peer multiplayer dungeon game into a static blog using WebRTC and Trystero, with deterministic procedural generation and no backend server.
A developer adds NetHack to their community app and discovers the 38-year-old roguelike's surprising depth, including multiplayer via bones files and countless obscure interactions.
A Show HN post describing the author's raycaster project inspired by the classic Atari 2600 game Entombed, exploring its famous 'mystery table' maze-generation algorithm that procedurally builds rows using only local neighbor information under extreme memory constraints.
Freehold Games' Brian Bucklew and Jason Grinblat explain their approach to combining procedural generation techniques to create entire villages with history, culture, architecture, NPCs, and quests in the game Caves of Qud.