This somewhat simplifies the code.
Suggested by Lucas Braesch.
No functional change.
-PolyglotBook::PolyglotBook() {
-
- for (int i = Time::now() % 10000; i > 0; i--)
- RKiss.rand<unsigned>(); // Make random number generation less deterministic
-}
+PolyglotBook::PolyglotBook() : RKiss(Time::now() % 10000) {}
PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
- // Init seed and scramble a few rounds
- void raninit() {
+public:
+ RKISS(int seed = 73) {
s.a = 0xf1ea5eed;
s.b = s.c = s.d = 0xd4e12c77;
s.a = 0xf1ea5eed;
s.b = s.c = s.d = 0xd4e12c77;
- for (int i = 0; i < 73; i++)
+ for (int i = 0; i < seed; i++) // Scramble a few rounds
-public:
- RKISS() { raninit(); }
template<typename T> T rand() { return T(rand64()); }
};
template<typename T> T rand() { return T(rand64()); }
};