Report #5 · Final Fantasy (NES) · Dragon Warrior (NES)

Dice You Can't See

Every miss, critical hit and “The Dragonlord is asleep” in these two NES classics comes out of a few lines of assembly. We read that code, rebuilt its dice exactly, then replayed two tool-assisted speedruns on a real cartridge dump to check the math against the game itself.

255possible turn orders per round in Final Fantasy — out of 6.2 billion
21%real crit rate of the Masmune; its own data says 6.3%
13 × 1/16“impossible” rolls in a row the TAS lands to beat Dragon Warrior's final boss at level 7

1Are the dice fair?

Final Fantasy doesn't compute random numbers at all. It keeps a 256-byte list inside the cartridge and reads the next entry every time the battle engine needs a roll. The list is never shuffled or reseeded — the reading position just moves forward by one. The list is supposed to contain every value from 0 to 255 exactly once. It doesn't.

FF1's battle dice contain $00 twice and never roll $95

The 256 entries of the battle table, one cell per possible value (row = high digit, column = low digit)

  • Appears twice
  • Appears once
000110220330440550660770880990AA0BB0CC0DD0EE0FF0$00: appears 2×$95: never appearsEvery other value: exactly once
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · bin/0F_FCF1_rngtable.bin (value counts only)

The walking-map dice use a different list that is a clean shuffle of 0–255. In battle, one value is missing and one is doubled — harmless for a single roll, but it means a "0% chance" is never quite zero (question 2). A comment in the Chaos death animation even warns that it depends on seeing every value once; the animation survives only because each tile it erases has two or three chances.

✓ EMULATOR E2 · 19,956/19,956 draws stepped exactly +1

The list never changes, so the only thing that decides your roll is where you are in it — and the battle menu burns one entry every time it checks the controller. Replaying TheAxeMan's tool-assisted run, we counted 3,713 draws spent purely on menu input. A TAS picks its roll by choosing when to press A. Against Kraken it steered the dice back to position 61 on 9 separate turns — and got the same two-hit critical for the same 81 damage every time.

Final Fantasy battle against Kraken showing 2 hits for 81 damage and a Critical hit message
Nine times against Kraken, the TAS lands a two-hit critical for exactly 81 damage — every time from battle-dice position 61.Final Fantasy (NES, 1990) · TASVideos 2079M (TheAxeMan), frame 172,684 · FCEUX 2.6.6
Final Fantasy: Chaos dissolving into scattered pixels after being defeated
Chaos dissolving. The effect draws its randomness from the same battle dice; a code comment warns it needs every value 0–255, but $95 never appears (it survives — each tile has 2–3 chances).Final Fantasy (NES, 1990) · TASVideos 2079M (TheAxeMan), frame 253,490 · FCEUX 2.6.6

Dragon Warrior does compute its dice: a 16-bit formula, next = 771 × state + 129, whose top byte is the roll. Over a full cycle every roll from 0 to 255 comes up exactly 128 times — perfectly fair one roll at a time. But the formula splits its 65,536 states into two separate loops of 32,768, a game stays on whichever loop it starts in, and consecutive rolls are tied together: most pairs can never happen.

Only 21,760 of 65,536 back-to-back roll pairs can ever happen in Dragon Warrior

Each blue pixel is a (this roll, next roll) pair the generator can produce

006464128128192192255255This roll (0–255)Next roll (0–255)Blue: pairs that can happenDark: pairs that never happen21,760 of 65,536 possiblepairs ever occur (33%)
Dragon Warrior (NES) · nmikstas/dragon-warrior-disassembly @ ebe6a13 · UpdateRandNum, Bank03.asm:668-691 ✓ EMULATOR E3 · 34,330 TAS rolls follow the formula

Your save file picks the dice. The two bytes that hold Dragon Warrior's dice are the same two bytes the game uses to checksum your adventure log. Every time it saves or verifies a log, the checksum is left behind as the new dice. In the TAS, the game checksums the brand-new log at frame 124 and the dice become exactly 43,321 — the value we get by running the game's checksum over those 30 save bytes ourselves. The hero's name is part of that data.

✓ EMULATOR E3 · checksum 43,321 = dice after save
Dragon Warrior name entry screen with the hero named Y
The TAS names its hero "Y". Seconds later the game checksums the new adventure log — and that checksum becomes the dice.Dragon Warrior (NES, 1989) · TASVideos 4050M (RationalMonkey), frame 108 · FCEUX 2.2.3

2What does "0 to 200" really mean?

Every physical swing in Final Fantasy rolls a number from 0 to 200. Roll at or under your hit chance and you connect; roll at or under the crit threshold and you crit; roll exactly 200 and you miss no matter what. But the game builds that roll by squeezing one byte (256 possibilities) into 201 slots. Something has to give: 55 of the outcomes get two bytes instead of one. On the real table it's lumpier still — the missing $95 knocks one of those back to a single byte (53 doubled), and the extra $00 gives roll 0 a third.

53 of FF1's 201 hit rolls are twice as likely as the rest — and roll 0 is three times as likely

How many of the 256 battle-dice values produce each 0–200 roll (the real cartridge table)

  • Cartridge
  • Perfectly fair (256 ÷ 201)
0123Values out of 256fair: 1.27050100150200Hit roll (0–200)Roll 0: 3/256
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · RandAX, bank_0B.asm:1562-1580; hit roll bank_0C.asm:4474-4512 FROM CODE

Three consequences you can feel in play. The automatic miss (roll 200) happens 1 time in 256, not 1 in 201, so the best possible hit chance is 99.61%. Roll 0 gets three of the 256 values — the doubled $00 from question 1 — so even a 0% crit rate or a spell with no chance to land still succeeds 1.17% of the time. And because of the squeeze, your real hit chance is never lower than a fair roll would give — it runs up to 0.78 percentage points higher.

FF1's dice are never stingy: your real hit chance is always at or above a fair roll's

Real chance to hit minus a perfectly fair 0–200 roll, in percentage points, for every hit chance

  • Real minus fair
+0.00+0.25+0.50+0.75+1.00Percentage points above fair0255075100125150175200Hit chance (after hit rate and evade)
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · cartridge table, roll <= hit chance and roll != 200 FROM CODE
Final Fantasy battle against Garland with the message Critical hit
"Critical hit!!" against Garland. Whether a swing hits or crits comes from one 0–200 roll.Final Fantasy (NES, 1990) · TASVideos 2079M (TheAxeMan), frame 4,773 · FCEUX 2.6.6

3Who goes first?

Each Final Fantasy round, the game lines up all 13 possible fighters — nine enemy slots, then your four heroes at the very back — and "shuffles" them by swapping two random slots, again and again. The comment in the code says it does this 16 times and admits the method is biased: a slot that never gets picked stays where it started. The loop actually runs 17 times (the counter starts at 17 and counts down to zero).

✓ EMULATOR E1 · 213/213 TAS rounds predicted exactly16-swap model: 16/213

We checked this against the real game. In every one of the 213 battle rounds of TheAxeMan's run, we read the dice position when the shuffle started, ran 17 swaps ourselves, and got the exact order the game wrote into memory. Assume 16 swaps and the prediction is right only 16 times.

A fighter stays in its starting slot 12.9% of the time — a fair shuffle would say 7.7%

Chance that each fighter (row) acts in each position (column); heroes start in positions 10–13. Lighter = more likely (the brightest cells are about 14%).

  • Rare
  • Common
Acts in position (1 = first)12345678910111213Fighter (starting slot)Enemy 1Enemy 2Enemy 3Enemy 4Enemy 5Enemy 6Enemy 7Enemy 8Enemy 9Hero 1Hero 2Hero 3Hero 4
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · DoBattleRound, bank_0C.asm:3199-3244 · exact Markov chain, ideal dice ✓ EMULATOR E1

With fair dice the damage is modest: heroes end up in the last four positions 34.9% of the time instead of 30.8%. On the real cartridge it's lumpier. The 34 rolls a shuffle uses are consecutive entries of the same fixed list, so there are only 255 possible shuffles in the whole game — and in none of them do your four heroes take positions 1 through 4.

Final Fantasy battle with nine enemies facing the party
A round against nine enemies. This round's order was shuffled from battle-dice position 91 — and our 17-swap model predicted the exact order the game produced.Final Fantasy (NES, 1990) · TASVideos 2079M (TheAxeMan), frame 12,894 · FCEUX 2.6.6

Dragon Warrior has no shuffle. Our earlier notes said it did — it doesn't. It's always one hero against one monster: a single roll at the start (your Agility × a random byte against the monster's Defense × another) decides who moves first, and then the two of you strictly alternate.

4The bugs that change the odds

Final Fantasy's source is famous for its bugs, and several of them rewrite the math quietly — no glitchy graphics, just different odds.

Your crit rate is your weapon's catalog number

Every weapon has a crit value in its data. The battle code never reads it. Instead it stores the weapon's position in the item list — 1 for Wooden Nunchucks up to 40 for the Masmune — as your crit threshold. The Masmune, listed at 10, crits on 54 of 256 rolls (21.1%) instead of 16 (6.3%). Late-game weapons get a huge boost; early ones barely change.

The Masmune crits 21.1% of the time — its own data says 6.3%

Chance per swing to crit: using the weapon's listed crit value vs. what the game actually uses (its item number)

  • Listed crit value
  • What the game uses
0%5%10%15%20%25%Chance to crit per swingWooden NunchucksRapierHand AxeLarge KnifeLong SwordSilver KnifeSilver AxeFlame SwordDragon SwordCoral SwordPower StaffMage StaffVorpalBane SwordKatanaXcalberMasmune
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · bank_0C.asm:5692-5697 ("BUGGED"), weapon data bin/0C_8000_weapondata.bin · cartridge dice ✓ EMULATOR E5 · crit in RAM = weapon number

We watched it happen. During TheAxeMan's run, the fighter's in-battle crit value in memory was 6 with the Short Sword (listed 5), 20 with the Flame Sword (listed 5) and 22 with the Dragon Sword (listed 10) — every round, the weapon's number.

Two more physical-attack bugs in the same routine: weapon slayer and elemental bonuses are wiped before the attack is calculated, so no weapon ever gets its +40 accuracy or +4 damage against the monsters it was designed for. FROM CODE

Running away ignores your level

The escape check was meant to compare your Luck against a random number from 0 to your level + 15. A bug reads a different byte instead — one that is 0 whenever your party is healthy — so the range is always 0 to 15. Luck 16 or more always escapes. The designers apparently wanted high-level characters to find running harder; instead it's flat forever.

With 15 Luck you escape 93.8% of the time at any level — as intended it would fall to 23.4% by level 50

Chance to run away for a character with 15 Luck, healthy party, by character level

  • What the game does
  • Intended formula
0%25%50%75%100%Chance to escapeLv 1Lv 10Lv 20Lv 30Lv 40Lv 50Character level
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · bank_0C.asm:3773-3808 ("BUGGED - Reading wrong value") · cartridge dice FROM CODE
Final Fantasy battle showing the message Can't run
"Can't run." The escape roll was meant to use the runner's level; a bug reads a different byte, so level never matters.Final Fantasy (NES, 1990) · TASVideos 2079M (TheAxeMan), frame 2,943 · FCEUX 2.6.6

A miss can still stun you

Some monsters' attacks carry a status effect. The code is supposed to roll for it only when that swing connects — but it actually rolls whenever any earlier swing in the attack connected. Against CRAWL's eight-hit stunning attack, the better you are at dodging, the more the bug costs you: at 160 evade the stun lands 54.2% of the time instead of 27.1%.

High evade barely protects you from CRAWL's stun: 54.2% instead of 27.1% at 160 evade

Chance CRAWL's 8-hit attack stuns a party member with 50 magic defense, by the target's evade (ideal dice)

  • What the game does
  • Intended
0%25%50%75%100%Chance to be stunned per attack04080120160Target's evade
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · bank_0C.asm:4528-4583 · CRAWL: 8 hits, hit rate 21 FROM CODE

5When more attack means less damage

Dragon Warrior's hit formula starts from your margin: your Attack minus half the monster's Defense. With a margin of 2 or more, damage is a random amount between a quarter and half of it. Below 2, the game switches to a "weak" formula: a coin flip between 0 and 1 damage. The two formulas don't line up — so at the bottom of the scale, adding attack makes you worse.

A margin of 2 averages 0.33 damage — less than a margin of 1 (0.50)

Average damage per hit by margin (your Attack − half the monster's Defense), before excellent moves and dodges

  • Average damage
02468Average damage per hit02468101214161820Margin (Attack − Defense ÷ 2)margin 2: 0.33
Dragon Warrior (NES) · nmikstas/dragon-warrior-disassembly @ ebe6a13 · PlyrCalcHitDmg, Bank03.asm:8491-8561 ✓ EMULATOR E4 · 21/21 TAS hits match

The same trick runs the other way, and it matters much more. When a monster attacks you, the game switches to a weak formula once your Defense reaches twice its (rounded-up) half-Attack. There is no gradual slope — one point of Defense flips the formula. Against an Axe Knight (Attack 94), going from 93 to 94 Defense drops its average hit from 17.6 to 8.1 and its best hit from 24 to 16.

One point of Defense halves an Axe Knight's hits: 17.6 → 8.1 average at 94 Defense

Axe Knight's damage per hit by your Defense: average (line) and full range (band)

  • Average hit
  • Range (min–max)
05101520253035Damage per Axe Knight hit60708090100110120130Your Defenseweak formula from 94
Dragon Warrior (NES) · nmikstas/dragon-warrior-disassembly @ ebe6a13 · EnCalcHitDmg, Bank03.asm:8502-8531 FROM CODE

And then there's the excellent move: 1 swing in 32 ignores the monster's Defense entirely and deals between half and all of your Attack. It's the only practical way a low-level hero hurts a Metal Slime (Defense 255) — which is exactly how the TAS levels up. Every hit we logged in the run matched the formulas exactly: 21 of 21, including all 8 excellent moves.

Dragon Warrior: level 1 hero lands an excellent move on a Metal Slime
A level-1 hero one-shots a Metal Slime (Defense 255) with an excellent move: 1-in-32 hits ignore defense entirely.Dragon Warrior (NES, 1989) · TASVideos 4050M (RationalMonkey), frame 5,774 · FCEUX 2.2.3
Dragon Warrior: the Wraith Knight attacks and the hero's hit points decrease by 28
"Thy Hits decreased by 28." Monster damage uses a different formula whenever your Defense is high enough — with a cliff at the switch-over.Dragon Warrior (NES, 1989) · TASVideos 4050M (RationalMonkey), frame 27,928 · FCEUX 2.2.3

6What the comments say vs. what the code does

Disassemblies come with comments written by the people who reverse-engineered them — and sometimes the comment and the instruction under it disagree. We also check our own earlier notes. Here is every mismatch we found that changes a number.

GameTopicThe note saysThe code doesWhere
DW1Monster wakes up1 in 493 in 256 (36.3%)Bank03.asm:7654-7660
DW1Monster HURT damage7 to 103 to 10Bank03.asm:7821-7830
DW1Best monster dodge22% (14/63)23.4% (15/64)Bank03.asm:6783-6796
DW1Weak monster hit multiplierAttack - Defense/2Attack/2 + 1Bank03.asm:8502-8531
FF1Turn-order shuffle16 swaps17 swapsbank_0C.asm:3211-3244
FF1Battle dice cover every valueevery value once per 256 calls$00 twice, $95 neverbank_0F.asm:13811-13813
DW1"Biased turn-order shuffle" (our notes)exists (our walkthrough 004)no shuffle in DW1 at all (it's FF1's bug)Bank03.asm (whole battle engine)
DW1"Escape uses the wrong level" (our notes)bug (our walkthrough 004)no level is read; monster Defense is the evasion statBank03.asm:8256-8325

The sleep comment is the best example. A sleeping Dragon Warrior monster rerolls until the last two bits of a random byte aren't both zero, then wakes on a 1. The comment calls that 1 in 4. With fair dice it's 1 in 3. On the game's actual generator — where each roll depends on the one before — it's 93 in 256.

A sleeping monster wakes 36.3% of the time — the comment says 25%

Chance a sleeping Dragon Warrior monster wakes up on its turn

  • The real generator
  • Comment / fair dice
0%10%20%30%40%Code commentFair diceReal generator25.0%33.3%36.3%
Dragon Warrior (NES) · nmikstas/dragon-warrior-disassembly @ ebe6a13 · Bank03.asm:7654-7660 · exact: every state on the generator's cycle FROM CODE

"Immune" is never immune

Dragon Warrior's spell resistances run from 0 to 15, and a spell fails when a 0–15 roll comes in under the resistance. Even the maximum, 15, leaves one roll that lands: 1 in 16. The Dragonlord's true form has maximum resistance to SLEEP and HURT. The TAS beats him at level 7 with 4 HP anyway — by landing that 1-in-16 roll 13 times in a row: one SLEEP, then 12 HURTs for 12, 12, 12, 11, 9, 11, 11, 11, 11, 9, 9, 12 damage. That adds up to exactly 130, his entire HP bar. With fair, unmanipulated dice, thirteen straight successes happen about once in 4,503,599,627,370,496 tries.

✓ EMULATOR E4 · 13/13 max-resistance rolls passed · 130 = 130 HP
Dragon Warrior: the hero puts the Dragonlord's true form to sleep
The true Dragonlord resists SLEEP at the maximum (15 of 15). It still lands 1 time in 16 — and the TAS makes it land.Dragon Warrior (NES, 1989) · TASVideos 4050M (RationalMonkey), frame 56,651 · FCEUX 2.2.3
Dragon Warrior: the final HURT spell reduces the Dragonlord's hit points by 12
The finishing HURT. Thirteen 1-in-16 resistance checks in a row, and twelve HURTs totalling exactly 130 — the Dragonlord's HP.Dragon Warrior (NES, 1989) · TASVideos 4050M (RationalMonkey), frame 60,555 · FCEUX 2.2.3

Dice Lab

Plug in your own numbers. Both calculators use the exact formulas above (tested to match our analysis code case for case) and open on stats read straight from the speedruns' memory.

Preset: TheAxeMan's fighter vs KRAKEN — Flame Sword, Damage 39, Hit% 51, read from RAM at frame 170,492 of TAS 2079M.

0–255
0–255
Swings per attack2
Hit chance per swing68.0% (174/256)
Crit chance per swing10.9% (threshold 20)
Average damage per attack19.3
Kills a full-HP KRAKEN in one attack0.00%
Damage roll capped at 2550.0%

Damage per attack against KRAKEN: 19.3 on average

All 2 swings combined; crit value 20 (weapon number); real cartridge dice

  • Chance
0%20%40%60%098189Damage per attack
Final Fantasy (NES) · Entroper/FF1Disassembly @ ea16eae · Dice Lab

How we know

Two kinds of evidence

FROM CODE means the number comes from reading the disassembled game code and computing every possible outcome exactly. ✓ EMULATOR E# means we also watched it happen: we replayed a published TAS from power-on on our own cartridge dumps in the FCEUX emulator, with a script that only reads the game's memory — it never changes anything — and compared what the game did with what our model predicted.

  • E1 — FF1 turn order: 213/213 rounds predicted exactly (16-swap control: 16).
  • E2 — FF1 battle dice: 19,957 draws, each exactly one step along the table.
  • E3 — DW1 generator: 34,330 of 34,342 calls follow 771 × state + 129; 10 are the known dodge-roll write-back and 1 is the save-checksum seed.
  • E4 — DW1 damage and spells: 21/21 hits recomputed exactly; 13/13 maximum-resistance rolls passed against the Dragonlord.
  • E5 — FF1 crit bug: the fighter's crit value in memory equals the weapon's item number in every logged round.

Dice models

  • Real cartridge (FF1): every position in the 256-entry battle table is equally likely when an action starts; values follow the table, including its doubled $00 and missing $95.
  • Exact (DW1): every state on the generator's 32,768-step loop is equally likely; consecutive calls are chained.
  • Ideal: every byte 0–255 equally likely and independent — used for comparison.

Where the position is “equally likely”, that is an assumption: in real play it is set by your button timing, which is exactly what a TAS controls.

Sources

Every screenshot on this page is a real frame from those replays, scaled 4× with no smoothing. Nothing was edited, patched or hacked into place; frames the runs never reach are simply not shown.