← All interactive demos

How RNG Manipulation Works — Interactive Demo

This is the treasure chest game from the video "How does RNG manipulation work in speedruns?", ready to play. Random numbers are read one by one from a table of 256 numbers (the same numbers as the table in the public source code of Wolfenstein 3D and DOOM). When you press Start, the table is read in this order: ① where the coin goes ② chest 1 ③ chest 2 ④ chest 3. If a chest's number is less than 16, it is rare. The treasure chest game is our own model.

1. Play (start with Space or the button below; press again to go back to the title)

Your results

#Frame pressedRead fromCoinChests 1, 2, 3
Task 1: press Start at frame 205 and get a rare (1 frame is 1/60 of a second). Around frame 205 (frames 197–213), if the coin appears second from the left, you hit the right frame. (Going once around the table, there are 33 positions where the coin lands second from the left, and most of them give a normal chest.)
Task 2: look at "2. The random number table" and find frames other than 205 where chest 1 is rare (table position = the remainder when the frame you pressed is divided by 256. Chest 1 is the number 2 places after it).

2. The random number table (256 numbers. Green = less than 16. Light blue box = coin, yellow box = chests)

3. Measure with 1000 people (the same way as in the video)

Timing error when pressing (spread)3 frames
We create 1000 people with random numbers, all aiming for frame 205 (the error is normally distributed with mean 0 and this spread; these are not measurements of real people).
What we measuredResult

Numbers from the video (seed 17, 1000 runs each): with the read-from-the-start version, 0 rares in 1000 runs. With the advance-on-the-title version, pressing anywhere between 1 and 5 seconds gives a rare 5.0% of the time. Aiming for frame 205 with a spread of 3 frames hits it exactly 13.6% of the time. Median time until a rare: pressing whenever 9.7 min, just aiming (checking the chests) 2.4 min, aiming and telling by the coin 1.1 min (one attempt: 1 s to the coin, 30 s to the chests, 3 s to reset, as set in this model). If it took only 1 s to reach the chests, it reverses: checking the chests 30.7 s, telling by the coin 35.1 s (because telling by the coin also throws away the rare that happens to come at frame 200).
In DOOM's public source code (m_random.c), each call moves one step through the 256-entry table, and the read position is reset to 0 when a new game starts. In the Wolfenstein 3D source code, demos start reading from 0, and normal play starts from the hundredths-of-a-second digit of the clock.
Sources and production: same as the video description (AI was used to make the diagrams and script. No game footage or characters are used).