I was wondering if functions in various languages used to return random values, such as AS2
Math.random() or Php
rand() are returning real random values or just a sequence of numbers someone can predict.
So I asked the question to someone that is facing this problem for a long time: Matt from CasinoInLinea.
That’s what he said:
Random results are very important in many computer applications. From online casino games, through video arcades, image processing to data security & encryption software and many other types of applications.
Since computers are 100% predictable: The same actions, performed at a specific order, will always lead to the same results. This means that generating true random numbers is not an easy task. For a function to produce a random number, one of the variables must have a different value every time.
A series of numbers is truly random if it completely unpredictable. In other words, if we have absolutely no way of knowing what the next number is in a series of N numbers, then the series is completely random. On the other hand, if we can determine the next number according to a specific formula, (i.e. Fibonacci, a linear or parabolic function etc), then the series is a function, and is not random at all. As odd as it may seem, computer functions also have interim statuses. A function can be highly random, (i.e. it’s difficult BUT POSSIBLE to predict the next number). It all depends on the capability of the RNG (random Number Generator) algorithm.
Applications like online casino software and security related programs (i.e. password generators, data encryption and more) demand the highest randomness possible. Imagine a roulette table in which a player can predict where the ball falls next, or a password generating software that generates predictable “random” passwords. Both scenarios present a major security breach for the software operators.
So how do random functions produce random numbers? Here are a few common ways:
The computer’s clock
That’s the easiest, cheapest and least secure method. The computer clock offers an ever changing value that always increases with time. Therefore, it is possible to integrate the absolute time value into the random function to produce random results. (The time value is a 2 * 16 bit, double word binary value) that contains years, months, days, hours, minutes & seconds).
Random keyboard or mouse sequence
Some applications (e.g. client-based password generators) resort to a more creative way of producing a random value. They ask the user to provide a sequence of keyboard strokes or a random mouse curosr movement over a specific screen area (or a combination of both). The keystrokes and/or mouse movements are then compiled to a series of values, which are then compiled to a single, random number. This method is excellent at giving the user a distinct sense of control. Its major drawback is that it cannot be used in automated processes (e.g. command line batch executions).
For applications where randomness is crucial, such as online casino software or encryption software, RNG extension cards can be installed on server machines. These offer faster, more secure random numbers, which are virtually inpredictable. When randomness is of outmost importance, Hardware based is the best solution, although the most expensive one.
Having said all that, when you develop your next computer game, be it browser or client based, you should not worry too much about random numbers â€“ feel free to use your development environment’s native random functions (which probably use the computer’s clock). The gaming experience is unlikely to be affected by it.
If you’re still serious about random numbers, and demand nothing but the best, this website provides more in-depth information about using random number genreators.