Rogue
The 1980 dungeon game, read through the BSD-licensed Rogue 5.4.4 source, with rooms on a 3 × 3 grid and a food clock.
On this page
The atlas reads Rogue 5.4.4, a BSD-licensed release of Rogue’s version 5.4. The 1980 original’s code isn’t public, so every claim here is about 5.4.
Each level is nine boxes in a 3 × 3 grid over the 80 × 24 screen, with up to three left as bare corridor junctions1. Corridors join only neighboring boxes: first a tree that reaches all nine, then up to four extra links2. NetHack has one generated level with the same 3 × 3 structure3.
The hero starts with 1,300 food, which drops by 1 a turn, more with rings worn4,5. The hunger-clock warns below 300 and 150, and the hero starves below −8506. An attack hits at 5% per point of the attacker’s level, the defender’s armor class, and the bonuses7.
A death ends the program8, and restoring a game deletes its save file, except for a wizard in a debug build9. Those two rules make death permanent in normal play. Potion colors and scroll titles are dealt out anew each game, so identifying an item in one game says nothing about the next10.
Mechanics
| Mechanic | Kind | How |
|---|---|---|
| Hunger clock | Capped stomach | 1,300 food at the start, less 1 a turn plus rings; Hungry below 300, Weak below 150, starved below −850; a meal fills to at most 2,000 |
| Hit chance | d20 against armor class | a 0–19 roll plus bonuses against 20 less level and armor class: 5% a point |
| Procedural dungeon | Room grid | nine boxes in a 3 × 3 grid, up to 3 of them bare junctions, joined only between neighbors |
| Permadeath | Whole run | a death exits the game, and restoring deletes the save and refuses a linked copy or a dead hero |
| Item identification | Shuffled appearances | 14 potions get 14 different colors out of 27 |
| Item identification | Generated names | 18 scroll titles strung from random syllables each game |
Every claim about this game, by concept (11)
References
- ^Rogue 5.4 lays out each level as nine boxes in a 3 by 3 grid over the 80 by 24 screen. It first marks 0 to 3 boxes, picked at random and possibly the same twice, as gone: a gone box gets a point for corridors to meet but no room. Each other box gets a room; it is dark when a roll of 0 to 9 is below the depth less 1, and a dark room is a maze at a chance of 1 in 15.CodeRogue 5.4.4 source
How we know
22#define MAXROOMS 9rogue.h line 22 at cf9bd26 · upstream ↗ 31#define NUMCOLS 80rogue.h lines 30–31 at cf9bd26 · upstream ↗ 41 bsze.x = NUMCOLS / 3;rooms.c lines 41–42 at cf9bd26 · upstream ↗ 57 rooms[rnd_room()].r_flags |= ISGONE;rooms.c lines 55–57 at cf9bd26 · upstream ↗ Place a gone room.
rooms.c#L61-L82 · upstream ↗ 86 if (rnd(10) < level - 1)rooms.c lines 86–91 at cf9bd26 · upstream ↗ if not gone pick door pos
passages.c#L169-L183 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^Rogue 5.4 joins the boxes with corridors only between grid neighbors: from a random box it grows a tree, each step joining a random neighbor not yet joined, until all nine are connected, and then makes 0 to 4 tries at an extra corridor between a random box and a neighbor it isn't joined to.CodeRogue 5.4.4 source
How we know
38 { { 0, 1, 0, 1, 0, 1, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },passages.c lines 33–43 at cf9bd26 · upstream ↗ 69 if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0)passages.c lines 55–95 at cf9bd26 · upstream ↗ 101 for (roomcount = rnd(5); roomcount > 0; roomcount--)passages.c lines 97–115 at cf9bd26 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^NetHack 3.6.7's main dungeon, the Dungeons of Doom, holds one level built in Rogue's style. Its code's comment says “Rogue levels are structured 3 by 3, with each section containing a room or an intersection”, and each of the nine cells is an intersection at a chance of 1 in 5, so long as at least one room is made.CodeNetHack 3.6.7 source
How we know
20LEVEL: "rogue" "R" @ (15, 4)dat/dungeon.def lines 17–21 at ed600d9 · upstream ↗ Rogue levels are structured 3 by 3, with each section containing
src/extralev.c#L209-L213 · upstream ↗ 233 if (!rn2(5) && (nroom || (x < 2 && y < 2))) {src/extralev.c lines 228–243 at ed600d9 · upstream ↗ 700 makeroguerooms();src/mklev.c lines 698–701 at ed600d9 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^Rogue 5.4 starts the hero with 1,300 food. The
stomachdaemon runs once per pass of the command loop, after the hero's move, or after both moves when the hero is hasted. While food is above 0 it takes 1, plus each worn ring's cost, and 1 less while the hero carries the Amulet of Yendor, so with the Amulet and no rings the count stops.CodeRogue 5.4.4 sourceHow we know
29 food_left = HUNGERTIME;init.c line 29 at cf9bd26 · upstream ↗ 117#define HUNGERTIME 1300rogue.h line 117 at cf9bd26 · upstream ↗ 150 start_daemon(stomach, 0, AFTER);main.c line 150 at cf9bd26 · upstream ↗ 32 if (on(player, ISHASTE))command.c lines 32–39 at cf9bd26 · upstream ↗ 444 do_daemons(AFTER);command.c line 444 at cf9bd26 · upstream ↗ 163 food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet;daemons.c lines 160–163 at cf9bd26 · upstream ↗ 148 amulet = TRUE;pack.c lines 147–148 at cf9bd26 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^In Rogue 5.4 each worn ring adds to the turn's food cost by kind: 2 for regeneration; 1 for protection, add strength, sustain strength, stealth, or maintain armor; 1 at a chance of 1 in 3 for searching, dexterity, or increase damage, and 1 in 5 for see invisible; 0 for adornment, aggravate monster, or teleportation. A ring of slow digestion gives 1 back at a chance of 1 in 2.CodeRogue 5.4.4 source
How we know
-2, /* R_DIGEST */
rings.c#L163-L179 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^Rogue 5.4 shows Hungry once food drops below 300 and Weak below 150. At 0 or below, rings stop counting and food drops by 1 a turn; on each turn the hero isn't already helpless, a 1-in-5 chance faints the hero for 4 to 11 turns, and the hero starves once the count is below −850.CodeRogue 5.4.4 source
How we know
118#define MORETIME 150rogue.h lines 118–120 at cf9bd26 · upstream ↗ 146 if (food_left-- < -STARVETIME)daemons.c lines 144–159 at cf9bd26 · upstream ↗ 171 else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) ⋮ 176 else
daemons.c lines 165–179 at cf9bd26 · upstream ↗ 184 "", "Hungry", "Weak", "Faint"io.c lines 182–185 at cf9bd26 · upstream ↗ 188 return range == 0 ? 0 : abs((int) RN) % range;main.c lines 186–189 at cf9bd26 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^In Rogue 5.4 an attack hits when
rnd(20), a roll of 0 to 19, plus a to-hit bonus is at least 20 less the attacker's level less the defender's armor class. The bonus is the weapon's plus (with a fired missile's launcher plus, and the hero's dexterity rings when the weapon used is the hero's wielded one), the attacker's strength adjustment, and +4 when the target isn't running (asleep or held); a hero defender's armor class is the worn armor's, when the hero wears any, less any rings of protection. Computed, the chance is (level + armor class + bonus) / 20, held within 0 to 100%. Damage is rolled only after a hit.CodeRogue 5.4.4 sourcerevisedHow we know
381 int need = (20 - at_lvl) - op_arm;fight.c lines 378–384 at cf9bd26 · upstream ↗ 431 hplus += cur_weapon->o_hplus;fight.c lines 411–433 at cf9bd26 · upstream ↗ 442 if (!on(*thdef, ISRUN))fight.c lines 438–453 at cf9bd26 · upstream ↗ 460 if (swing(att->s_lvl, def_arm, hplus + str_plus[att->s_str]))fight.c lines 460–470 at cf9bd26 · upstream ↗ 188 return range == 0 ? 0 : abs((int) RN) % range;main.c lines 186–189 at cf9bd26 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Revised after a check by a second AI model, 2026-10-21.
- ^When a Rogue 5.4 hero dies,
deathshows the tombstone (or, with the tombstone option off, one line naming the killer), records the score, waits for return, and exits the program.CodeRogue 5.4.4 sourcerevisedHow we know
228death(char monst)rip.c line 228 at cf9bd26 · upstream ↗ 240 if (!tombstone)rip.c lines 240–246 at cf9bd26 · upstream ↗ 274 my_exit(0);rip.c lines 270–274 at cf9bd26 · upstream ↗ 394 exit(st);main.c lines 391–395 at cf9bd26 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Revised after a check by a second AI model, 2026-10-21.
- ^Restoring a Rogue 5.4 game deletes the save file as soon as it is read, refuses a file with another hard link or reached through a symbolic link, “to defeat multiple restarting from the same place”, and refuses a saved hero with no hit points left. It then reseeds the random number generator from the process id. A wizard in a debug (
MASTER) build skips the deletion and the link check.CodeRogue 5.4.4 sourceHow we know
226 md_unlink_open_file(file, inf) < 0)save.c lines 222–229 at cf9bd26 · upstream ↗ defeat multiple restarting from the same place
save.c#L237-L248 · upstream ↗ 250 if (pstats.s_hpt <= 0)save.c lines 250–255 at cf9bd26 · upstream ↗ 262 srand(md_getpid());save.c line 262 at cf9bd26 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^At the start of each game, Rogue 5.4 gives each of its 14 kinds of potion a different color, drawn at random from a list of 27 (amber to yellow), and each of its 18 kinds of scroll a title of 2 to 4 random words, each word 1 to 3 syllables from a fixed list, up to about 40 characters.CodeRogue 5.4.4 source
How we know
119 init_colors(); /* Set up colors of potions */main.c lines 118–119 at cf9bd26 · upstream ↗ 111#define NCOLORS (sizeof rainbow / sizeof (char *))init.c lines 81–111 at cf9bd26 · upstream ↗ 250 until (!used[j]);init.c lines 240–253 at cf9bd26 · upstream ↗ 272 nwords = rnd(3) + 2;init.c lines 260–289 at cf9bd26 · upstream ↗ 219#define MAXPOTIONS 14rogue.h line 219 at cf9bd26 · upstream ↗ 242#define MAXSCROLLS 18rogue.h line 242 at cf9bd26 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
Sources
Code
- Toy, Michael, Ken Arnold, and Glenn Wichman. 2016. “Rogue 5.4.4 source code.” Commit cf9bd26. Davidslv/rogue @ cf9bd26 · licence, all uses
- NetHack DevTeam. 2023. “NetHack 3.6.7 source code.” Commit ed600d9. NetHack/NetHack @ ed600d9 · licence, all uses