default random object?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 16 05:43:26 PST 2009


Lionello Lunesu wrote:
> 
> "Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
> news:gnafec$1cko$1 at digitalmars.com...
>> Ok. Let me just note that rand()%max is a lousy method of generating 
>> random numbers between 0 and max-1 and everybody should put that in 
>> the bin with Popular Examples That Should Never Be Used, together with 
>> exponential Fibonacci, linear-space factorial, and bubblesort.
> 
> Yes yes, I know I know, but, honestly, when I'm generating noise for 
> some terrain generation or a random color, or some fuzzy AI behaviour, I 
> don't care about random periods that much and %max does the job.

Ahhh, so that's why all my enemies in Far Cry 1 and 2 behave so 
predictably! :o)

Andrei



More information about the Digitalmars-d mailing list