Hack (Fenlason)

Specifications
Released
Summer, 1982
Developers
Jay Fenlason
Kenny Woodland
Mike Thome
Jonathan Payne
Release Platform
PDP-11
Language
C
Source
Repository

Hack is a 1982 Rogue-inspired game that Nethack is ultimately based on. Hack was primarily written by Jay Fenlason, a high-school student, after playing Rogue for a day or two. A remarkable achievement, Rogue was closed source and Fenlason recreated the game from memory. The game was built for the PDP-11/70 and as a recreation of Rogue, it shares many of it’s properties; an ASCII, top-down, grid-based, dungeon crawler with procedural levels and permadeath.

A gameplay screenshot of Hack, though all Roguelikes tend to look quite similar. There's a `t` Troll and a `W` wraith here.
A gameplay screenshot of Hack, though all Roguelikes tend to look quite similar. There’s a t Troll and a W wraith here.

The content of this article uses the Hack source from “the original Hack source code submitted by Jay Fenlason and classmates for inclusion on the USENIX 1982-1 tape”.

Gameplay Video

A gameplay video of Hack, from the 1982 source release.

Setting

Hack, like Rogue, is a terminal game played on a mainframe terminal. The entire game is represented by ASCII characters. Each character represents one element of the game. The dungeon fills the entire screen, and you fight monsters, find loot, and search for staircases to venture ever deeper.

Goal

There’s no hard win condition but if you escape the dungeon you’re awarded a score based on the value of everything you’re carrying. The final level of the dungeon is a maze containing “the amulet of Frobozz”, and if you escape with this it’s worth 5000 points, far more than any other item, so that can be considered to be the real win condition.

In later versions of Hack, the amulet of Frobozz is renamed the amulet of Yendor to match Rogue.

Character Creation

There’s no character creation in Hack apart from typing in your name.

Stats

The stats are:

  • Level - experience level.
  • Gold - how much gold you’ve acquired.
  • HP - current and max hit points.
  • AC - armor class.
  • Str - strength that determines how hard you hit for.
  • Experience - used to level up.

Armor Class comes from Dungeons & Dragons and follows the same convention where the lower the armor class score the more armored the character. This differs from Rogue which has an arm stat where a higher value indicates a more armored character.

In addition to these stats there are around twenty-five other trackers for things like status and hunger.

Classes

As with Rogue there are no classes nor restricted actions in the game.

Input

This is a terminal game with keyboard input. The keyboard wouldn’t have been too far away from any modern QWERTY keyboard - see the photo below for an idea of what was used at the time.

A VT-100 terminal, the sort device that would have been used to interface with a PDP-11/70
A VT-100 terminal, the sort device that would have been used to interface with a PDP-11/70

Like Rogue and future rogue-likes Hack makes broad use of nearly every key the keyboard has to offer. Here are the controls, taken directly from the moves file in the source repository.

To move in a direction, use the following list:

  y  k  u
   \ | /
  h--@--l
   / | \
  b  j  n

Then you have a large number of keys, both uppercase and lowercase, for a wide variety of actions, including taking off armor, reading scrolls, naming unknown objects, and so on. Interestingly, the two most common actions - picking things up and attacking - do not have dedicated keys. To hit a monster, you simply move in its direction, and to pick up an item, you walk onto its tile.

Exploration

In Hack you start in a dungeon that you can explore a tile at a time. Each level begins black apart from your immediate area. Rooms are revealed as you enter them but corridors are only revealed a few tiles at a time. All levels are randomly generated. There are 25 to 29 levels, determined randomly on game start, and the final level is always a procedurally generated maze. Monsters are distributed according to the level depth. Monsters only ever spawn in rooms but it is possible to have them wander into corridors.

Procedural Dungeon

Hack has a procedural level generator. You can try it out below to see the kind of level it generates and if you press the step-by-step button you’ll get a feeling for how it works. For a deeper dive check out the Hack Dungeon Spark page.

 
HTML5 figure. If you're seeing this, your browser may not support HTML5.

Rogue’s dungeon generation worked on splitting the space into a grid, with nine cells, then randomly adding a room per cell and linking them with corridors. Hack’s algorithm is a bit more sophisticated, it attempts to place a room in each corner of the level, then sweeps from left to right attempting to place more rooms where they can fit. Then it sorts them and connects them left to right with corridors. Finally it adds a few additional corridors that can dead-end. Corridors can overlap or run directly next to each other, so the end results can look messier than Rogue’s but they’re more varied and arguably more fun to explore.

Traps

There are seven trap types

  • Bear trap — clamps your foot; you’re held in place for a few turns until you struggle free.
  • Arrow trap — fires an arrow at you (if it hits 0-6 damage).
  • Dart trap — a dart hits (if it hits 0-3 damage); 1-in-6 it’s poisoned.
  • Trapdoor — drops you through the floor to a level below (sometimes several in a row), landing at a random spot. On the bottom level (no down-stair) a rock falls on you instead for 2d10 damage.
  • Teleportation trap — teleports you to a random spot on the current level.
  • Pit — you fall in, stuck a few turns, 0-6 damage.
  • Sleeping-gas trap — a gas cloud knocks you out for up to ~25 turns.

Traps are hidden until you discover them — usually by springing one, or by searching using the s key. Once discovered they’re drawn as ^, and if you knowingly step on one there’s a 1-in-6 chance you avoid it. Traps get denser the deeper you go and below level 8 a “trap” has a 1-in-8 chance of actually being a mimic — a monster usually disguised as gold $ or a door + that hits you when you touch it.

Inventory

Items are scattered across the dungeon or dropped by monsters on death. You step on an item and you’ll try and pick it up. Equipable items can be enchanted or cursed and if they’re cursed you can’t remove them without finding a suitable scroll.

There’s also gold but it’s only used as a scoring mechanism or something to be stolen if you encounter a leprechaun.

Items

There are nine item types that you’ll see on the map.

Character Item type
" Amulet
[ Armor
% Food
? Scroll
! Potion
) Weapon
= Ring
* Gem/Rock
/ Wand

When you pick them up or examine them you can see the details of the specific item. The only amulet in the game is the Amulet of Frobozz so if you see " you’re a step closer to winning the game.

Items have various types for instance armor might be leather, ring, scale, chain, splint or plate in order of strength of defense.

Weight System

Hack restricts how much you can pick up. Weights are coded by item type rather than individual items (see the code below).

C
1// from hack.c2weight(obj)3register struct obj *obj;4{5  switch(obj->olet) {6  case '"': return(2);7  case '[': return(8);8  case '%': if(obj->otyp) return(obj->quan);9  case '?': return(3*obj->quan);10  case '!': return(2*obj->quan);11  case ')': if(obj->otyp==8) return(4);12    if(obj->otyp<4) return(obj->quan/2);13    return(3);14  case '=': return(1);15  case '*': return(obj->quan);16  case '/': return(3);17  default: pline("Bad weight %c",obj->olet);18    return(0);19  }20}

There’s a hard coded weight limit of 85, exceed this and you’ll get a message saying your pack is full. This is different to Rogue which had 23 item slots that can be used to store items.

Combat

Combat works much like the original Rogue to perform a melee attack; you walk into the enemy and blows are traded. Then to continue the battle you walk them into them again, to retreat you merely move away. There are ranged weapons and also magic scrolls that can inflict damage on enemies.

The weapon items include: arrow, sling bullet, crossbow bolt, dart, mace, axe, flail, long sword, two-handed sword, dagger, spear, bow, sling and the crossbow.

Calculate ToHit

Combat works by first determining if you hit.

C
1toHit = weapon_bonus 2    + player_level3    + opponents_armor_class4    + strength // scaled from -4 to +256if(toHit >= rnd(20))7  // YOU HIT, PROCEED TO DMG CALCULATION

weapon_bonus - A normal weapon gives 0 to hit bonus, except for two weapon types: daggers are +2 and two-handed swords are −1. Enchanted weapons can found in the dungeon up to a +3 to hit bonus and with enchant scrolls that can be pushed even higher. Cursed weapons give a negative to hit.

player_level - The higher your level, the more likely you are to land hits.

opponents_armor_class - Monsters have a fixed armor class based on their species.

strength - 3 STR is -4 and 18/100 is +2.

There are additional complications I’ve skipped over - such as a sleep and frozen states that make hitting more likely.

Calculate Damage

The damage calculation is quite complicated. Here’s a step-by-step.

  1. A base die is chosen depending on your weapon - A weapon → look up its damage die in a table. - Bare hands or a thrown non-weapon → 1d3. - wand of striking → special case we’re going to ignore :)
  2. Based on the monster size - big or small, choose an addition die based on the weapon. (e.g. long sword = 1d8 normally, 1d12 vs. large).
  3. Add special weapon bonuses. Mace is +1 against small. Flail +1d4 against small and large etc.
  4. Apply damage enchantment or curse.
  5. Add damage bonus from rings or other non-weapon damage bonuses.
  6. Clamp to 1, if you land a hit, you always do 1 damage minimum

Then the damage amount is applied to the monster and if they drop to 0 HP or below, they’re dead, you win! The monster attacking the player is a little simpler but follows the same pattern.

Magic

As in Rogue the only magic system is the use of scrolls, wands and potions. These items always work; there’s no fizzle chance.

The 15 potions are: restore strength, alcohol, invisibility, fruit juice, healing, paralysis, monster detection, object detection, sickness, confusion, gain strength, speed, blindness, gain level and extra healing.

The 15 scrolls are: enchant armor, confuse monster, blank, remove curse, enchant weapon, create monster, damage weapon, rust armor, genocide, light, teleport, gold detection, identify, magic mapping and fire.

And the 16 wands are light, secret-door/trap detection, create monster, striking, slow/speed monster, undead turning, polymorph, cancelation, teleport monster, digging, magic missile, fire, sleep, cold, and death.

When found, all these items are obscured - like “ruby potion” or “wooden wand” until their true nature is discovered and the real name is displayed. Equipping rings can also grant certain magical statuses but that’s more under the category of equipment.

Monsters

Hack has 56 monsters each represented by a character, the verbatim names are:

  • giant Ant
  • acid blob
  • Bat
  • giant beetle
  • Centaur
  • cockatrice
  • Dragon
  • displacer beast
  • floating Eye
  • ettin
  • Freezing sphere
  • fog cloud
  • Gnome
  • gelatenous cube
  • Hobgoblin
  • homonculous
  • Invisible stalker
  • imp
  • Jackal
  • jaguar
  • Kobold
  • killer bee
  • Leprechaun
  • leocrotta
  • Mimic
  • minotaur
  • Nymph
  • neo-otyugh
  • Orc
  • owlbear
  • Purple worm
  • piercer
  • Quasit
  • quivering blob
  • Rust monster
  • giant rat
  • Snake
  • giant scorpion
  • Troll
  • teleporter
  • Umber hulk
  • ugod
  • Vampire
  • violet fungi
  • Wraith
  • wumpus
  • Xorn
  • xerp
  • Yeti
  • yellow light
  • Zombie
  • zelomp

Four are drawn as symbols rather than letters:

  • chameleon (:)
  • lurker above (~)
  • trapper (,)
  • demon (&)

Rogue has 26 monsters, Hack contains all of them but the char casing is different. Hack transforms Rogue’s monsters to uppercase with a few switches: for violet fungi, Rogue draws it as f, but Hack puts it on lowercase v.

Advancement

Level-up thresholds use a simple formula — the XP needed to leave your current level L is:

exp_required = 10 × 2L−1.

So leaving level 1 needs 10 XP, level 2 needs 20, level 3 needs 40, and so on. There’s a cap at level 14, that’s as high as you can go by gaining experience.

C
1// hack.mon.c — after a slain monster's XP has been added2if(u.uexp < 10*ipow(u.ulevel-1)) return;   // not enough XP yet3if(u.ulevel > 13) return;                  // level 14 is the cap4pline(WCLEV, ++u.ulevel);                  // announce the new level5tmp = rnd(10);6if(tmp < 3) tmp = rnd(10);                 // 1d10 HP added (re-rolled once if low)7u.uhpmax += tmp;8u.uhp += tmp;

XP earned in combat is never reset, it keeps accumulating. There’s also a potion that can grant a level-up and this bypasses the level cap.

Systems

All systems in Hack are taken from Rogue unless otherwise stated.

Scoring System

Escape the dungeon or die and you’re given a score. All items have some value and this is combined with your goal to give your run a score.

Hunger Clock

There’s hunger in the game, you start with a satiety counter of 900 and it counts down every turn. A food ration restores 900 hunger points and fruit restores 100. There’s a 1-in-7 chance food is rotten which may inflict confusion, blindness or sleep.

You won’t die outright from hunger but there are effects at different thresholds:

  • < 151 Hungry: You get a message about being hungry.
  • < 51 Weak: You lose a point of strength. This is regained on eating food.
  • < 1 Fainting: “You faint from lack of food”. You’re paralyzed ~20 turns. This retriggers every 4-25 turns.

Wandering Monsters

Every turn, from the very first turn, there’s a 1 in 60 chance a wandering monster may spawn somewhere on the level. These monsters spawn “awake”, instead of the room monsters that are asleep and unreactive until you enter their room. Unlike Rogue, wandering monsters are not drawn from a special pool, they’re just any level-appropriate monster for the depth of the dungeon level.

Like the hunger clock this is another mechanic that incentivizes moving on deeper in the dungeon and not lingering around the level.

Cursed Items

Weapons, armour and rings can be generated cursed. Cursed items can’t be removed until the curse is lifted. A particular cursed ring can kill you by dropping your health to zero.

Knowledge System

Hack implements the same identification system as Rogue. Some potions and other items have random names, then identifying them reveals the true name. In the meantime you can use the c call command to name the items whatever you like. Certain items, like health potions, are revealed when you use them. However if you drink a Booze potion it’s not revealed and instead you’re prompted to name that potion type.

Development

Development began at the Lincoln-Sudbury Regional High School, the students there were taught by Brian Harvey who also set up the computer lab and acquired the PDP-11/70s for the school. Harvey encouraged the students to experiment and work on computer games. Among the students were Jay Fenlason, Jonathan Payne, Kenny Woodland and Mike Thome who together created Hack.

One of Lincoln Sudbury’s students using what looks like a vt100 terminal
One of Lincoln Sudbury’s students using what looks like a vt100 terminal

The summer between my sophomore and junior years, Brian [Harvey] invited some of us students to come out to California to [work as teacher’s assistants during] a summer class he was teaching at San Francisco State University. While we were out there, we took a trip to UC Berkeley, where I got to play Rogue for the first time.

I think I got a little bit obsessed then, and like any obsessed person who’d been cut off, I decided to build my own.

Jay Fenlason quoted in Dungeon Hacks by David L. Craddock 📖

Fenlason played Rogue for about 8 hours and from that he attempted to recreate the game. The first prototype was written for the Apple II using Turtle - a program written in Logo, an educational programming language - for doing graphics. This early version had movement and enemy behavior but was shortly ported over to C to continue development on the PDP-11/70.

Later in January 1982, Fenlason, Thome, and other students of Harvey’s made the 40-minute drive to Boston to attend the annual USENIX conference. Here they met Michael Toy and Ken Arnold the creators of Rogue - who were there to give a talk on the game. The students asked for source code but the Rogue authors politely refused.

Even without the original Rogue source, Hack quickly ticked off it’s features and went beyond adding new monsters, behaviors and a better dungeon generator.

Lincoln-Sudbury Regional High School 1981 yearbook photo of the Computer Society featuring Jay Fenlason.
Lincoln-Sudbury Regional High School 1981 yearbook photo of the Computer Society featuring Jay Fenlason.

Brian Harvey submitted the student projects, including Hack, for inclusion on the 1982 USENIX distribution tapes. USENIX was (and still is) the Unix users’ association, whose conferences were a main channel for sharing Unix software before the internet made that trivial. At these conferences, magnetic tapes containing collections were created and exchanged, allowing recipients to load the software onto their own systems. In the Hack source code Fenlason added a note granting permission for anyone to modify and distribute the code provided his copyright remained intact. So in comparison to Rogue, Hack was opensource and available for anyone to extend - and extend it they would.

Name

Fenlason dubbed his clone Hack for two reasons: “One definition was ‘a quick [computer] hack because I don’t have access to Rogue’. The other was ‘hack-n-slash’, a reference to one of the styles of playing Dungeons and Dragons.”

Jay Fenlason quoted in Dungeon Hacks by David L. Craddock 📖

Source Code

Until recently, Fenlason’s version of Hack had been thought lost, but in 2025 Brian Harvey provided his back-ups of the school’s PDP-11 which are now hosted at Sustainable-Games/fenlason-hack.

Legacy

Hack is similar to Rogue but it iterates on the design and extends some of the systems. However there’s nothing I would carve out as a brand new innovation, at least in the code. The legacy of Hack is its license and distribution.

This is an opensource game before opensource was really a word. Hack’s source code is distributed via the 1982-1 USENIX distribution tapes. These tapes are distributed at the Boston USENIX conference where Rogue authoroks Michael C. Toy and Kenneth C. R. C. Arnold are presenting a talk on Rogue: “Rogue: Where It Has Been, Why It Was There, and Why It Shouldn’t Have Been There in the First Place”.

Fenlason later recalled: “Usenix had biannual meetings, Unix users would get together and swap war stories. For each meeting they’d put together a tape of some of the contributed software. I put [Hack] on the tape and forgot about it until someone I know mentioned that the two most popular pieces of software on that particular tape were my silly game and my friend Jonathon’s text editor.”

Jay Fenlason quoted in History of Hack

Andries E. Brouwer was a mathematician and computer programmer working at the Centrum Wiskunde & Informatica (CWI) in Amsterdam. He was responsible for maintaining the games available on the institute’s Unix systems. In 1982 he installed a USENIX tape containing Jay Fenlason’s original version of Hack, making the game available to users at the institute and possibly other universities in Amsterdam. Brouwer gradually expanded and rewrote the game based on player feedback, adding features such as shops and fixing numerous bugs. On the 17th of December 1984 he released Hack 1.0 on the Usenet newsgroup net.sources. His versions of Hack formed the foundation from which NetHack was later developed.

Influences

Hack is basically a cleanroom reimplementation of Rogue and therefore it’s greatest and most direct influence is Rogue itself.

The Amulet of Frobozz is likely a reference to the Zork text-based adventure games. The second, 1981, Zork game even features the term in it’s title: “Zork II: The Wizard of Frobozz”.

Rogue

I don’t think the goal was ever really to clone Rogue as such, but to build a game that was satisfying in the same ways that Rogue was. Mike Thome

Further Reading

Here are a selection of resources used in the article and for further reading.