-
Notifications
You must be signed in to change notification settings - Fork 102
Description
The apparent reason is that when the engines output_previous template parameter is true, the previous internal state generated with the previous increment is returned first. This is at least unintuitive, and I'd even consider it a bug. Maybe set_stream should bump the internal state when output_previous is true (though I have to admit I don't really see the purpose of outputting the previous state in any case, but I'm sure I'm just missing something?).
Example code:
pcg32 generator1{};
pcg32 generator2(generator1);
generator1.set_stream(0xF00BA8);
generator2.set_stream(0xBAA8F00);
// Uncomment to "Pump out" the stored internal state and make the assert pass
// generator1();
// generator2();
assert(generator1() != generator2()); // FAILS!
Also, if I use stream numbers 1 and 2, or for example 73, 146 or such simply generated seeds, the first two numbers generated are identical, but I suppose that's what's described shortly in https://www.pcg-random.org/posts/critiquing-pcg-streams.html in the STOP PRESS parentheses statement. I'd be more than happy to read a slightly longer discussion of how to safely initialize a number of streams, initially just given consecutive integers as instance numbers?