If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

A: A random number generator needs to be seeded before use, or it will always generate the same list of random numbers. For example the C 'time()' function can be used for this:

Code:

srand(time(NULL));

One should generally avoid using 'clock()' to initialize random numbers, since 'clock()' returns the amount of time the current thread has been running, generally a number close to zero.

Good seeds will involve more "random" bits. One way this can be accomplished is by using higher resolution timers such as a performance counter or an RDTSC value. Better seeds may mix the least significant bits of different timers. The best seeds are produced from truely random sources. If a computer is connected to the internet, truely random seeds can be obtained from sites like random.org.