1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

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
This commit is contained in:
Marco Costalba 2015-04-10 08:57:35 +02:00 committed by Joona Kiiski
parent 27efc5ac99
commit a66c73deef
2 changed files with 2 additions and 1 deletions

View 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)
{

View file

@ -19,7 +19,7 @@
#include <algorithm>
#include <cassert>
#include <sstream>
#include <ostream>
#include "misc.h"
#include "thread.h"