Details

Doom quickly became a cult classic soon after its release in the mid-1990s. Surprisingly though, the way it handles random number generation is extremely primitive: the numbers are simply indexes in a hard-coded table of 256 values. The only calculation being performed is moving the pointer to the next index. This shockingly simple method works quite well, suggesting that perhaps this table was originally created using the output of a more advanced PRNG.

Another advantage of such a simple PRNG is that it makes syncing multiplayer games much easier, as their PRNGs would always return the same output. It also permitted players to make recordings of their adventure, as the random number rolls were guaranteed to be the same during playback.

However, the obvious limits to this design ensured that it would never pass the Period or Plot tests.

Pseudocode

// Adapted from the source at
// https://github.com/id-Software/DOOM

// The current state value
state = 0;

// PRNG table
values = [ ... ];

// random number generator
function RandomNumber() {

	// Return the new value
	return values[state];

	// Move to the next slot
	state++;
	if (state >= count(values)) {
		state = 0;
	}
}
			


Test Results

Period Length Test

SeedPeriod LengthResult
1138258Failed
65535258Failed
8675309258Failed
16777216258Failed
123456789258Failed
Minimum to Pass: 64,000

Plot Test

 

Count the 1s Test

Seed% Bits that are 1sResult
113849.52%Passed
6553549.52%Passed
867530949.53%Passed
1677721649.50%Passed
12345678949.51%Passed
Minimum to Pass: 45%

Dartboard Test

SeedDarts PlacedResult
1138127Failed
65535128Failed
8675309128Failed
16777216126Failed
123456789128Failed
Minimum to Pass: 2,600

Crush Test

SeedCompression RateResult
11384.72%Failed
655354.73%Failed
86753094.74%Failed
167772164.73%Failed
1234567894.73%Failed
Minimum to Pass: 95%

Unique Bytes Test

SeedUnique High BytesUnique Low BytesResult
1138165165Passed
65535165165Passed
8675309165165Passed
16777216165165Passed
123456789165165Passed
Minimum to Pass: 160

High/Low Byte Test

SeedHigh After HighHigh After LowLow After HighLow After LowSpreadResult
11382604244224412512233Passed
655352592244224432522229Passed
86753092593244424442518223Passed
167772162591244124422525233Passed
1234567892595244024402524239Passed
Maximum to Pass: 500

Distribution Test

Seed113865535867530916777216123456789
0.0 to 0.1888886887889889
0.1 to 0.2927926923926930
0.2 to 0.310821081108210811080
0.3 to 0.411591159116011581157
0.4 to 0.5969962966962963
0.5 to 0.610391046104210461042
0.6 to 0.71004100610091007999
0.7 to 0.810011006100510061008
0.8 to 0.9850848847848853
0.9 to 1.010041003100210021004
Spread655679677675657
ResultFailedFailedFailedFailedFailed
Maximum to Pass: 500

Sample Output

178252182202182141197481181
2421454239227156198225193219
9312217524901751437023946
24616353163109168135223525
9220145138776916678176173
21216611394161415023949111
16470602371717513615611
564214613822973146776198
196135106631971958696203113
101170247181113802501087255


A WFTID Website