Test Results: Doom's PRNG



Implementation

Doom by id Software may be a cult classic, but the way it handles random numbers is unexpectedly primitive.

Within the game's binary is a table listing 256 "random" bytes, and the game keeps track of the current position in the table. When a random number is needed, it simply returns the value at the current position and moves to the next entry. No other calculations are done.

This might seem like a terrible way to handle randomness, especially in a video game, but it does allow for some interesting features. For example, this ensures that online games are syncronized, and it's also the secret behind Doom's ability to record gameplay.



Test Results

Period Length Test
SEEDNumber indicates how many results could be obtained before the generator fell into a loop.
1138256FAIL
65535256FAIL
8675309256FAIL
16777216256FAIL
123456789256FAIL


Dice Roll Test
This is a surprisingly good distribution, suggesting that the table was created using values from an actual PRNG.


Dartboard Test
SEEDMinimum of 6,000 darts placed needed to pass.
1138126FAIL
65535126FAIL
8675309126FAIL
16777216126FAIL
123456789126FAIL


Crush Test
SEED70% or higher required to pass.
11384%FAIL
655354%FAIL
86753094%FAIL
167772164%FAIL
1234567894%FAIL


Plot Test
With its small range of values, Doom's PRNG didn't have a chance at passing this test.


Example Output
0810922022224114910775248254140166674212114780242
15427205128161897736951108548212140211249227920050
28188521402021206814562701841909119715222414910425178
252182202182141197481181242145423922715619822519321993
122175249017514370239462461635316310916813522352592
2014513877691667817617321216611394161415023949111164
70602371717513615611564214613822973146776198196
135106631971958696203113101170247181113802501087255237
1292267910711216610324124223239120198586082128318466
143224145224812061634563901681145933159952813912398
12519615701942535414109226711716193186872441382052
123251263617465223123276312218437216165212106197242
9843391752541451908411822218713612016323624908109220
2222411491077524825414016667421211478024215427205128
1618977369511085482121402112492279200502818852140
2021206814562701841909119715222414910425178252182202182
1411974811812421454239227156198225193219931221752490
175143702394624616353163109168135223525922014513877
6916678176173212166113941614150239491111647060237
171751361561156421461382297314677619819613510663197


A WFTID Website