From 1e6d21dbb6918a2d5f2f09730b0c30e3a4895d5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Nicolet?= Date: Sun, 1 Mar 2015 01:00:52 +0800 Subject: [PATCH] Simplify pawn code a bit Simplify a bit the number of bitwise operators used to calculate the pawn evaluation in pawns.cpp No functional change. Resolves #269 --- src/pawns.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pawns.cpp b/src/pawns.cpp index e582692e..c5f1b22c 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -110,9 +110,9 @@ namespace { const Square Right = (Us == WHITE ? DELTA_NE : DELTA_SW); const Square Left = (Us == WHITE ? DELTA_NW : DELTA_SE); - Bitboard b, p, doubled, connected, supported; + Bitboard b, neighbours, doubled, connected, supported, phalanx; Square s; - bool passed, isolated, opposed, phalanx, backward, lever; + bool passed, isolated, opposed, backward, lever; Score score = SCORE_ZERO; const Square* pl = pos.list(Us); const Bitboard* pawnAttacksBB = StepAttacksBB[make_piece(Us, PAWN)]; @@ -137,18 +137,16 @@ namespace { // This file cannot be semi-open e->semiopenFiles[Us] &= ~(1 << f); - // Previous rank - p = rank_bb(s - Up); - // Flag the pawn - connected = ourPawns & adjacent_files_bb(f) & (rank_bb(s) | p); - phalanx = connected & rank_bb(s); - supported = connected & p; - isolated = !(ourPawns & adjacent_files_bb(f)); + neighbours = ourPawns & adjacent_files_bb(f); doubled = ourPawns & forward_bb(Us, s); opposed = theirPawns & forward_bb(Us, s); passed = !(theirPawns & passed_pawn_mask(Us, s)); lever = theirPawns & pawnAttacksBB[s]; + phalanx = neighbours & rank_bb(s); + supported = neighbours & rank_bb(s - Up); + connected = supported | phalanx; + isolated = !neighbours; // Test for backward pawn. // If the pawn is passed, isolated, connected or a lever it cannot be @@ -193,7 +191,7 @@ namespace { score -= Backward[opposed][f]; if (connected) - score += Connected[opposed][phalanx][more_than_one(supported)][relative_rank(Us, s)]; + score += Connected[opposed][!!phalanx][more_than_one(supported)][relative_rank(Us, s)]; if (lever) score += Lever[relative_rank(Us, s)]; -- 2.39.2