Speed up piece evaluation
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 23 Apr 2021 09:29:46 +0000 (11:29 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 23 Apr 2021 09:29:46 +0000 (11:29 +0200)
standard STC
ELO: 16.27 +-4.6 (95%) LOS: 100.0%
Total: 10000 W: 2492 L: 2024 D: 5484

No functional change.

src/evaluate.cpp

index 23804b9..2975d6f 100644 (file)
@@ -1467,13 +1467,14 @@ namespace {
         goto make_v;
 
     // Main evaluation begins here
+    std::memset(attackedBy, 0, sizeof(attackedBy));
     initialize<WHITE>();
     initialize<BLACK>();
 
     // Pieces evaluated first (also populates attackedBy, attackedBy2).
     // For unused piece types, we still need to set attack bitboard to zero.
-    for (PieceType pt = KNIGHT; pt < KING; ++pt)
-        if (pt != SHOGI_PAWN)
+    for (PieceType pt : pos.piece_types())
+        if (pt != SHOGI_PAWN && pt != PAWN && pt != KING)
             score += pieces<WHITE>(pt) - pieces<BLACK>(pt);
 
     // Evaluate pieces in hand once attack tables are complete