Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!PT.CS.CMU.EDU!andrew.cmu.edu!jv0l+ From: jv0l+@andrew.cmu.edu (Justin Chris Vallon) Newsgroups: comp.sys.mac Subject: Re: How Doy you get a real random number in LSC? Message-ID: <0WD9Zey00Xo7sDQ0Cl@andrew.cmu.edu> Date: 15 Mar 88 02:39:38 GMT Organization: Carnegie Mellon University Lines: 19 In-Reply-To: <7671@cisunx.UUCP> jasst3@cisunx.UUCP (Jeffry A. Sullivan) asks: >> How do you get a real random number in LSC? I have tried using rand() and Random() (from math lib and quickdraw, repectively). They both give the same sequence of numbers each time at startup. I am trying to write a randomizer INIT that works on a mac II, but the randomness is all that's holding me back. (I think...) << The QD function Random() uses the global variable RandSeed, which is always initialized to the same number when you call InitGraf(&thePort). To change the sequence of random numbers, you must initialize the seed. A seed that I use a lot is either the current system time, since it will never be the same for two instances of your initialization. Look for the function which returns the number of seconds elapsed since 1/1/04. Use this number (ANDed w/0xffff) to generate a unique random number seed. -Justin justin.vallon@andrew.cmu.edu