From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Srandom Date: Mon, 30 Mar 1998 21:52:15 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 25 Message-ID: <35205A5F.6C23@cs.com> References: <19980330 DOT 202928 DOT 14806 DOT 0 DOT matthew DOT krause AT juno DOT com> NNTP-Posting-Host: ppp237.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 | ---------------------------------------------------------------------