From d39b22927e432adb9c06c718ce577f6647d5b07d Mon Sep 17 00:00:00 2001 From: jundery Date: Wed, 20 Mar 2013 23:07:25 -0600 Subject: [PATCH] Use ALL_PIECES value to reference attackedBy No functional change --- src/evaluate.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 3ba405cc..85fac61e 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -40,8 +40,8 @@ namespace { Pawns::Entry* pi; // attackedBy[color][piece type] is a bitboard representing all squares - // attacked by a given color and piece type, attackedBy[color][0] contains - // all squares attacked by the given color. + // attacked by a given color and piece type, attackedBy[color][ALL_PIECES] + // contains all squares attacked by the given color. Bitboard attackedBy[COLOR_NB][PIECE_TYPE_NB]; // kingRing[color] is the zone around the king which is considered @@ -693,7 +693,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // Undefended minors get penalized even if not under attack undefendedMinors = pos.pieces(Them) & (pos.pieces(BISHOP) | pos.pieces(KNIGHT)) - & ~ei.attackedBy[Them][0]; + & ~ei.attackedBy[Them][ALL_PIECES]; if (undefendedMinors) score += UndefendedMinorPenalty; @@ -701,7 +701,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // Enemy pieces not defended by a pawn and under our attack weakEnemies = pos.pieces(Them) & ~ei.attackedBy[Them][PAWN] - & ei.attackedBy[Us][0]; + & ei.attackedBy[Us][ALL_PIECES]; if (!weakEnemies) return score; @@ -740,9 +740,9 @@ Value do_evaluate(const Position& pos, Value& margin) { score += evaluate_pieces(pos, ei, mobility, mobilityArea); // Sum up all attacked squares - ei.attackedBy[Us][0] = ei.attackedBy[Us][PAWN] | ei.attackedBy[Us][KNIGHT] - | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK] - | ei.attackedBy[Us][QUEEN] | ei.attackedBy[Us][KING]; + ei.attackedBy[Us][ALL_PIECES] = ei.attackedBy[Us][PAWN] | ei.attackedBy[Us][KNIGHT] + | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK] + | ei.attackedBy[Us][QUEEN] | ei.attackedBy[Us][KING]; return score; } @@ -768,7 +768,7 @@ Value do_evaluate(const Position& pos, Value& margin) { { // Find the attacked squares around the king which has no defenders // apart from the king itself - undefended = ei.attackedBy[Them][0] & ei.attackedBy[Us][KING]; + undefended = ei.attackedBy[Them][ALL_PIECES] & ei.attackedBy[Us][KING]; undefended &= ~( ei.attackedBy[Us][PAWN] | ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP] | ei.attackedBy[Us][ROOK] | ei.attackedBy[Us][QUEEN]); @@ -816,7 +816,7 @@ Value do_evaluate(const Position& pos, Value& margin) { } // Analyse enemy's safe distance checks for sliders and knights - safe = ~(pos.pieces(Them) | ei.attackedBy[Us][0]); + safe = ~(pos.pieces(Them) | ei.attackedBy[Us][ALL_PIECES]); b1 = pos.attacks_from(ksq) & safe; b2 = pos.attacks_from(ksq) & safe; @@ -903,7 +903,7 @@ Value do_evaluate(const Position& pos, Value& margin) { if (pos.is_empty(blockSq)) { squaresToQueen = forward_bb(Us, s); - defendedSquares = squaresToQueen & ei.attackedBy[Us][0]; + defendedSquares = squaresToQueen & ei.attackedBy[Us][ALL_PIECES]; // If there is an enemy rook or queen attacking the pawn from behind, // add all X-ray attacks by the rook or queen. Otherwise consider only @@ -912,7 +912,7 @@ Value do_evaluate(const Position& pos, Value& margin) { && (forward_bb(Them, s) & pos.pieces(Them, ROOK, QUEEN) & pos.attacks_from(s))) unsafeSquares = squaresToQueen; else - unsafeSquares = squaresToQueen & (ei.attackedBy[Them][0] | pos.pieces(Them)); + unsafeSquares = squaresToQueen & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them)); // If there aren't enemy attacks or pieces along the path to queen give // huge bonus. Even bigger if we protect the pawn's path. @@ -989,7 +989,7 @@ Value do_evaluate(const Position& pos, Value& margin) { // Compute plies to queening and check direct advancement movesToGo = rank_distance(s, queeningSquare) - int(relative_rank(c, s) == RANK_2); oppMovesToGo = square_distance(pos.king_square(~c), queeningSquare) - int(c != pos.side_to_move()); - pathDefended = ((ei.attackedBy[c][0] & queeningPath) == queeningPath); + pathDefended = ((ei.attackedBy[c][ALL_PIECES] & queeningPath) == queeningPath); if (movesToGo >= oppMovesToGo && !pathDefended) continue; @@ -1136,7 +1136,7 @@ Value do_evaluate(const Position& pos, Value& margin) { Bitboard safe = SpaceMask[Us] & ~pos.pieces(Us, PAWN) & ~ei.attackedBy[Them][PAWN] - & (ei.attackedBy[Us][0] | ~ei.attackedBy[Them][0]); + & (ei.attackedBy[Us][ALL_PIECES] | ~ei.attackedBy[Them][ALL_PIECES]); // Find all squares which are at most three squares behind some friendly pawn Bitboard behind = pos.pieces(Us, PAWN); -- 2.39.2