Developer's Handbook for "Rogue: Amulet of Aivilo"

Version of the Developers's Handbook: 1.0.0
Version of the game: 1.0.0 Vanilla

Table of Contents

  1. Overview and development process
  2. Layout and Structure of a Game Screen
    1. Chebyshev Distance & Monster Behaviour
    2. How Monsters Move and Behave
      1. Turn order
      2. Aggro radius: chase or wander (Manhattan distance)
      3. The footstep early warning
      4. How a chasing monster picks its step (greedy pursuit)
      5. Stepping into the player: the attack
      6. Some more Monster facts
  3. Player Progression, Chests & Monsters
    1. Levelling Up
    2. Strength (STR)
    3. Chests - the Peculiarities
    4. Monster Strength over the Run
    5. The 26 Monster Types
  4. Example: The player's odds of reaching Level 26 and winning
  5. Random Labyrinths Generation on the NES: Challenges and Constraints
  6. Four Notable Fun Facts

 

 

Overview and development process

Rogue: Amulet of Aivilo is a roguelike game for the Nintendo Entertainment System (NES). First, a custom 6502 assembler, a cycle-oriented emulator (with the ability to automatically test game sequences) and a test/regression tool for verifying the defined game mechanics rules were developed; the game itself was then written entirely in assembler using this toolchain.


Layout and Structure of a Game Screen

The original Rogue (1980, Michael Toy, Glenn Wichman, and Ken Arnold, University of California, Berkeley) ran on Unix terminals of the time, such as the DEC VT100. The game could display up to 24 lines, each containing 80 ASCII characters (up to 1,920 single symbols).

The Nintendo Entertainment System renders a 256x240-pixel frame (NTSC), divided into a fixed grid of 32x30 tiles (960 tiles in total) of 8x8 pixels each. That's why individual labyrinths may be less complex, but the available resources were still sufficient to develop a challenging game.

Rogue: Amulet of Aivilo on the NES uses these 960 tiles as follows:

RegionRowsTiles usedPurpose
Information barrow 11 x 32 = 32 tilesCombat and event messages ("YOU HIT THE RAT, -1 HP", footstep warnings)
Dungeonrows 2-2524 x 32 = 768 tilesOne entire labyrinth
HUDrows 26-283 x 32 = 96 tilesTwo-column status display

If you’d like to gain a deeper insight into the game’s mechanics, take a look at this page: Maze Generation on the NES: Challenges and Constraints

Chebyshev Distance & Monster Behaviour

The Chebyshev Distance (the 7x7 grid from the player's perspective)

. . . . . . .
. . . . . . .
. . . . . . .
. . . @ . . .
. . . . . . .
. . . . . . .
. . . . . . .

A monster is drawn on screen - its letter becomes visible - if and only if:

  1. its Chebyshev distance to the player is 3 or less, and
  2. the field it stands on has already been explored (the fog-of-war memory).

This produces the 7x7 window: three squares to the left of the player, three to the right, three above, three below, plus the player's own square in the centre - seven columns by seven rows, diagonals included.

How Monsters Move and Behave

Turn order

The dungeon is strictly round-based: every monster takes exactly one step per player action. Stand still and the world stands still. There is no clock ticking - resting, waiting and planning a route are possible without fear. However, anything the player does (walking, bumping, drinking a potion) grants every living monster one move in return.

Aggro radius: chase or wander (Manhattan distance)

Each monster continuously measures its separation from the player using the Manhattan distance (the "taxicab" metric):

  • Manhattan distance ≤ 6: the monster gives chase.
  • Manhattan distance ≥ 7: it loses interest and wanders - one step in a random orthogonal direction, chosen freshly each turn.

Practically speaking, a monster needs to be within about six squares' walking distance to notice you. Because the aggro check uses Manhattan while the sight window uses Chebyshev metrics, a monster can chase you while remaining invisible - particularly across an open hall diagonally.

The footstep early warning

If a monster is chasing at a Manhattan distance of 4 to 6 - outside the visible 7x7 window - then each turn brings a one-in-four chance of a warning: the message "YOU HEAR FOOTSTEPS NEARBY" plus a soft step sound. Three design details are worth knowing:

  • The chance is deliberately generous (1/4).
  • The random draw comes from the frame counter, not from the game's level-generator RNG, so the warning never disturbs the dungeon's own randomness.
  • The warning deliberately may overwrite another message on screen.
How a chasing monster picks its step (greedy pursuit)

A chasing monster always moves greedily towards the player, one square per turn, orthogonal moves only (it never cuts diagonals):

  1. It compares the horizontal and vertical separations and tries the larger axis first - a monster four squares east and one north steps east.
  2. If that square is blocked (wall, player, another monster, chest, bottle, ...), it tries the other axis instead.
  3. If both are blocked, it stays put for this turn - no shuffling, no jumping over obstacles.
Stepping into the player: the attack

A monster blocked because the player stands in its way does not move - it attacks instead. Standing next to a chasing monster is therefore always answered with a blow; blocking a corridor with your own body is not a safe wall.

Some more Monster facts
  • Monsters only ever step onto plain floor; walls, stairs, chests, gold, bottles and other monsters are impassable.
  • At most four monsters exist on a level at any time: the three spawned with the level plus, on even levels, possibly one hidden chest monster.

 


 

Player Progression, Chests & Monsters

Levelling Up

  • Every descent grants +3 HP - but only if the player's current HP are below the maximum.
  • Every third dungeon level (i.e. upon descending to levels 3, 6, 9, 12, ...) the player receives +2 HP and +2 max HP automatically as part of the descent.
  • Maximum HP has a second growth source: blue potions grant +1 max HP each (applied before their +5 HP heal, so the heal may use the new maximum).
  • There is no experience-point system; health growth is purely rule-based from levels and potions.
Situation on descendingEffect
HP below maximum+3 HP, capped at max HP
HP already fullno healing
Level 3, 6, 9, ... (every third)additionally +2 max HP and +2 current HP (current HP therefore rise beyond the old maximum)

Strength (STR)

  • STR determines the damage dealt per successful hit in combat.
  • STR starts at 1 and is raised by the cumulative kill count, thresholds at 10 and 25, each granting +1 STR, capped at 3. The counter never resets, so progress cannot be lost.
  • Character strength thus rises through fighting.

Chests - the Peculiarities

  • Chests appear on even-numbered levels; odd levels have none.
  • Contents: gold (5–12), a red or blue potion, or a hidden monster - opening it may spawn a monster right on the chest's own position ("AN OGRE HAS APPEARED"), which immediately attacks.
  • Pity system: a small counter remembers bad chest luck. Every chest that contains gold or a monster increments it; finding a potion resets it - nudging subsequent chests gently back towards potions after unlucky streaks.
  • If the player still stands on the chest's field, the game pushes the player to a neighbouring free field and places the loot on the freed tile.

Monster Strength over the Run

  • Each monster's starting HP comes from a fixed per-type table (see below), then gains a depth bonus of +1 HP per three dungeon levels (floor(level / 3)). Example: a RAT (2 HP base) has 2 HP on levels 1 - 2, 3 HP on levels 3 - 5, and 10 HP on level 26.
  • Early-game: on levels 1 - 3 only the low-HP (2) types spawn; all 26 monsters can appear from level 4.
  • Monster damage stays constant (1 HP per hit, ARM absorbs a hit at 0 HP loss); what changes with depth is durability, not the hit.

The 26 Monster Types

We are not particularly knowledgeable about various mythologies. Please forgive us if some of the creatures on this list don't really belong here. We chose them based solely on their names. ;-)

LetterNameBase HP
AANT2
BBAT2
CCOBRA3
DDEMON5
EELF2
FFIEND3
GGNOME2
HHARPY4
IIMP2
JJACKAL2
KKOBOLD2
LLICH4
MMIMIC2
NNYMPH2
OOGRE4
PPHANTOM2
QQUASIT2
RRAT2
SSKELETON2
TTROLL2
UURCHIN2
VVAMPIRE2
WWRAITH3
XXORN2
YYETI3
ZZOMBIE2

 


Example: The player's odds of reaching Level 26 and winning

This calculation assumes the game version 1.0.0 Vanilla. Despite all theoretical probabilities, there is always an element of chance that - along with your own playstyle - can indirectly determine whether a playthrough is won or lost.

The maths of a single encounter

Every bump against a monster resolves as follows: a 50/50 coin toss decides who strikes, the striker misses in one of four attempts.

So each bump:

  • deals damage to the monster with probability 0.5 × 0.75 = 37.5%,
  • is wasted (player wins but misses) with 12.5%,
  • hands the turn to the monster with 50%, of which it lands its blow 75% of the time.

Now the ARM peculiarity: each landed monster blow costs the player 1 HP only when ARM = 0. As long as armour charges remain, every single monster hit is absorbed completely ("THE X HITS YOUR ARMOR, −0 HP") and merely consumes one ARM charge. So the expected damage per bump is conditional:

  • during the descent (ARM = 0): 0.5 × 0.75 = 0.375 HP lost per bump, since ARM can only ever be obtained on level 26,
  • after collecting the amulet (ARM = 4): exactly 0 HP for the first four landed hits; ARM only then runs dry.

For the typical early enemy (a 2-HP type at STR 1): the player needs 2 damaging hits, i.e. an expected 5.3 bumps per kill, costing an expected 2 HP per kill. Against the +3 HP heal per descent, a level only "pays off" if the player fighting at ARM 0 clears fewer than about one-and-a-half monsters per level on average.

"Monte Carlo" simulation (30,000 runs each)

Using a strategy model with the game's real mechanics (+3 heal per descent, +2 max HP per third level, red potions as an emergency gamble, monster HP by type plus depth bonus, drops at 1/12, STR at 10/25/45 kills, and the level-26 amulet reward of full heal + 4 ARM charges + 2 blue potions for the climb back):

Forced fights per level (player style)Chance of a complete win
~ 0.5 (cautious, dodges most monsters)~ 54%
~ 1.0 (pragmatic)~ 24%
~ 1.5 (aggressive explorer)~ 7%
~ 2.5 (fights everything)~ 0.4%

The figures confirm the game design (as of version 1.0.0 Vanilla) intent: the game is beatable, but only for a cautious player. Someone who treats it as a hack-and-slash will statistically not survive the descent - precisely because there is no ARM to lean on before level 26.

Why level 26 specifically, and why ARM makes the return a victory lap

The descent is the bottleneck. Monsters grow by +1 HP per three levels, so a common 2-HP foe becomes a 10-HP foe on level 26 - the expected cost of killing one quadruples exactly as the player's healing income stays flat, all of it at ARM 0.

The climb back up is deliberately safe thanks to ARM: collecting the amulet refills health completely and grants 4 armour (ARM) charges plus 2 free blue potions ("AMULET COLLECTED! ARM +4"). Effectively the player travels with 4 guaranteed free hits (ARM) plus up to 10 more from the two blue potions, on top of a fully restored health pool of roughly 30 HP and the +3 heal per ascent.

In simulation terms, a player who leaves level 26 healthy almost always survives monsters met on the way up - the failure cases on the return route are nearly all staircase-hunting delays, not combat.

Empirical corroboration from the real game

Our scripted (automatic) gameplays match these numbers strikingly: seven of eight fully automated playthroughs died in ordinary combat on the way down - every single one of them at ARM 0, as the design dictates - and the single successful run captured in the 1:1 frame video collected the amulet with an empty armour gauge, then coasted "home" to level 1.

See a "perfect run" it in action: You'll find the link to the video in the section "Four Notable Fun Facts" under point 3 "Deterministic game testing".

A careful human player manages in roughly one run in four; a careless one wins about as often as a lottery.

Bottom line: The descent is a knife-edge walk without any armour - roughly a quarter to a half of careful runs make it to level 26 - while the ascent flips the risk profile: ARM +4, the full heal and two blue potions turn the escape into the safest stretch of the entire game.


Random Labyrinths Generation on the NES: Challenges and Constraints

The Hardware's Fundamental Numbers

ResourceValueConsequence for the maze
Screen256x240 pixels, 32x30 tiles of 8x8 pixels eachThe entire visible playing field must fit on a single fixed screen page
Tile8x8 pixels (16 bytes of CHR: 8 bytes each of graphic and colour plane)Walls, floors, characters, text: everything lives on this grid
RAM (CPU side)2,048 bytes in totalMap, monsters, HUD, RNG, queue - everything shares these 2 KB
CHR-ROM8 KB = 512 tilesGame tileset in bank 0 ($0000), title screen in bank 1 ($1000)
PRG-ROM16 KB (Mapper 0, no bank switching)The complete code, including maze generator, monster mechanics and SFX (currently ~11.8 KB)

How Much Maze Fits In?

The game reserves the range $0400–$06FF = 768 bytes in RAM for the dungeon map: 32 columns × 24 rows. That is the maximum logical maze size available: 768 tiles. On top of that:

  • $0700 onwards: the "explored" bitmap (SEEN) for the fog of war - 1 bit per tile, 4 bytes per row, i.e. 32×24/8 = 96 bytes,
  • $0300–$032F: the generator's room data (x, y, w, h, centre for each of 8 rooms),
  • $0200: the PPU update queue (3 bytes per entry),
  • $00–$7F: the zero page (player, monster slots, RNG, temporaries).

The 2 KB ceiling therefore dictates the world size directly: no scrolling, no large levels - one screen page is the entire level.

The Actual Challenges

1. The CPU's time budget

The Ricoh 2A03 (a MOS 6502 derivative) runs at ~1.79 MHz (NTSC); per frame (~16.6 ms) there are roughly 29,000 cycles available. Level generation must finish between two frames or run with rendering switched off (black screen) - which is exactly what the game does, hence the brief black flash when changing levels.

2. The VBlank write budget

The PPU cannot be written to during the visible picture; only about 2,270 cycles of VBlank remain per frame. That is why every map update flows through a queue of at most 25 entries per frame (three bytes each, buffered): a deliberate cap, verified in the NMI handler, ensuring the 25 tile updates plus the 32-byte message line always fit inside the VBlank window together.

3. RAM economy

The generator works with just 8 room records - laid out as six arrays of eight bytes each (x, y, width, height, centre-x, centre-y), 48 bytes in total. Nothing larger fits alongside the 768-byte map, the 96-byte exploration bitmap and the game state. The generator therefore works entirely from this minimal state and burns its results straight into the map array. A structural safeguard exist: a fallback guarantees at least one room per level.

4. Determinism as a design constraint

The RNG is a 16-bit Galois LFSR (polynomial $B400, period 65,535) living in the zero page, re-seeded at the start of every level from the frame counter XOR the level number, followed by a 16-31-round warm-up and a zero-state lock (the LFSR must never hold 0). A consequence follows. Within a level, the draw order is sacred: any "contamination" with additional randomness - the "footstep" warning, for instance - must draw from the frame counter so the level's own number stream never drifts.

5. Connectivity by construction

Random mazes can cut the player off from the key or the stairs; the game's generator avoids that fate structurally rather than by repair. Rooms are carved first (up to 8, at most 20 placement attempts, each new room requiring an intact wall ring); then L-shaped corridors connect each room's centre to the next room's centre, chaining every room into one connected component. The stairs are placed in the centre of the last room, which the corridor chain reaches; the key additionally refuses the stairs tile, the player's start and the first room's centre when dropping. A separate fallback exists for monster spawning - after 20 failed random attempts, the three per-level monsters are placed deterministically on the first free floor tiles.

6. Visibility across 768 cells

Fog of war at 1 bit per tile (96 bytes, 4 bytes per row) is cheap to keep, but the sight window (7x7 Chebyshev) and the exploration bitmap must stay in sync on every step without overloading the queue: the game redraws a monster's letter only when its new square is both within the window and already explored, and erases the abandoned square only if it was explored. Invisible movement is deliberately "forgotten", which is what makes the "footstep" warning necessary in the first place.


Four Notable Fun Facts

  1. Everything is background tiles. No sprite is used anywhere. All monsters, the player, collectable items and text are single tiles in the nametable, drawn through a queue system processed during VBlank.
  2. A font with history. The letters come from a digitised Amstrad CPC-464 typeface.
  3. Deterministic game testing. The entire game can be tested without a screen: After numerous attempts, a script-driven run was deterministically successful ("Seed Run #164" with a fixed sequence of keystrokes resulted in a real victory), which made it possible to create a complete 1:1 frame-by-frame recording of the entire playthrough as approximately 50,000 PNG files.
    The images compiled into a video: Youtube - the perfect run
  4. Strict regression discipline. Every change is verified against a growing test tool, currently 311 checks, 0 failures, including byte-level CHR assertions and font-map signature checks in the ROM.