Welcome to Religious Forums, a friendly forum to discuss all religions in a friendly surrounding.
Your voice is missing! You will need to register to get access to the following site features:We hope to see you as a part of our community soon!
In Basic (just one possible language) you could use the RND (random) function, like so:I am currently playing the computer game Bauldur's Gate 3 in which certain game outcomes are determined by a roll of a dice
How do computers roll dice?
How do they randomise things?
That is correct. My answer attempts to operate at a somewhat lower level of computer architecture.In Basic (just one possible language) you could use the RND (random) function, like so:
D = INT (6 * RND(1)) + 1
RND returns a decimal number between 0 and 1, although it is really only pseudo random. But the formula is complex enough that it works very well for most purposes.
So, say the above RND(1) function returns 0.71929349. If you multiply that by 6, you get 4.31576094, which if you take just the integer part (that's the INT part of the code), you get just 4. Then add 1, so your die roll is 5.
Most of the time they indeed don't.So they don't produce random numbers, only pseudo-random numbers?
What's the difference?
From the practical point of view (i.e. the user's) the difference is entirely negligible. It would only matter to a hard-boiled mathematician or statistician trying to generate a truly random series of nhumbers.So they don't produce random numbers, only pseudo-random numbers?
What's the difference?
As the others have mentioned, it is quite difficult to generate truly random numbers, but in most circumstances this hardly matters. It does matter when random numbers are used in cryptography however - see below link (near the bottom) and as to how this is important - when an adversary manages to crack whatever has been produced.So they don't produce random numbers, only pseudo-random numbers?
What's the difference?
Most of the time they indeed don't.
There are fairly exotic means that are sometimes used to attempt to make the numbers "truly" random - I once heard of something involving readings of the air temperature in some environment - but that is probably overkill for most applications by far.
The differences between random and pseudorandom numbers can be somewhat esoteric, philosophical even. The short of it is that a pseudorandom number can be guided towards predictability if need be (useful for testing), while true random numbers are indeed random, and no one could predict them accurately.
Interestingly, it does happen in real life of certain demands requiring avoidance of "too random" numbers. Things such a a D6 (a common dice) turning up the same number twenty times in succession "feel too random", but that could happen with a true random number generator.
I've long felt exactly the same thing -- but I'm told by my "betters" that this is not entirely true. They never quite explain why, however. Still, those betters know a truck-full more mathematics than I do, so I take them at their word.When he's well my brother in law works in the computer games industry. We've discussed randomising pseudo random numbers,
He reckons randomize(time) gives a unique sequence.
So they don't produce random numbers, only pseudo-random numbers?
What's the difference?
It can be helpful, if done correctly.When he's well my brother in law works in the computer games industry. We've discussed randomising pseudo random numbers,
He reckons randomize(time) gives a unique sequence.
It can be helpful, if done correctly.
For instance, if you take the number of miliseconds since the last full second, you end up with what might as well be a random number between 0 and 999 for most non-rigorous purposes.
A full exposition of the consequences and measures applicable is way, way beyond my pay grade, but the entire time stamp is actually a lot less random than a glance of the time between seconds. It must be mathematically easier to crack as well.Using the entire time value as the seed must give a different number every millisecond
A full exposition of the consequences and measures applicable is way, way beyond my pay grade, but the entire time stamp is actually a lot less random than a glance of the time between seconds. It must be mathematically easier to crack as well.
Using a fairly large seed number is indeed desirable, as is making it unpredictable. But in this case one may work against the other.
What's a seed number?
It is a starting point, an initial value.What's a seed number?