discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

random number seed

RW
Raymond West
Tue, Oct 22, 2024 2:08 PM

afaik, rands is a pseudo random number generator and the results are
deterministic. Would it be possible, say,  to bring out  the time of day
into the scad code, so that it could be used as a seed for rands?

afaik, rands is a pseudo random number generator and the results are deterministic. Would it be possible, say,  to bring out  the time of day into the scad code, so that it could be used as a seed for rands?
JO
jjvb-openscad@bassklampfe.de
Tue, Oct 22, 2024 3:21 PM

Am 22.10.24 um 16:08 schrieb Raymond West via Discuss:

afaik, rands is a pseudo random number generator and the results are

deterministic. Would it be possible, say,  to bring out  the time of day
into the scad code, so that it could be used as a seed for rands?

OpenSCAD seeds the random generator by itself on every new render.

Try

values=rands(0,1,10);
echo(values=values);

You will get different values on every save

Am 22.10.24 um 16:08 schrieb Raymond West via Discuss: > afaik, rands is a pseudo random number generator and the results are deterministic. Would it be possible, say,  to bring out  the time of day into the scad code, so that it could be used as a seed for rands? OpenSCAD seeds the random generator by itself on every new render. Try -------- values=rands(0,1,10); echo(values=values); -------- You will get different values on every save
RW
Raymond West
Tue, Oct 22, 2024 4:09 PM

Thanks. I'd completely missed that. I won't tell you that I've just
written a python script to generate a list of random numbers seeded by
the  system clock which can be imported to my scad code. 😳

On 22/10/2024 16:21, jjvbhh via Discuss wrote:

Am 22.10.24 um 16:08 schrieb Raymond West via Discuss:

afaik, rands is a pseudo random number generator and the results are
deterministic. Would it be possible, say,  to bring out  the time of
day into the scad code, so that it could be used as a seed for rands?

OpenSCAD seeds the random generator by itself on every new render.

Try

values=rands(0,1,10);
echo(values=values);

You will get different values on every save


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Thanks. I'd completely missed that. I won't tell you that I've just written a python script to generate a list of random numbers seeded by the  system clock which can be imported to my scad code. 😳 On 22/10/2024 16:21, jjvbhh via Discuss wrote: > Am 22.10.24 um 16:08 schrieb Raymond West via Discuss: > > afaik, rands is a pseudo random number generator and the results are > deterministic. Would it be possible, say,  to bring out  the time of > day into the scad code, so that it could be used as a seed for rands? > > > OpenSCAD seeds the random generator by itself on every new render. > > Try > -------- > values=rands(0,1,10); > echo(values=values); > -------- > You will get different values on every save > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org