True random or pseudorandom number generation?

This may sound like an odd question, but does anyone know if the random number that is generated by RPG Maker MZ is a true random number or a pseudorandom number?

Same question if you use the script for Math.randomInt?

I’m not exactly sure why the distinction bothers me, but it does. It probably doesn’t make sense.

If it is pseudorandom, I have an idea for a workaround that makes me feel a bit better, but I wanted to ask.

I assume the random number generation is pseudorandom, but I was hoping to confirm that.

Thanks!
I'm not using MZ so I will just tell you all this just in case the average developer ignores this fact.

There's no true random generated number system or RGN in real (computing) life mainly because you can only get close to picking a number randomly. This means that there's still a chance you'd get the very same result a couple of times in a row or in the 20th throw, etc.
Related:
Math.random (and by extension RM's Math.randomInt) is random enough for general purposes.
Computers can't generally produce truly random numbers on their own. Depending on your interpretation of quantum mechanics, such things might not even exist at all.
There are workarounds that do allow you to generate properly random numbers, like using fluctuations in the atmosphere, but they require specialised hardware.

As Caethyril mentioned, JavaScript's built-in randomness in very much random enough for any game-related applications - no human would ever be able to predict what numbers will be produced next. Specialised software potentially could, so if for some reason you need your numbers to be really random you can look into cryptographically secure numbers - though that is almost certainly overkill if it's for a game.
Thanks for these responses! I don’t know how I missed or forgot the previous thread on randomness. I searched for the wrong criteria when I was looking for information.

The idea that a random number generated by a regular computer isn’t really random just hurts my brain because…Math! Or whatever is the cause.

Thanks again and I am going to just eat chocolate every time the question of the randomness of numbers bothers me. That should make me feel better.

And fat…it will make me fat. And maybe diabetic.
Just try this several times. Open F12 in your browser, type
JavaScript:
ab = {}
for (let index = 0; index < 10000; index++) {
    let num = Math.floor(Math.random() * 10)
    if (ab[num] === undefined) { ab[num] = 0}
    else { ab[num] += 1}
       
}
console.log(ab)
See the distribution of the number and determine if it is random enough for you.
Sometimes you don't need to care about the truth, sometimes you just need to know if it is good enough.
@caethyril I thought this topic seemed familiar:LZSskeptic:

I hope my thread helps OP :LZSlol:
@TheoAllen Thanks for this test JS. I was able to try it and see the results.

@caethyril That thread was very helpful indeed.

To everyone:

I think I have a fundamental deficiency when it comes to understanding how a computer generates a random number. I thought I had read that if you could see enough results of a randomly generated number, you would eventually see a pattern and that pattern would duplicate and never change. Huh?

I sort of got the impression (probably completely inappropriately) that the computer was referencing a long series of numerical results and then sequentially returning the next value each time a random number was generated. (Why would you think that? Weirdo!)

So, for a simple example, a computer might be referring to a series like (10, 7, 5, 2, 3, 8, 6, 1, 9, 4) and that is how the random results would appear. (Face Palm Slap)

To me, that isn't even close to random. It means that at any given time, the random result can only possibly be one number, the next in the series, but because the referred to series is so long, it lends the appearance that the number being generated is random. (You need to stop day drinking.)

Again, I am probably so far off on understanding this that it isn't funny. RANDOM!

What I am truly interested in understanding is that if I have the game randomly generate a number from 1-20, each time it does it, is there really a 1 in 20 chance of any given value being generated? Just like there is if I roll a physical D20.

But I don't think that can be true because if it was, to me and my limited cranial capacity, that seems like a truly random number. (Oh, oh. The headache is starting again.)

This probably doesn't make any sense and what I am thinking is probably completely irrational (read delusional).

I guess it is time to go get some more chocolate...even though it is breakfast time.

Just give me a virtual head pat, say good old person who doesn't understand computers, and go about your day. Nothing to see here! NOTHING!

This is why I teach laws, regulations, procedures, and policies. That seems much easier to grasp.

Thanks again!
@TheoAllen Thanks for this test JS. I was able to try it and see the results.

@caethyril That thread was very helpful indeed.

To everyone:

I think I have a fundamental deficiency when it comes to understanding how a computer generates a random number. I thought I had read that if you could see enough results of a randomly generated number, you would eventually see a pattern and that pattern would duplicate and never change. Huh?

I sort of got the impression (probably completely inappropriately) that the computer was referencing a long series of numerical results and then sequentially returning the next value each time a random number was generated. (Why would you think that? Weirdo!)

So, for a simple example, a computer might be referring to a series like (10, 7, 5, 2, 3, 8, 6, 1, 9, 4) and that is how the random results would appear. (Face Palm Slap)

To me, that isn't even close to random. It means that at any given time, the random result can only possibly be one number, the next in the series, but because the referred to series is so long, it lends the appearance that the number being generated is random. (You need to stop day drinking.)

Again, I am probably so far off on understanding this that it isn't funny. RANDOM!

What I am truly interested in understanding is that if I have the game randomly generate a number from 1-20, each time it does it, is there really a 1 in 20 chance of any given value being generated? Just like there is if I roll a physical D20.

But I don't think that can be true because if it was, to me and my limited cranial capacity, that seems like a truly random number. (Oh, oh. The headache is starting again.)

This probably doesn't make any sense and what I am thinking is probably completely irrational (read delusional).

I guess it is time to go get some more chocolate...even though it is breakfast time.

Just give me a virtual head pat, say good old person who doesn't understand computers, and go about your day. Nothing to see here! NOTHING!

This is why I teach laws, regulations, procedures, and policies. That seems much easier to grasp.

Thanks again!
So the exact method of generating the number varies from implementation to implementation, but the general pattern is that it uses an algorithm performed upon a *seed*. The most common seed is a timestamp.

What makes random numbers occasionally predictable is when *you know what the seed is*. If you know what the seed is, you can figure out what the next number it generates will be.
So the exact method of generating the number varies from implementation to implementation, but the general pattern is that it uses an algorithm performed upon a *seed*. The most common seed is a timestamp.

What makes random numbers occasionally predictable is when *you know what the seed is*. If you know what the seed is, you can figure out what the next number it generates will be.
Thanks, @Trihan ! I think the "seed" part is what makes me think of the long series of numbers and the computer just taking the next number in the series or "seed".

But since you referenced a timestamp, does that mean that the "seed" could continually change when you reference it? So it isn't referencing a static "seed" every time?

So if I generate a random number now and then 10 minutes later I generate another random number, each time it is referencing a different "seed"?

If that is how it works, I will put my chocolate away for good, be happy, and put the whole sordid affair of randomness behind me!
Thanks, @Trihan ! I think the "seed" part is what makes me think of the long series of numbers and the computer just taking the next number in the series or "seed".

But since you referenced a timestamp, does that mean that the "seed" could continually change when you reference it? So it isn't referencing a static "seed" every time?

So if I generate a random number now and then 10 minutes later I generate another random number, each time it is referencing a different "seed"?

If that is how it works, I will put my chocolate away for good, be happy, and put the whole sordid affair of randomness behind me!
Yes, generators that use a timestamp as the seed will always generate a different set of numbers once the timestamp changes (which is pretty frequent, obviously). That's one of the reasons it's used as one.
Yes, generators that use a timestamp as the seed will always generate a different set of numbers once the timestamp changes (which is pretty frequent, obviously). That's one of the reasons it's used as one.
Oh, thank you, thank you, thank you for taking the extra time to explain that!

You have saved me from overindulging in my chocolate obsession and rushing toward an early grave.

No seriously, this really does help a lot and I greatly appreciate everyone's willingness to help and answer questions!
Oh, thank you, thank you, thank you for taking the extra time to explain that!

You have saved me from overindulging in my chocolate obsession and rushing toward an early grave.

No seriously, this really does help a lot and I greatly appreciate everyone's willingness to help and answer questions!
This is, incidentally, why there are some exploits for games where they tell you to set your clock to a certain date or time, or do things in a certain order. Because you can either predict the outcome based on time, or because performing certain actions modifies the seed in calculable ways.
So, for a simple example, a computer might be referring to a series like (10, 7, 5, 2, 3, 8, 6, 1, 9, 4) and that is how the random results would appear. (Face Palm Slap)
Lemme ask, is the digit of PI random enough for you?
What if some "random" function just uses the digit of PI?
What if they never told you?
Would you ever find out? 😛

Original thread: https://forums.rpgmakerweb.com/threads/true-random-or-pseudorandom-number-generation.154204/