Re: Random Numbers (is new: Seeding)
Re: Random Numbers (is new: Seeding)
- Subject: Re: Random Numbers (is new: Seeding)
- From: Timothy Bates <email@hidden>
- Date: Mon, 01 Apr 2002 09:54:09 +1000
If this can generate a random number when called once per tick (i.e. With
sequentially numbered tick values), why not just store the last seed in a
property and run it with seed+=1 each time? Then you can access random
numbers as fast as the box will execute your function?
On 30/3/02 7:55 PM, "email@hidden" <email@hidden> wrote:
--=======================================
-- Quickly Generate Semi-Random Number
-- notes: only generates a new one each second
-- if you can access the ticks instead, you can
-- generate a new one each 60th of a second.
--=======================================
on OurRandNum()
set SegmentA to the time of the current date
-- Our seed value for the generation.
-- Valid range 0 - 86,399, based on
-- the number of seconds to Now
set OurSemiRandomNumber to (SegmentA mod 1039)
-- result: valid range 0 - 1038
-- Always use a prime to mod into a rand;
-- bigger prime = larger rand
-- See
http://www.rsok.com/~jrm/printprimes.html
-- to generate prime numbers in any reasonable range.
Return OurSemiRandomNumber
end OurRandNum
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.