]> git.sesse.net Git - stockfish/commitdiff
Allow to pass a 'seed' to RKISS
authorMarco Costalba <mcostalba@gmail.com>
Mon, 31 Dec 2012 10:57:49 +0000 (11:57 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 31 Dec 2012 10:59:53 +0000 (11:59 +0100)
This somewhat simplifies the code.

Suggested by Lucas Braesch.

No functional change.

src/book.cpp
src/rkiss.h

index 1c2d30e0a41df95358a23cd9bdf1b8ace8944315..d75d63f97b9e87eaf18ea4f84c85a8d0da007bcd 100644 (file)
@@ -348,11 +348,7 @@ namespace {
 
 } // namespace
 
 
 } // namespace
 
-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(); }
 
index 154f3ca2d9252c5f1952498a8fd95b588c67e9d0..54bcab449e19e25224a17bd88febc68a41ba2f9b 100644 (file)
@@ -61,17 +61,15 @@ class RKISS {
     return s.d = e + s.a;
   }
 
     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;
 
     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();
   }
 
         rand64();
   }
 
-public:
-  RKISS() { raninit(); }
   template<typename T> T rand() { return T(rand64()); }
 };
 
   template<typename T> T rand() { return T(rand64()); }
 };