RNG: Difference between revisions

1,850 bytes added ,  12 October 2018
m (remove stub tag)
(→‎Objects that call RNG: lots of stuff)
Line 25: Line 25:
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.
==Objects that call RNG==
==Objects that call RNG==
The following objects always call RNG under the given circumstances.
* Dust calls RNG to determine its resultant [[angle]] and [[horizontal speed]]. Note that the dust itself calls RNG, not the [[dust spawner]].
* Dust calls RNG to determine its resultant [[angle]] and [[horizontal speed]]. Note that the dust itself calls RNG, not the [[dust spawner]].
* [[Goomba]]s call RNG to determine which direction to move when they do not see Mario.
* [[Goomba]]s call RNG to determine which direction to move when they do not see Mario.
Line 31: Line 32:
* [[Coin]]s from Bob-ombs, Goombas, [[Big Cork Box]]es, [[Cork Box]]es, [[Piranha Plant]]s, [[Bully|Bullies]], [[Chuckya]]s, [[Fly Guy]]s, [[Snowman|Snowmen]], etc... you name it, it calls RNG 3 times to determine angle, horizontal speed, and [[vertical speed]]. Since angles are shorts just like RNG, the RNG value is used directly for the angle. Horizontal speed is set to (RNG / 65536) * 20, and vertical speed is set to (RNG / 65536) * 40 + 17. Since these RNG calls must be contiguous, there are still only 65114 possible coin trajectories.
* [[Coin]]s from Bob-ombs, Goombas, [[Big Cork Box]]es, [[Cork Box]]es, [[Piranha Plant]]s, [[Bully|Bullies]], [[Chuckya]]s, [[Fly Guy]]s, [[Snowman|Snowmen]], etc... you name it, it calls RNG 3 times to determine angle, horizontal speed, and [[vertical speed]]. Since angles are shorts just like RNG, the RNG value is used directly for the angle. Horizontal speed is set to (RNG / 65536) * 20, and vertical speed is set to (RNG / 65536) * 40 + 17. Since these RNG calls must be contiguous, there are still only 65114 possible coin trajectories.
* [[Bowser]] calls RNG to determine which attack to do next.
* [[Bowser]] calls RNG to determine which attack to do next.
* [[Spinner]]s call RNG twice when they stop spinning on the random setting. The first call determines direction. If the result is less than 32768, the spinner spins clockwise, and otherwise counterclockwise. The chance of a spinner choosing to spin clockwise on a given frame is 0.50016893. Spinners calculate their intended angular displacement by the formula (RNG % 4) * 30 + 30. Thus, the chance of spinning 30 [[angle unit]]s is 0.24982339, the chance of spinning 60 angle units is 0.24999232, the chance of spinning 90 angle units is 0.25008447, and the chance of spinning 120 angle units is 0.25009982.
* And many, many, many more.
* And many, many, many, many, many more.
===[[Tick Tock Clock]] Random Setting Only===
The following objects call RNG under the given circumstances when the clock was entered at 6:00 (the random setting).
* [[Spinner]]s call RNG twice when they stop spinning<ref>https://www.youtube.com/watch?v=MiuLeTE2MeQ</ref>. The first call determines direction. If the result is less than 32768, the spinner spins clockwise, and otherwise counterclockwise. The second call determines intended angular displacement. Spinners calculate their intended angular displacement by the following formula, in which % denotes the [[wikipedia:modulo operation|modulo function]]:
<nowiki>Intended Angular Displacement = (RNG % 4) * 30 + 30</nowiki>
 
The following is a table summarizing this information, with probabilities of the individual states in parentheses:
{| class="wikitable"
|-
! [[Spinner]] intended CW ang disp ([[AU]]) !! RNG2 % 4 = 0 (24.982339%) !! RNG2 % 4 = 1 (24.999232%) !! RNG2 % 4 = 2 (25.008447%) !! RNG2 % 4 = 3 (25.009982%)
|-
| '''RNG1 ≥ 32768 (49.983107%)'''|| -30 (12.485794%) || -60 (12.490401%) || -90 (12.501152%) || -120 (12.505759%)
|-
| '''RNG1 < 32768 (50.016893%)'''|| 30 (12.496545%) || 60 (12.508831%) || 90 (12.507295%) || 120 (12.504223%)
|}
* [[Cogs]] call RNG twice when they reach their target [[angular velocity]] (TAV)<ref>https://www.youtube.com/watch?v=S0q3_toE3b4</ref>. The cog approaches its TAV with an angular acceleration of ±50AU/frame². The first call determines the cog's next TAV. Because of the way the formula is structured, there is a possibility that the TAV is 0. If this occurs multiple times, the cog can stand still. The TAV is calculated by the following formula:
<nowiki>Target Angular Velocity = (RNG % 7) * 200</nowiki>
 
The second RNG call determines the sign of the TAV. If the result is less than 32768, the sign is -1, and 1 otherwise.
 
The following table summarizes this information:
{| class="wikitable"
|-
! RNG1 % 7 !! 0 (14.313358%) !! 1 (14.265749%) !! 2 (14.278035%) !! 3 (14.281107%) !! 4 (14.282643%) !! 5 (14.284179%) !! 6 (14.284929%)
|-
| '''RNG2 < 32768 (50.016893%)''' || 0 || -200 (7.1274995%) || -400 (7.1413214%) || -600 (7.1490002%) || -800 (7.1443929%) || -1000 (7.1505360%) || -1200 (7.1490002%)
|-
| '''RNG2 ≥ 32768 (49.983107%)''' || 0 || 200 (7.1382498%) || 400 (7.1367141%) || 600 (7.1321068%) || 800 (7.1382498%) || 1000 (7.1336425%) || 1200 (7.1459287%)
|}
 
==References==
==References==
<references />
<references />