I read about how to make math.random even more random on the Roblox DevWiki, but I don't understand. Can someone translate this into simpler terms? https://www.robloxdev.com/articles/Random-Number-Generation
The random number generator in Roblox is called a pseudo random number generator. Pseudo means fake so it quite literally means a "fake random number generator".
Computers cannot produce actual random numbers because they are using the same algorithm every time to produce the random number in question. Computers by their very nature are deterministic machines which basically means it will give the same answer if the same input is given.
Computers generally use some sort of algorithm in order to produce these random numbers which is why they are pseudo random number generators. In theory, it is completely feasible to reverse engineer the process and predict the next "random" numbers with complete accuracy. These algorithms produce sequences of numbers based on a seed. If the same seed is given, the algorithm will always produce the same sequence of numbers (just like how a Minecraft word generation seed will always produce the same world).
The problem that the article is outlining is that without setting the seed of the random number generator, you'll get the same sequences of numbers every time. In order to make the pseudo random number generator reasonably random, you can call
math.randomseed() simply takes in a number as input and sets it as the seed. You need to make sure you set the seed to something different every time. You can do this by giving
math.randomseed() the time as input because time is a constantly changing value. You can pass in the value of
tick() which returns how much time has passed since UNIX epoch like so:
It is possible to produce true random numbers (not perfectly random but extremely close) by observing factors such as thermal and atmospheric noise. This site does exactly that and uses atmospheric noise in order to produce random numbers. It’s appropiately called a “true random number generator” because it produces authentic random numbers. Even if it’s not perfectly random, it can’t be predicted at all to any degree.