]> git.sesse.net Git - stockfish/commitdiff
Simplify Passed Pawns (#2058)
authorprotonspring <mike@whiteley.org>
Sun, 24 Mar 2019 16:37:38 +0000 (10:37 -0600)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Sun, 24 Mar 2019 16:37:38 +0000 (17:37 +0100)
This is a non-functional simplification/speedup.

The truth-table for popcount(support) >= popcount(lever) - 1 is:
------------------lever
------------------0-------1---------2
support--0------X-------X---------0
-----------1------X-------X---------X
-----------2------X-------X---------X

Thus, it is functionally equivalent to just do: support || !more_than_one(lever) which removes the expensive popcounts and the -1.

Result of 20 runs:
base (...h_master.exe) = 1451680 +/- 8202
test (./stockfish ) = 1454781 +/- 8604
diff = +3101 +/- 931

STC
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 35424 W: 7768 L: 7674 D: 19982
Http://tests.stockfishchess.org/tests/view/5c970f170ebc5925cfff5e28

No functional change.

src/pawns.cpp

index 6072745b6e7f6f1b06653d2094d89ee72e2d4f27..7eb584d2e8f37c5c8e49b507515bc7ba2c0657d5 100644 (file)
@@ -114,7 +114,7 @@ namespace {
         // which could become passed after one or two pawn pushes when are
         // not attacked more times than defended.
         if (   !(stoppers ^ lever ^ leverPush)
         // which could become passed after one or two pawn pushes when are
         // not attacked more times than defended.
         if (   !(stoppers ^ lever ^ leverPush)
-            && popcount(support) >= popcount(lever) - 1
+            && (support || !more_than_one(lever))
             && popcount(phalanx) >= popcount(leverPush))
             e->passedPawns[Us] |= s;
 
             && popcount(phalanx) >= popcount(leverPush))
             e->passedPawns[Us] |= s;