Fix #5: Set attack bitboards for all piece types
authorianfab <ianfab@users.noreply.github.com>
Sun, 12 Aug 2018 09:49:53 +0000 (11:49 +0200)
committerianfab <ianfab@users.noreply.github.com>
Sun, 12 Aug 2018 09:49:53 +0000 (11:49 +0200)
This fixes issues with uninitialized attack tables.
Bench results are deterministic now also for variants
that are missing some of the standard chess piece types.

No functional change for standard chess.

src/evaluate.cpp

index e009ba5..4333e24 100644 (file)
@@ -944,10 +944,10 @@ namespace {
     initialize<WHITE>();
     initialize<BLACK>();
 
-    // Pieces should be evaluated first (populate attack tables)
-    for (PieceType pt : pos.piece_types())
-        if (pt != PAWN && pt != KING)
-            score += pieces<WHITE>(pt) - pieces<BLACK>(pt);
+    // Pieces should be evaluated first (populate attack tables).
+    // For unused piece types, we still need to set attack bitboard to zero.
+    for (PieceType pt = KNIGHT; pt < KING; ++pt)
+        score += pieces<WHITE>(pt) - pieces<BLACK>(pt);
 
     score += mobility[WHITE] - mobility[BLACK];