From a66c73deef420104e74b6645ee60e20b37fd8549 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Fri, 10 Apr 2015 08:57:35 +0200 Subject: [PATCH] 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 --- src/position.cpp | 1 + src/ucioption.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-) 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" -- 1.7.0.4