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 29a2b31..84c7ae8 100644 (file)
@@ -168,6 +168,8 @@ void Position::init() {
   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)