How do computers randomise/shuffle?

653 views

I don’t understand how an algorithm can be truly random

In: Technology

8 Answers

Anonymous 0 Comments

That’s the thing – it can’t.

Computers are, by design, not random. Everything that you do on a computer is represented as data, and that data is stored physically as ones and zeroes, representing an electrical switch in either the on (1) or off (0) position. With enough of these switches, you can store information as a stack of these switches, and read it by translating the ones and zeroes into something that we can understand, like basic English. This is a painfully simplified version, but the important part here is that there is, 100%, no randomness here. If there were, the data you want to store or read would be corrupted, and therefore lost.

Computers get around this by making incredibly complicated algorithms that take a starting variable, run it through a mathematical gauntlet, and then display the new result as the “random” number. An example of this would be rolling a dice for 1-6 in a gambling video game.

Instead of running a physics simulation to determine how the dice lands, a computer will grab a random number from somewhere on the system. This is ideally a number that can change a lot over time, like the players current score added to the current time. That initial variable is then put into an algorithm, usually a long one that is likely to change the variable significantly, without reproducing the same numbers over and over. Then, this number is divided and rounded down until it’s a number between 1-6, which is then displayed to you as your result.

This is usually how RNG is programmed, but here’s the thing: if you know what the algorithm is or how it works, and you can predict or manipulate the starting variable, you *can predict every time* what the “random” number will be, with perfect accuracy.

A famous example of bad RNG would be the a Fire Emblem game for the Gameboy Advance. Instead of an algorithm or some kind of generator to create random numbers, it literally has a list of numbers that it goes down, one by one, every time something “random” needs to happen. If you know the table, you can use useless actions to burn through the low numbers or make your enemies use them, and then attack when the large numbers are next on the list.

There are quite a few videos that explain this way better than I can, go look up RNG on YouTube.

Edit: I love it when a comment spurs a bunch of good discussion. Just a reminder that my explanation is pretty quick and dirty, I skipped over A LOT in this explanation. Computerized RNG is a fascinating topic.

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