[RMVX ACE] HOW DO I MAKE RANDOM NUMBERS TRULY RANDOM?

Posts

Pages: 1
Hey all, I'm sure this is a basic question, but I couldn't find where it had already been answered in the forums. I need to be able to generate random numbers in RPG Maker VX Ace, and I need them to be different every time.

For example, you encounter an event and it gives you a random monster encounter, or item, or powerup, based on a random number between one and ten. But computers are notoriously bad at not generating the same "random" number every time. How can I make it so that on one playthrough the game generates a 3, then a 7, then a 4, rather than a 5 every single time?

Thanks for any help!
That meens at it random it, but somehow take just half number.
Thats because it can´t know what it giwe last play.
Deltree
doesn't live here anymore
4556
Short of a quantum random number generator, the one that comes with RM is about as decent as you'll get. I've never had issues with it, either. You're not using a seed, are you? That would give the same result every time.
To avoid having back to back identical results, I tend to store the resulting number into a variable, and then the next round, I run a conditional that checks to see if the current result is the same as the recorded number. If they're the same, reroll, if not, then it continues, and that result is recorded for checking next time.
You can consider making your game more deterministic if RNG is not working out for you.
Well everybody, now I think I may have had a strange run of weird luck (if you know what I mean). I had seventeen different things that could happen, but the same thing happened twice in a row, so I assumed something wonky was going on. Jeez, guess I was being a drama queen, sorry! But Skie Fortress that's not a bad idea, thanks for the suggestion!
TehGuy
Resident Nonexistence
1827
author=kylebstiff
I had seventeen different things that could happen, but the same thing happened twice in a row, so I assumed something wonky was going on.


That's completely possible, though. Sure the chances of that happening are much smaller than a different outcome occurring, but it can still happen.

Now if you had gotten the same thing several times in a row, that's a different story IMO
Yeah, I was being paranoid. But I remember programming in BASIC waaaaay back in the day and I learned stuff about how making a computer generate a "random" number is more difficult than you'd think. A low IQ person and a pair of dice can do it easily, but a computer has to go through some kind of jibbety cranko process to do it. So as soon as that happened, I was like, "Uh oh, I know what's going on here!" But of course I didn't. So there's a lesson here, people! And the lesson is: Don't try to use Game Maker if you're a total moron...
Do remember: Our minds like to play tricks on us, we like to see patterns everywhere. If you're rolling random numbers with the computer, its effectively as random as you are going to get, barring using the radiation noise of the universe like some things do. Your mind will always make patterns though, and having two back to back same results doesn't mean its not random. Remember, random means that each result is independent of the next. While rolling the same thing 15 times is unlikely, its still possible.
Just because the same thing happened more than once, doesn't mean it's NOT random you know. If you ask the computer to print a random number from 1 to 4096 21 times, it is completely normal to get 21 6's as a result (though that's pretty far-out, I admit).

If I remember correctly, Ruby uses C's built-in RNG, which uses your computer's clock and memory addressess. I couldn't tell myself, but some people do say that C's RNG is terrible. Maybe you can look into the generators used in other programming languages and see if someone made an rgss script for it (or ported it to ruby, at the least). Python and Lua, for example, uses the Mersenne Twist.
The odds of one in seventeen things happening twice in a row is only 1 / 17 which aren't awful odds or anything. If you're testing randomness you should definitely use a larger sampling population than two! It's more likely that there's a bug in what pulls your random numbers or how you use it than in the randomness of the RNG. For example maybe your random number generator is only creating a number between 1 and 2 because its min/max values were improperly set. Better random numbers are only needed for things like cryptography than randomness in a video game.
GreatRedSpirit, wouldn't the odds be more like 1 in 34?

And thanks lot you guys! Please don't think I'm a total retard. I'd like to blame BASIC for this, and reading something 20 years ago about the difficulties of generating random numbers!
No, because the first RNG number actually doesn't matter as long as all values are possible with the same probability. The only important thing is that the second event is the same as the first which is a 1 / 17 chance of it happening. If you wanted one particular event to occur twice in a row then you'd have two 1 / 17 chances trying to get the same desired event which you multiply to gether to get 1 / 289.


There are definitely difficulties in RNG but since the days of BASIC it has been abstracted out into the languages framework or core libraries *. It's possible to get Ruby to use a RNG generator with the same seed but you have to explicitly mark it so. There's other languages where you have to give a seed (usually based on the computer time) or hardware (old console RNG is usually more deterministic or based on the # of frames since the game started) and work for RNGs but that's largely days gone by.


* Security and cryptography are the biggest cases of "RNG is hard". Your RNG needs to appear as random as possible to prevent a malicious force from reverse engineering your RNG and determining what your next 'random' number is which could be the basis of an attack against your software.
Pages: 1