]> git.sesse.net Git - stockfish/commitdiff
Allow Position::init() to be called multiple times.
authorGian-Carlo Pascutto <gcp@sjeng.org>
Tue, 17 Jul 2018 21:13:12 +0000 (23:13 +0200)
committerStéphane Nicolet <cassio@free.fr>
Wed, 18 Jul 2018 06:14:57 +0000 (08:14 +0200)
For the rationale to allow this, see commit
a66c73deef420104e74b6645ee60e20b37fd8549

This was broken when cuckoo hashing was added, and
subtly broke (for example) lichess' Android application,
thus illustrating the original judgement was sound.

No functional change.

src/position.cpp

index 29a2b314741f8f5db6ebc920d8c76c2881cf8a37..84c7ae8f1c65539101650b68492fe4a902de8f7d 100644 (file)
@@ -168,6 +168,8 @@ void Position::init() {
   Zobrist::noPawns = rng.rand<Key>();
 
   // Prepare the cuckoo tables
   Zobrist::noPawns = rng.rand<Key>();
 
   // Prepare the cuckoo tables
+  std::memset(cuckoo, 0, sizeof(cuckoo));
+  std::memset(cuckooMove, 0, sizeof(cuckooMove));
   int count = 0;
   for (Piece pc : Pieces)
       for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)
   int count = 0;
   for (Piece pc : Pieces)
       for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)