|
|
> Am 26.07.2021 um 10:34 schrieb jr:
>
>> demo scene TdG mentioned simply needs a (fairly) reliable unique seed
>> for the
>> 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
>
>
> 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:
>
When I want coprimes, I often plug in pi in the mix, or use two values
that differ by 1. It could be something like :
#declare Seed_ = mod(now*pi*100000000, 87654321);
Post a reply to this message
|
|