RNGs?

Hi guys i’m a newbie programmer wannabe, what i am about to ask could sound a bit stupid, but that’s why i’m posting it in general section :smiley:

I’m trying to make my own basic slot machine after reading an article about Alex, a hacker who found a way to ‘win’ against slot machine (You can find the whole story on Wired magazine)
And my question is about basic programming; i read that slot’s technology is based on an RNG. I have questions about this:

  • I saw that there are several types of sources that an RNG can use to give a result (static noise, transistor distortion, computational, etc); so first one question is: which is the difference? like, if possible, should i prefer one to one another in my case of application?
  • Advices on the actual RNG software i should download?
  • I saw many people talking about RNG or PRNG; i cannot understand the difference between them, since in someone’s opinion, choosing one or the other is really important. I’d like to know whether it’s better to use a PRNG or a regular RNG, if you are trying to program your own video slot machine. Actually i don’t even have clearly understood the difference between the two since, in guides i’m looking at they always talk about RNG, but here, which was my first source when i first knew the story of this aforementioned Alex, there are PRNG. so i’m pretty confused :confused:

Thank you very much guys <3

That’s something to study up on. I’m not too sure of RNG differences myself but I’d start on something like here: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6051287/

UPDATE

I found two pictures representing the difference between RNG and PRNG, in the case of static noise sourcing. I’m attaching them here since they were pretty clarifying to me, i just hope they’re proper

In short: A PRNG(Pseudo-random-number-generator) uses a seed based on some input. Usually the current date, time, number of CPU cycles etc. If you were to plug in these exact numbers again, the seed would always be the same, resulting in the exact “random” number output.

True RNG however would not depend on that. A true RNG would always spit out numbers that are not predictable, no matter the circumstances. Unfortunately this is not really possible. Even with the input you mentioned, static noise, transistor distortion it would still be a PRNG. Luckily these inputs are almost impossible to recreate, so one could it call “true randomness”.

So yeah, you can hack Slot machines if you were to find out what inputs the RNG in the machine uses. But depending on the input, it can be quite hard :wink:

Basically. The chances of such numbers being recreated are negligible, which is why PRNG is still used. The issue with RNG being tampered with isn’t really ever a problem with the source, but the implementation.

Heck, you could use atmospheric noise to generate your numbers (like random.org does), but that still wouldn’t protect your app from being tampered with. Someone could simply let the app think it’s receiving different atmospheric noise than it actually is, and suddenly the numbers are predictable again.

This is all theory of course, and things are always easier said than done, but if you’re looking for a 100% foolproof way to generate random numbers, I’m afraid 99% is as close as you’re gonna get.

In regards to what kind of RNG to use, the right answer is almost always the one built into the programming language you’re using. The vast majority of use-cases do not require anything more than this. Cases which do need more than this are things like lotteries and encryption, where predictability has obvious consequences. Unless you’re working on slot machines which need to satisfy very strict laws, seeding the standard library function with the current time is the way to go.