One Number Repeated Forever: RNG in NSMB (2020)
roadrunnerwmc.github.io
roadrunnerwmc.github.io
Was it an accident? Did someone think that it would be a waste to throw away all these fine higher bits and just did anything with them?
(It feels a bit like a self-designed crypto algorithm when someone adds complexity because that's sure better than not, isn't it?)
They might not have been too familiar with linear congruential generators (LCG) because then they would have known that casting the result to an unsigned 32bit integer was not an accident but the modulus operation of the LCG (here: "mod 2^32"). See [0] for details.
[0] https://en.wikipedia.org/wiki/Linear_congruential_generator
It'd be interesting to see if the same randomizer is used in other SMB games after NSMB and any ports.
> Given a random starting seed, rand_nsmb will repeat an output after 1,820,529 calls, on average.
> Longest cycle: 1 cycle of length 1,708,724