From: Marco Costalba Date: Mon, 31 Dec 2012 10:57:49 +0000 (+0100) Subject: Allow to pass a 'seed' to RKISS X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=896420b1661d3ec1247487dbaf73e05546a1d625 Allow to pass a 'seed' to RKISS This somewhat simplifies the code. Suggested by Lucas Braesch. No functional change. --- diff --git a/src/book.cpp b/src/book.cpp index 1c2d30e0..d75d63f9 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -348,11 +348,7 @@ namespace { } // namespace -PolyglotBook::PolyglotBook() { - - for (int i = Time::now() % 10000; i > 0; i--) - RKiss.rand(); // Make random number generation less deterministic -} +PolyglotBook::PolyglotBook() : RKiss(Time::now() % 10000) {} PolyglotBook::~PolyglotBook() { if (is_open()) close(); } diff --git a/src/rkiss.h b/src/rkiss.h index 154f3ca2..54bcab44 100644 --- a/src/rkiss.h +++ b/src/rkiss.h @@ -61,17 +61,15 @@ class RKISS { return s.d = e + s.a; } - // Init seed and scramble a few rounds - void raninit() { +public: + RKISS(int seed = 73) { 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 rand64(); } -public: - RKISS() { raninit(); } template T rand() { return T(rand64()); } };