]> git.sesse.net Git - stockfish/commitdiff
Allow Position::init() to be called more than once
authorMarco Costalba <mcostalba@gmail.com>
Fri, 10 Apr 2015 06:57:35 +0000 (08:57 +0200)
committerJoona Kiiski <joona.kiiski@gmail.com>
Fri, 10 Apr 2015 19:39:15 +0000 (20:39 +0100)
Currently Zobrist::castling[] are not properly zeroed
and rely on the compiler to do this at startup, but this
makes Position::init() to set different values every time
it is called!

This is a bit odd, and although not impacting normal usage,
can yield to subtle misbehaviour, very difficult to track
down, in case we happen to call it more than once for some
reason. I found this while developing tuning support and
it took me a while to track it down.

So properly init Zobrist::castling[]

No functional change.

Resolves #329

src/position.cpp
src/ucioption.cpp

index 15ccb4835dbea166a6ae267d30e27056893734ac..5a98821d493dde10d9fe2bd020ba17467c1d7ea5 100644 (file)
@@ -149,6 +149,7 @@ void Position::init() {
 
   for (int cr = NO_CASTLING; cr <= ANY_CASTLING; ++cr)
   {
+      Zobrist::castling[cr] = 0;
       Bitboard b = cr;
       while (b)
       {
index 35c907ae52fb7b368a0feeea36108619adab598e..fd6c46d2f35489beee9b4360c0c37422d3fe3131 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <algorithm>
 #include <cassert>
-#include <sstream>
+#include <ostream>
 
 #include "misc.h"
 #include "thread.h"