From 64a6138d3736babad0f0d9758e3d0e5475f477dd Mon Sep 17 00:00:00 2001 From: Alain SAVARD Date: Sat, 15 Dec 2018 12:09:35 -0500 Subject: [PATCH] Refactor king ring calculation Compute the "double protection by pawns" expression only once in initialize(), instead of once for each piece in the piece loop. Passed STC http://tests.stockfishchess.org/tests/view/5c1506380ebc5902ba11f3b4 LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 9494 W: 2191 L: 2045 D: 5258 Inspired by Nick Pelling's test http://tests.stockfishchess.org/tests/view/5c144d110ebc5902ba11e4af and an older test of mine http://tests.stockfishchess.org/tests/view/5c0402810ebc5902bcee1fc8 Non functional change. --- src/evaluate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 6308f472..b58d4a03 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -274,6 +274,7 @@ namespace { kingRing[Us] |= shift(kingRing[Us]); kingAttackersCount[Them] = popcount(kingRing[Us] & pe->pawn_attacks(Them)); + kingRing[Us] &= ~double_pawn_attacks_bb(pos.pieces(Us, PAWN)); kingAttacksCount[Them] = kingAttackersWeight[Them] = 0; } } @@ -309,7 +310,7 @@ namespace { attackedBy[Us][Pt] |= b; attackedBy[Us][ALL_PIECES] |= b; - if (b & kingRing[Them] & ~double_pawn_attacks_bb(pos.pieces(Them, PAWN))) + if (b & kingRing[Them]) { kingAttackersCount[Us]++; kingAttackersWeight[Us] += KingAttackWeights[Pt]; -- 2.39.2