Dungeon & Branch Map
NetHack keeps its entire dungeon topology in one file: how deep every dungeon runs, which levels a
branch entrance may generate on, and where each named special level can land. This page parses that
file — dat/dungeon.def in 3.6, dat/dungeon.lua in 3.7 and 5.0 —
and draws it. Every number below comes out of the game data; nothing is remembered lore.
Version
How to read the depths. Each dungeon’s length is itself random, so the map is drawn at
the minimum depth of every dungeon. Levels pinned to the top (the Oracle, the Mines entrance)
keep their numbers whatever happens; levels pinned to the bottom (Medusa, the Castle, the Sanctum)
slide down as the dungeon gets longer, so those are labelled relative to N, the dungeon’s
actual depth. A bracket spans every level an entrance or special level is allowed to appear on.
↓ down staircase
↑ up staircase
◊ magic portal
• special level
• level you arrive on
│ range it can generate in
The map
Loading dungeon data…
What changed between versions
Diffed from the filesReading the raw fields
Both file formats carry the same numbers; only the syntax changed. The rules below are from
util/dgn_comp.y (the 3.6 grammar) and src/dungeon.c
(level_range() and init_dungeon_set_entry(), 3.7 / 5.0) — they agree.
| Field | Meaning |
|---|---|
base, range on a dungeon |
The dungeon has base to base + range - 1 levels
(rn1(range, base)). range absent means exactly base. |
base > 0 on a level or branch |
An absolute level number counted from the top of that dungeon. |
base < 0 |
A reverse index: the level is N + base + 1, so -1 is the bottom level. |
chainlevel |
base is added to wherever the named level actually landed, so the two move together. |
range on a level or branch |
0 means one fixed choice; n means n consecutive candidate
levels, clipped at the bottom of the dungeon; -1 means “anywhere from here
down”. |
nlevels (3.6: the trailing count on RNDLEVEL) |
How many interchangeable map files exist for that level; one is picked per game. |
chance |
Percentage chance the level is created at all. Only the Big Room uses it (40%). |
entry |
Which level of the dungeon you arrive on. 0 / absent = the top,
negative counts from the bottom, so Sokoban’s -1 means you enter at
its bottom and climb. |
branchtype |
stair (two-way), portal (a magic portal; both ends stay at the same
depth), or no_up / no_down for a one-way connection missing one
of its staircases. |
| flags | mazelike, hellish, town, roguelike,
unconnected — the five bits in d_flags
(include/dungeon.h). |
The dungeon file says nothing about shops, temples, altars or monsters, so neither does this page.