Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!spud From: spud@Apple.COM (Dave "Spud" Kalin) Newsgroups: comp.sys.mac.programmer Subject: Re: Random number generator - Think Pascal - help Keywords: think pascal random number generator Message-ID: <53569@apple.Apple.COM> Date: 3 Jun 91 04:44:10 GMT References: <1991May24.201417.1423@ccu.umanitoba.ca> Organization: Apple Computer Inc., Cupertino, CA Lines: 29 In article <1991May24.201417.1423@ccu.umanitoba.ca> burchil@ccu.umanitoba.ca (Charles Andrew Burchill) writes: > >Would someone send me an example of a random number generator in >Think Pascal. Using the random function always returns the same >number, I would like to know how to properly set the rand(seed) >using the time. > I was just pondering this question last week, so here's what I found out: the _Random call apparently does not get seeded from the RndSeed low-memory global, but from the grafport global RandSeed. Whenever you call InitGraf, the global is reset to 1, hence your repeating random numbers. A fix to this problem is as easy as this: randseed := tickcount; every time you try a new random sample.. Hope this helps! -- --------------------------------------- Dave "Spud" Kalin Apple Computer, Inc. ---------------------------------------- ?SYNTAX ERROR (beep!)