Skip to content

Commit 64a6138

Browse files
Rocky640snicolet
authored andcommitted
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.
1 parent 4e2bb8f commit 64a6138

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/evaluate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ namespace {
274274
kingRing[Us] |= shift<EAST>(kingRing[Us]);
275275

276276
kingAttackersCount[Them] = popcount(kingRing[Us] & pe->pawn_attacks(Them));
277+
kingRing[Us] &= ~double_pawn_attacks_bb<Us>(pos.pieces(Us, PAWN));
277278
kingAttacksCount[Them] = kingAttackersWeight[Them] = 0;
278279
}
279280
}
@@ -309,7 +310,7 @@ namespace {
309310
attackedBy[Us][Pt] |= b;
310311
attackedBy[Us][ALL_PIECES] |= b;
311312

312-
if (b & kingRing[Them] & ~double_pawn_attacks_bb<Them>(pos.pieces(Them, PAWN)))
313+
if (b & kingRing[Them])
313314
{
314315
kingAttackersCount[Us]++;
315316
kingAttackersWeight[Us] += KingAttackWeights[Pt];

0 commit comments

Comments
 (0)