[chuck-users] easy random numbers

Scott Wheeler wheeler at kde.org
Mon Nov 19 14:43:42 EST 2007

jakob kaiser wrote:
> Hi,
> I want to write a small script for ear training with Chuck. Therefore 
> Chuck should produce values that seem to be quite random. But it seems 
> like that the standard functions here are too deterministic. I know 
> that a non-deterministic random function would not be possible, but 
> most programming languages provide functions that create at least new 
> numbers every time I start the same code. However, in chuck something 
> like the following always prints the same numbers when I run it:

Actually the second number should seem random.  It's just the first 
number that's being repeated, most likely.  That's the same behavior 
that you get with the system rand() because it's seeded with the time 
and when reduced to the range of { 50, 1000 } is the same between two 
sequential runs.  (Admittedly, this behavior annoys me in most C, and 
ChucK could work around it, but it's just passing on the behavior from a 
lower level.)


More information about the chuck-users mailing list