Fix linear congruential random number generator

Fixes: #4146, #4148, #4270
Fixes: 2252936fc8 ("Use linear congruential random number generator [...]")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2024-11-22 21:29:57 +01:00
parent 5c78037bd3
commit 32fee19447

View File

@ -68,7 +68,9 @@ inline const std::vector<std::string> split(const std::string &s, char c) {
return v; return v;
} }
// A simple linear congruential random number generator. // A simple linear congruential random number generator,
// using Knuth's constants from:
// http://en.wikipedia.org/wiki/Linear_congruential_generator.
class TRand { class TRand {
public: public:
// Sets the seed to the given value. // Sets the seed to the given value.
@ -95,7 +97,10 @@ public:
} }
private: private:
std::minstd_rand e; std::linear_congruential_engine<std::uint_fast32_t,
6364136223846793005ULL,
1442695040888963407ULL,
UINT64_MAX> e;
}; };
// Remove newline (if any) at the end of the string. // Remove newline (if any) at the end of the string.