RNG: Difference between revisions

148 bytes removed ,  15 October 2018
No edit summary
Line 20: Line 20:
</nowiki>
</nowiki>
===Description===
===Description===
[[File:RNG Graph.png|500px|right|A graph showing notable RNG values and indeces in SM64.]]
[[File:RNG Graph.png|500px|right|A graph showing notable RNG values and indices in SM64.]]
The function has 65536 possible inputs and 65536 possible outputs. It is a bijection, meaning that every input maps to exactly one output and none repeat or are left out. The function forms two loops, one of length 65534 and one of length 2, but one of the if statements causes the cycle of 2 to lead back to the cycle of 65534. Oddly, the RNG value of 21674 at index 65113 loops back to index 0. This may be because this index's S1 value is equal to the previous RNG value for the first time, but that is no reason to prematurely end the loop. Indeces 65114-65533, as well as values 22026 and 58704 (the loop of 2,  which are not given indeces) are considered [https://www.youtube.com/redirect?v=MiuLeTE2MeQ&redir_token=SymUNd8wBHOCXi28TSwbDD5ZZ9N8MTUzOTI1NzkyM0AxNTM5MTcxNTIz&event=video_description&q=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0B3JCRPC09lDtcHRjdU9pSjJCX1U%2Fview%3Fusp%3Dsharing|'''impossible RNG values'''] and cannot be reached without hacking. All other RNG values are considered [https://www.youtube.com/redirect?v=MiuLeTE2MeQ&redir_token=SymUNd8wBHOCXi28TSwbDD5ZZ9N8MTUzOTI1NzkyM0AxNTM5MTcxNTIz&event=video_description&q=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0B3JCRPC09lDtOExmOW1hclhiNHc%2Fview%3Fusp%3Dsharing|'''possible RNG values''']. The RNG index and value of 0 is set when the game powers on.
The function has 65536 possible inputs and 65536 possible outputs. It is a bijection, meaning that every input maps to exactly one output and none repeat or are left out. The function forms two loops, one of length 65534 and one of length 2, but one of the if statements causes the cycle of 2 to lead back to the cycle of 65534. Oddly, the RNG value of 21674 at index 65113 loops back to index 0. This may be because this index's S1 value is equal to the previous RNG value for the first time, but that is no reason to prematurely end the loop. The RNG index and value of 0 is set when the game powers on.
 
=== Impossible RNG ===
Impossible RNG values are values that are theoretically legal within the game, but cannot be reached due to how the RNG values cycle. 1 set of these is a 2 value RNG loop (values 22026 and 58704) that has no lead-in's from the main loop. If you entered this loop somehow, it would send you back to the main loop almost immediately. The other set (indices 65114-65533) is caused by there being a manual check that resets the primary loop early. This leaves the latter part of the loop, after the reset, unreachable. Any other RNG is considered possible.
 
==Cycling RNG==
==Cycling RNG==
Because RNG indeces loop from 0 to 65113 and back to 0 again, by looping through every RNG index Mario can reach any reachable RNG value. By making [[dust]], Mario can advance RNG 4 times per frame, which takes 9 minutes to loop. If objects are calling RNG, this time will be much faster.
Because RNG indeces loop from 0 to 65113 and back to 0 again, by looping through every RNG index Mario can reach any reachable RNG value. By making [[dust]], Mario can advance RNG 4 times per frame, which takes 9 minutes to loop. If objects are calling RNG, this time will be much faster.