POV-Ray : Newsgroups : povray.newusers : question about seed() and random() Server Time
6 Sep 2024 06:24:22 EDT (-0400)
  question about seed() and random() (Message 1 to 5 of 5)  
From: bassompierre laurent
Subject: question about seed() and random()
Date: 24 Feb 1999 09:24:57
Message: <36d40bb9.0@news.povray.org>
I'm writing a pov file like this :
...................
#declare Obj=array[5]
#declare Obj[0]=object{Myobject0}
#declare Obj[1]=object{Myobject1}
#declare Obj[2]=object{Myobject2}
#declare Obj[3]=object{Myobject3}
#declare Obj[4]=object{Myobject4}

#declare R=seed(1);
#declare C=1;
#while (C<5)
    object {Obj[int(rand(R)*4) Obj_Mod ....}
    #declare C=C+1;
#end
...................
The question is : will i get the same values for rand(R), each time i render
my file ?


Post a reply to this message

From: Ken
Subject: Re: question about seed() and random()
Date: 24 Feb 1999 09:31:35
Message: <36D40CC2.EF0E8BAF@pacbell.net>
bassompierre laurent wrote:
> 
> I'm writing a pov file like this :
> ...................
> #declare Obj=array[5]
> #declare Obj[0]=object{Myobject0}
> #declare Obj[1]=object{Myobject1}
> #declare Obj[2]=object{Myobject2}
> #declare Obj[3]=object{Myobject3}
> #declare Obj[4]=object{Myobject4}
> 
> #declare R=seed(1);
> #declare C=1;
> #while (C<5)
>     object {Obj[int(rand(R)*4) Obj_Mod ....}
>     #declare C=C+1;
> #end
> ...................
> The question is : will i get the same values for rand(R), each time i render
> my file ?

From my understanding of it yes it will always be the same until you
change the seed value. It offers random distribution for the values
you feed to it but as many people want predictable results once they
have found the right values it is not a floating random function.
  I know of no way to add a random float to rand either. It would be
nice if you could do a system read of the computers clock and add that
to the seed value but I'm not sure if this is possible.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Ken
Subject: Re: question about seed() and random()
Date: 24 Feb 1999 09:37:05
Message: <36D40E0B.DFE8B1A5@pacbell.net>
bassompierre laurent wrote:
> 
> I'm writing a pov file like this :
> ...................
> #declare Obj=array[5]
> #declare Obj[0]=object{Myobject0}
> #declare Obj[1]=object{Myobject1}
> #declare Obj[2]=object{Myobject2}
> #declare Obj[3]=object{Myobject3}
> #declare Obj[4]=object{Myobject4}
> 
> #declare R=seed(1);
> #declare C=1;
> #while (C<5)
>     object {Obj[int(rand(R)*4) Obj_Mod ....}
>     #declare C=C+1;
> #end
> ...................
> The question is : will i get the same values for rand(R), each time i render
> my file ?

Just had a thought and I have no idea if it would work but you might try
something like:

#declare C=1;
#while  (C<5)
#declare R=seed(C);
object...

This will change the seed value for each iteration of the loop.
Pov might also choke to death on it and it may not work. It was
just a thought I had and is untested.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: BC
Subject: Re: question about seed() and random()
Date: 25 Feb 1999 23:46:45
Message: <01be6143$7b117f80$010b010a@angela>
Ken <tyl### [at] pacbellnet> wrote in article
<36D40E0B.DFE8B1A5@pacbell.net>...
> bassompierre laurent wrote:
> > 
> > I'm writing a pov file like this :
> > ...................
> > #declare Obj=array[5]
> > #declare Obj[0]=object{Myobject0}
> > #declare Obj[1]=object{Myobject1}
> > #declare Obj[2]=object{Myobject2}
> > #declare Obj[3]=object{Myobject3}
> > #declare Obj[4]=object{Myobject4}
> > 
> > #declare R=seed(1);
> > #declare C=1;
> > #while (C<5)
> >     object {Obj[int(rand(R)*4) Obj_Mod ....}
> >     #declare C=C+1;
> > #end
> > ...................
> > The question is : will i get the same values for rand(R), each time i
render
> > my file ?
> 
> Just had a thought and I have no idea if it would work but you might try
> something like:
> 
> #declare C=1;
> #while  (C<5)
> #declare R=seed(C);
> object...
> 
> This will change the seed value for each iteration of the loop.
> Pov might also choke to death on it and it may not work. It was
> just a thought I had and is untested.
> 
> -- 
> Ken Tyler
> 
> mailto://tylereng@pacbell.net
> 

It will give you different values in each time through the loop, but each
time you run the file, you will get the same sequence of values. AFAIK(As
far as I know) there is no way out of this within POV, it is the nature of
"random" numbers on computers that they are not random!.

On your idea of using the clock, good thought! I was thinking you could
write a tiny batch file that places the time in a text file, then read this
in POVRay, and base the seed on it. Just get POVRay to call it
"pre-render". I haven't tried this (I usually want the predictable
behaviour) but it should work if you can get the time in a format that a
POVRay read statement will swallow. Try getting the batch file to put it in
quotes, then POVRay will read it as a string and you can decipher it.

Good Luck

Gordon
<gbe### [at] birdcameroncomau>


Post a reply to this message

From: Ken
Subject: Re: question about seed() and random()
Date: 26 Feb 1999 13:14:12
Message: <36D6E3E9.47BF6F24@pacbell.net>
BC wrote:

> It will give you different values in each time through the loop, but each
> time you run the file, you will get the same sequence of values. AFAIK(As
> far as I know) there is no way out of this within POV, it is the nature of
> "random" numbers on computers that they are not random!.
> 
> On your idea of using the clock, good thought! I was thinking you could
> write a tiny batch file that places the time in a text file, then read this
> in POVRay, and base the seed on it. Just get POVRay to call it
> "pre-render". I haven't tried this (I usually want the predictable
> behaviour) but it should work if you can get the time in a format that a
> POVRay read statement will swallow. Try getting the batch file to put it in
> quotes, then POVRay will read it as a string and you can decipher it.
> 
> Good Luck
> 
> Gordon
> <gbe### [at] birdcameroncomau>

  I realized that about 10 minutes after I posted that and sent
a private email to the original poster to that effect. It did
sound good at the time though.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

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