POV-Ray : Newsgroups : povray.beta-test : POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10 : Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10 Server Time
21 Jun 2024 01:14:29 EDT (-0400)
  Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10  
From: clipka
Date: 26 Jul 2021 14:46:34
Message: <60ff030a$1@news.povray.org>
Am 26.07.2021 um 10:34 schrieb jr:

> demo scene TdG mentioned simply needs a (fairly) reliable unique seed for the
> RNG, whenever it's rendered.  made a couple of quick tests with 'now', and am
> thinking of using something like the following to replace the
> 'datetime(now,"%s")', and would appreciate comment(s):
> 
> #declare seed_ = mod((now-int(now))*1e16,1e9);

- Variable name should use uppercase as the first letter. Just saying.

- No need for `mod`, as the seeding via `#declare MyRNG = seed(seed_);` 
already effectively does a `mod` operation with a modulus of 2^32 (ca. 4e9).

- Taking the time of day, rather than the running total, is a smart move 
I probably wouldn't have thought of, and had me thinking thrice to 
figure out whether it even has any advantage. (My preliminary 
conclusion: I think it does.)

- Multiplying with 1e16 seems excessive. The value is given in days, and 
has a precision of microseconds at best; 8.64e10 would be the ideal 
factor in that case. Some systems may even provide timers as slow as one 
tick mer millisecond, in which case there would be little point in using 
  a factor larger than 8.64e6.


There might be some point in multiplying with a very large number and 
then applying `mod`, so that seeds quickly diverge. But that doesn't 
work when the multiplying factor is a multiple of the modulus - you'd 
ideally want coprime values for that, otherwise you're not shuffling 
around information, you're just ditching digits.

This should be easy to accomplish by using any odd (in the literal 
sense) multiplier, while ditching your own mod and relying on the 
inbuilt mod 2^32 operation. I have a hunch that numbers with a 
well-balanced number of binary ones and zeros would be ideal.

The following might do nicely:

     #declare seed_ = (now-int(now))*(1e9+1);


Post a reply to this message

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