NetHack's Gnomish Mines Use Cellular Automata for Cave Generation
NetHack’s Gnomish Mines use cellular automata to generate organic-feeling cave networks, contrasting with the square rooms prevalent elsewhere in the game. The generation begins by randomly designating 40% of cells as floor, followed by four successive passes of cellular automata rules. Each pass evaluates the eight neighboring cells around every position, applying state transitions based on the count of floor tiles nearby.
Pass 1 uses unbuffered computation, updating each cell immediately before processing the next, preventing oscillation between states. It converts cells to rock with 0-2 floor neighbors, leaves 3-4 neighbors unchanged, and creates floor with 5-8 neighbors. This clustering effect consolidates scattered tiles into contiguous regions. Passes 2-4 use buffered computation, calculating all changes before updating the grid globally. Pass 2 uniquely converts cells with exactly 5 floor neighbors to rock. Passes 3 and 4 serve as erosion routines, converting cells with 6-8 rock neighbors to rock, which smooths corners and removes isolated islands. The algorithm concludes by adding corridors to reconnect any disconnected cave systems.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.