How can computers generate random numbers when all they understand is pure logic?
Generating truly random numbers (or other data) is a… difficult problem, to make an understatement. There isn’t much in the universe that is truly random, if there’s even anything at all. The closest we come is pulling values from hard-to-predict sources like the atmospheric noise RANDOM.ORG uses. And that’s pretty neat, but they lack something the (less random) computer-generated sequences do have. Reproducibility.
It may be strange to think of a bunch of random digits as something to repeat, but it can actually be quite useful. You may have heard of a “seed” in the context of randomness. The seed is the initial value the computer uses to base the rest of the sequence off. Setting a seed and requesting the first ten random numbers will get you the same numbers every single time if you use the same seed. This is how, even in games with randomly generated environments, those worlds can be sent to other players by only a single phrase or string: once the computer knows where to start, the rest is all logic.
That’s not my use case though, I just wanted random colors that didn’t follow the same sequence every time. The thing I run my code on doesn’t have an ever-updating internal clock, so I can’t use the correct time as a seed (which is very commonly done to get a unique random sequence). I had to jump through all kinds of hoops to get a somewhat random seed from which to sprout my sequence.
Logic is nice, except when you want thing to be less logical.