[chuck-users] easy random numbers

David Powers cyborgk at gmail.com
Mon Nov 19 13:52:29 EST 2007

I guess you need some pseudo-random number to multiply by, such as the
system time in milliseconds... However I'm not sure how one would get
the system time into ChucK.

I suppose that you could run some sort of batch script, or say a
couple lines of Python, that either gets the current system time, or
creates some type of random seed number; then generates a ChucK file
with that seed number as a global variable.


On Nov 19, 2007 12:26 PM, jakob kaiser <jakobala at hotmail.com> 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:
>  while(true){
>    1::second => now;
>    Math.rand2(50, 1000) => int rndNumber;
>    <<<rndNumber>>>;
> }
>  Is there an easy way to get something more unpredictable? I don't want to
> go deep into random generator programming. But the function does not really
> what you would expect of a random generator, does it?
>  Cheers
>  Jakob
> ________________________________
> Connect to the next generation of MSN Messenger  Get it now!
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

More information about the chuck-users mailing list