POV-Ray : Newsgroups : povray.programming : Random number generator not random : Re: Random number generator not random Server Time
26 Apr 2024 07:57:54 EDT (-0400)
  Re: Random number generator not random  
From: Warp
Date: 30 Apr 2011 03:10:34
Message: <4dbbb5ea@news.povray.org>
awestover <nomail@nomail> wrote:
> I understand that the seed
> means that every time you run the program the numbers will appear in the same
> order, but I thought that calling rand() with the same seed multiple times would
> yield different results.

  I hope you see the contradiction in that statement. You expect the same
seed to both give and not give the same result.

  Of course the regular way of doing it is to declare the seed object like:

#declare S = seed(123);

and then use rand(S) whenever you need. (The advantage is that if you have
found a seed that gives you the result you want, and then you need to
create more random things in between, but don't want to mess up the existing
stream of random numbers, you can create a different seed object, like
#declare S2 = seed(456); and use that for the secondary stream of random
numbers.)

  If you want a seed that is different on each render, in POV-Ray 3.7
you can do this:

#declare S = seed(now * 100000);

  (It's not clear to me why you have to multiply by 100000 in order to get
a seconds count, but that's how it seems to work...)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.