ELi5 , how do random number generators work?

761 views

How is it different than the program just choosing the number it wants within range?

In: 6

11 Answers

Anonymous 0 Comments

Firstofall, let me just tell you that most computers do not possess true RNG. This is because the number used is generated algorithmically. Now, an algorithm has a precise definition, and one of the points on this definition is that it is deterministic, in other words, if you run it multiple times with the same input, the output must be the same each time.

As for these computers, which use so called pseudo-random numbers, they usually take a lot of different variables on your computer to generate numbers that aren’t random, but close enough to random for most purposes. This could include, for example, the last 25 keystrokes you made before generation, your system time, the current runtime (that is time since bootup) of your computer, and a whole host of other numbers.

Now, thing with this is that, again, these numbers are only close enough to random; If someone knew all the variables in the calculation, and knew exactly what the values of these variables were when you ran the random number generator, they could theoretically run the same algorithm to figure the number out, which is why these aren’t used for, for instance, online encryption.

A video game, however, is likely to use this sort of number generator, because for the purposes of a video game, close enough for it to feel random when it really isn’t is good enough; However, you might have heard speedrunners use the term “RNG manipulation”. This is exactly what it sounds like.

If you knew every variable in the games random number generator, you could, theoretically, purposefully make inputs to make said random numbers occur in your favour, thus saving time. This is possible because the algorithm is just that; it generates a number that is close enough to random for you to think it is, but at the end of the day, it is still an algorithm, and therefore deterministic.

You are viewing 1 out of 11 answers, click here to view all answers.