Jump to content

RNG correlation (Generation I): Difference between revisions

m
→‎Mechanics: Undid a superfluous change when doing text replacement ("~" for approximation should not be changed).
m (Text replacement - "~" to "–")
m (→‎Mechanics: Undid a superfluous change when doing text replacement ("~" for approximation should not be changed).)
 
Line 5:
==Mechanics==
:''See also: [[Luck manipulation (Generation I)#Mechanics of the RNG]]''
In {{RBY}}, the value of the RNG advances each time by the value of the rDIV register, which itself is incremented at a rate of 16384Hz (–16779Hz~16779Hz on SGB). Since the game advances the RNG each frame, in normal gameplay, the state of the RNG can be considered uniformly random. This would suffice to generate two independent uniformly random bytes. However, assuming that the timing are fixed, a ''third'' RNG output byte will be highly correlated with the previous two, with at most a small variation due to different timings for rDIV increment (the "sub-rDIV" value). Furthermore, the three values will be related by a simple arithmetic relation, so the correlation will be noticeable even when only the approximate ranges of the values matter.
 
In particular, if the random numbers are drawn in a tight loop, then they will approximately follow a quadratic function (modulo 256), with the leading coefficient depending on the timing of the loop.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.