Confusion about `Random`

Siarhei Siamashka siarhei.siamashka at gmail.com
Sat Dec 24 16:42:36 UTC 2022


On Saturday, 24 December 2022 at 16:16:17 UTC, jwatson-CO-edu 
wrote:
> Then it became clear that the parser was replacing calls to 
> `rand` with
> a number, which was displayed repeatedly when a loop was 
> evaluated.

Sounds like a case of https://xkcd.com/221/

BTW, you don't need to explicitly initialize unpredictableSeed, 
because that's how it is already configured dby efault. Setting 
the seed is useful if you are interested in a specific PRNG 
algorithm with a specific seed to produce a predictable 
deterministic pattern.

Another thing is that the current implementation of `std.random` 
in Phobos is extremely slow and with some tweaks it [can be up to 
3x-6x times 
faster](https://codeforces.com/blog/entry/99292#comment-881097). 
There's a more advanced 
[mir-random](https://code.dlang.org/packages/mir-random) 
third-party dub package, but I'm not sure whether they have any 
plans to backport all of their optimizations to Phobos (or 
whether such contribution would be accepted).


More information about the Digitalmars-d-learn mailing list