Random algorithm
    Dave Cragg 
    dave.cragg at lacscentre.co.uk
       
    Thu Nov 13 04:02:24 EST 2008
    
    
  
Malte
It looks like I miscalculated the upper limit, or have goofed  
something entirely.
The script I ran first was this:
on mouseUp
    put the milliseconds  into tSeed
    set the randomSeed to tSeed
    put empty into field 1
    repeat 5
       put random (1000)  & cr after field 1
    end repeat
end mouseUp
This always gives me the same sequence:
671
250
597
371
78
When I use the script below, I get a different sequence each time as  
expected (so long as I wait at least 1 second between clicks.)
on mouseUp
    put the seconds  into tSeed
    set the randomSeed to tSeed
    put empty into field 1
    repeat 5
       put random (1000)  & cr after field 1
    end repeat
end mouseUp
On 13 Nov 2008, at 07:36, Malte Brill wrote:
> Dave wrote:
>
> > The  maximum number it can be set to seems to be 2130706432.
>
> Hi Dave (and all)
>
> I am not too sure about that, though I would love to know if there  
> are upper limits. On my Intel mac I get:
>
> 9
> 4
> 34
> 30
> 25
> 21
> 16
> 12
> 8
> 3
> 33
>
> on each run of the following script:
>
> on mouseUp pMouseBtnNo
>    repeat with i= 2130706432 to 2130706442
>        set the randomseed to i
>        put random(34) & cr after fld 1
>    end repeat
> end mouseUp
>
> So it does not appear to be upper limited at 2130706432. Given the  
> game writers perspective to this, I really like the way the random  
> algorithm the way it is implemented in Revolution, as a seeded  
> algorithm can be used in many ways in games. It prevents the ability  
> to cheat with undo systems in casual games, or even lets you set up  
> whole galaxies without stuffing memory.
>
> Cheers,
>
> Malte
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
    
    
More information about the use-livecode
mailing list