]> git.sesse.net Git - stockfish/commitdiff
Fix pieceList initialization in Position::clear()
authorMarco Costalba <mcostalba@gmail.com>
Sat, 10 Oct 2009 08:48:02 +0000 (09:48 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 10 Oct 2009 08:49:41 +0000 (09:49 +0100)
We want piece list to be terminated with SQ_NONE.

This happens with all the pieces but the pawns that
being 8 make the inner loop exit just before writing
the SQ_NONE value at the tail of the list.

This bug was hidden because currently we don't use
piece list to scan pawns, but this will change in the
future and in any case an initialization should be done
correctly for the whole array to avoid subtle bugs in
the future.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/position.cpp

index 4e9a6dc7b02388ddae1c8224a9bfd8eeedea2368..388f91f34172806157a7f44573a6177b7a94193d 100644 (file)
@@ -1488,8 +1488,8 @@ void Position::clear() {
   for (int i = 0; i < 64; i++)
       board[i] = EMPTY;
 
-  for (int i = 0; i < 7; i++)
-      for (int j = 0; j < 8; j++)
+  for (int i = 0; i < 8; i++)
+      for (int j = 0; j < 16; j++)
           pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;
 
   sideToMove = WHITE;