Mail Archives: djgpp/1998/03/30/22:31:33
Matthew R Krause wrote:
>
> Wouldn't using the previous random number as a seed work better? In other
> words, start with the time as a seed and generate a random number 'x'.
> Seed random with 'x' next time, and set 'x' as new seed?
> I'm not sure about this, though, and __please__ tell if I'm wrong!!
Well, sort of. However, random(), as opposed to rand(), uses a highly
complex mathematical algorithm for generating random values, and
reseeding it each time it runs, especially if the seed is based on a
prior value of the algorithm, could theoretically produce
non-randomness. As a practical matter, nobody has ever tested it.
Besides, the problem is that if a program fork()s itself, the child
process will inherit the parent's seed, and therefore an identical
series of random numbers. There has to be some way to make it use a
different seed in each process.
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| Proud owner of what might one | http://www.cs.com/fighteer/ |
| day be a spectacular MUD... | ICQ UIN#: 7406319 |
| Plan: To make Bill Gates suffer | HEAT User ID: Fighteer |
---------------------------------------------------------------------
- Raw text -