🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #26457

Re: How Doy you get a real random number in LSC?

#26457
From: Eric K. Olson
Date: Thu, 17 Mar 1988 14:22
25 lines
1814 bytes
In a recent article Jeffrey A. Hallett writes:
>In article <7671@cisunx.UUCP> jasst3@cisunx.UUCP (Jeffrey A. Sullivan) writes:
>>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...)
>
>Well, rand() works pretty well if you remember to change the seed each
>time.  The best way I've seen to do this is by using the value off the
>System clock.  You have to take it modulo the max seed size and then
>set the seed to this value.  This will keep you from getting the same
>"random" sequence every time.

There is a similar seed value for Random(), called randSeed.  It's one
of those quickdraw globals, like thePort and screenBits.  It's a long,
so it can take the value of the system clock directly.

It is initialized to 1 by InitGraf, and if you don't reinitilize it, you
will, indeed, get the same sequence every time.

-Eric
	    "We're writing tomorrow's software yesterday."
Eric K. Olson     olson@endor.harvard.edu     harvard!endor!olson     D0760
   (Name)                (ArpaNet)                 (UseNet)        (AppleLink)
Technical Details
Message-ID: <4238@husc6.harvard.edu>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!endor!olson
References: <7671@cisunx.UUCP> <9965@steinmetz.steinmetz.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!endor!olson
From: olson@endor.harvard.edu (Eric K. Olson)
Newsgroups: comp.sys.mac
Subject: Re: How Doy you get a real random number in LSC?
Message-ID: <4238@husc6.harvard.edu>
Date: 17 Mar 88 14:22:46 GMT
References: <7671@cisunx.UUCP> <9965@steinmetz.steinmetz.UUCP>
Sender: news@husc6.harvard.edu
Reply-To: olson@endor.UUCP (Eric K. Olson)
Organization: Lexington Software Design, Lexington, MA
Lines: 25
Keywords: LSC C RANDOM