POV-Ray : Newsgroups : povray.general : Is it me or does rand(n) loop ? : Is it me or does rand(n) loop ? Server Time
5 Aug 2024 02:19:19 EDT (-0400)
  Is it me or does rand(n) loop ?  
From: BlackRose
Date: 18 Dec 2002 11:45:07
Message: <web.3e00a576fc9687d9f765b2b40@news.povray.org>
So I wanted to pseudorandomly place objects (with some minimum spacing)over
a 2 d field. The technique I was using for this amounted to :

k = min
while (k < max)
   l = min
   while (l < max)

       dummy = rand(x);
       if (dummy < 1/1000) & (dummy > 1/2000)
            place the object  (on average it would show up in 1 of every 2k
possible spots).
       end
   l = l+1
   end
k = k+1
end

(yeah I know it's not real pov code, but...)
Anyways, it seemed that no matter what bounds I used, I was getting square
grids of objects (instead of the randomly placed ones I wanted). Upon
debugging, I found that (atleast to 5 decimal places) the values popped out
by a particular rand stream repeated (which is not what I had expected.
BTW, I'm doing this on a winXP machine, with pov version 3.5...

Any suggestions on how to get 'round this ? Anyone else come across this
before ? I guess I could create new random number streams, but I don't know
if that is necessarily the wisest move.

Thanks...


Post a reply to this message

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