From: Marco Costalba Date: Fri, 10 Apr 2015 06:57:35 +0000 (+0200) Subject: Allow Position::init() to be called more than once X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=a66c73deef420104e74b6645ee60e20b37fd8549;p=fairystockfish.git Allow Position::init() to be called more than once 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 --- diff --git a/src/position.cpp b/src/position.cpp index 15ccb48..5a98821 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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) { diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 35c907a..fd6c46d 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include "misc.h" #include "thread.h"