]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Simpler PRNG and faster magics search
[stockfish] / src / search.cpp
index 5b22b8e93730ec7bcce5c6e62cb18e2051c2bba6..7cf4a8a3b583054b651d17b7c422564e859a7296 100644 (file)
@@ -27,7 +27,7 @@
 #include "evaluate.h"
 #include "movegen.h"
 #include "movepick.h"
-#include "rkiss.h"
+#include "misc.h"
 #include "search.h"
 #include "timeman.h"
 #include "thread.h"
@@ -1377,11 +1377,8 @@ moves_loop: // When in check and at SpNode search starts from here
 
   Move Skill::pick_move() {
 
-    static RKISS rk;
-
-    // PRNG sequence should be not deterministic
-    for (int i = Time::now() % 50; i > 0; --i)
-        rk.rand<unsigned>();
+    // PRNG sequence should be non-deterministic, so we seed it with the time at init
+    static PRNG rng(Time::now());
 
     // RootMoves are already sorted by score in descending order
     int variance = std::min(RootMoves[0].score - RootMoves[candidates - 1].score, PawnValueMg);
@@ -1402,7 +1399,7 @@ moves_loop: // When in check and at SpNode search starts from here
 
         // This is our magic formula
         score += (  weakness * int(RootMoves[0].score - score)
-                  + variance * (rk.rand<unsigned>() % weakness)) / 128;
+                  + variance * (rng.rand<unsigned>() % weakness)) / 128;
 
         if (score > maxScore)
         {