Can you generate a really true (non-pseudo) random numbers with Unity for instance for use of casino and gambling related games?
5 Answers
5This is a loaded question.
-
The definition of “random” is arguable.
-
It’s not possible to get “true” random numbers from a computer, by the very definition of how computers work at the low-level.
-
What you are actually asking for is, “How do I get numbers that look like they are purely random and/or don’t repeat themselves often?”
-
Despite what most people think, video gambling games are deterministic, meaning the results of a move are predetermined. Therefore, using a PRG is exactly what you need.
All that said, if you are looking for PRG that “looks” random, you should do a web search for “Mersenne twister”, and hopefully you can find an implementation of it in your language of choice.
Cheers!
This, is technically not true, at least not anymore. Computers are capable of generating true random numbers. However, this does require some more specialized equipment than most computer owners have. Source: [https://www.random.org/randomness/][1] [1]: https://www.random.org/randomness/
– TonanBoramersenne twisters have nothing to do with anything. they just produce a sequence based on a seed. the whole issue is getting a seed. "Computers are capable of generating true random numbers" this is "technically" (what does that mean?) not true. "computers", as such, can't generate a profoundly random seed. you have to attach a dongle which generates profound randomness using radioactive decay or the like.
– FattieCreating truly random numbers in Unity is not possible. Creating additional randomness can be managed by incorporating unpredictable factors into the random number sequence - it’s never going to be casino level quality and should not be used for gambling games, but it can remove “sameness” in other random sequences - for example the creation of mid level security keys, codes and seeds for a subsequent sequence.
- Use the current time as part of the calculation - if the user is responsible for triggering an action that will need a random number it will be very unlikely that they will execute the action at a regular interval.
- Use the positional movements of the mouse on a PC or the accelerometer on a device over time to adjust the random sequence
- Use the Ping time to a remote server
Using current time is actually predictable... :P The mouse position might not be so "volatile" on a server, a good idea would be using microphone's input as a perturbation to the random function.
– bruce965At the millisecond level - time between events is not predictable if the user is involved in the process - I guess you mean it can be spoofed, which is true. All of these suggestions are client side though, to create a seed, which is itself down to, as I mentioned, getting the user to be more secure. If the construction of a key is in the users best interests- i.e. security, then you are adding their deliberate unpredictability.
– whydoidoitI guess if he had wanted a client side solution, pseudorandom numbers would have been enough...
– bruce965So I am answering the question in the title - because this is a knowledge base and that is what future searchers will find. My answer is specifically not for gambling games and is for the use of factors to create additional levels of randomness. I don't see server side specified in the question.
– whydoidoit“return winCon-Random.Range(1,winCon)”
![]()
Generating true random numbers requires specialized hardware, you can buy or craft a quantum random generator that produces values that cannot be predicted (according to universe physics rules).
This is an example that you can buy online.
And this is a guide to craft a simple one, you might need a radioactive material to generate a fast enough stream of random numbers (if potassium isn’t fast enough).
http://m.instructables.com/id/Arduino-True-Random-Number-Generator/
Good luck with your project, Fabio Iotti.
excellent product link, thanks. things have changed since my day! only 1000 bucks or so as well.
– FattieTo generate true randomness you need randomizing what was already randomized and multiply that all by however many times you want to randomize to continue to randomize it.
If you had to pick a number out a bowl, no matter how shuffled the numbers, the values on top of the pile will always have the highest ratio of being chosen. Now if you change how deep to dig your hand, these values at such depth have a high ratio of being selected.
If you want true randomness, the values in the bowl need to continuously change as well as the heights of the hand that will dig in the pile before choosing.
Random is not at all as complicated as people believe it to be.
OP says: "for use of casino and gambling" .... it is utterly inconceivable you would use Unity for the actual meat of actual licensed gaming, in any jurisdiction. It's a game engine for goodness sake, it's for making things like angry birds. your question would be literally like asking: "I work for Chase Manhattan bank. Can I use Unity to run Chase's online banking?" Your question is just utterly, utterly, outside the bounds of reality. The answer is "of course not, not in any way."
– Fattie