]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Smoothly change playing strength with skill level. (#2142)
[stockfish] / src / search.cpp
index e008bec1e45d8a063cca7d05dd803411d7cb38c6..b4a69092ccedc1489c53ae7c064ec99b46e9e157 100644 (file)
@@ -335,7 +335,12 @@ void Thread::search() {
   beta = VALUE_INFINITE;
 
   multiPV = Options["MultiPV"];
-  Skill skill(Options["Skill Level"]);
+  // Pick integer skill levels, but non-deterministically round up or down
+  // such that the average integer skill corresponds to the input floating point one.
+  PRNG rng(now());
+  int intLevel = int(Options["Skill Level"]) +
+        ((Options["Skill Level"] - int(Options["Skill Level"])) * 1024 > rng.rand<unsigned>() % 1024  ? 1 : 0);
+  Skill skill(intLevel);
 
   // When playing with strength handicap enable MultiPV search that we will
   // use behind the scenes to retrieve a set of possible moves.