Date: Wed, 16 Jul 1997 12:39:27 -0700 (PDT) Message-Id: <199707161939.MAA08221@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: scochran AT shoalsnet DOT com From: Nate Eldredge Subject: Re: Fast random number generator Cc: djgpp AT delorie DOT com, Alan DOT Poppleton AT wanadoo DOT fr Precedence: bulk You wrote: >Alan Poppleton wrote in article ><33C91424 DOT 7615 AT wanadoo DOT fr>... >> I need a fast and simple algorithm which can produce a fairly random >> number given two seeds - x and y. Any ideas? It MUST be SIMPLE and >> FAST and it only needs to return a number between 0 and 15. > >okay.. Why don't you use standard C. Just to be picky... this is NOT standard C but C++. C does not have the reference construct. >#include >#include > >void randomxy( int&, int&); > >int main(void) >{ >int foox, fooy; > >srandom(time(NULL)); > >randomxy(foox, fooy); > >return 0; >} > >void randomxy(int &x, int &y) // using refrences speeds it up by using the >actual varibles >{ > int r = random(225); > x = r / 15; > y = r % 15; >} Nate Eldredge eldredge AT ap DOT net