From e5077dc11e8047eb8ce32a166a73e433a7e19b15 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Tue, 28 Jun 2011 15:36:39 +0200 Subject: [PATCH] Rename pieces_of_color() in pieces() To be uniform with other overloads. No functional change. Signed-off-by: Marco Costalba --- src/evaluate.cpp | 18 +++++++++--------- src/movegen.cpp | 8 ++++---- src/position.cpp | 26 +++++++++++++------------- src/position.h | 4 ++-- src/search.cpp | 4 ++-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 2cfa4d5a..f7ae1977 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -619,7 +619,7 @@ namespace { Score score = SCORE_ZERO; // Enemy pieces not defended by a pawn and under our attack - Bitboard weakEnemies = pos.pieces_of_color(Them) + Bitboard weakEnemies = pos.pieces(Them) & ~ei.attackedBy[Them][PAWN] & ei.attackedBy[Us][0]; if (!weakEnemies) @@ -651,7 +651,7 @@ namespace { Score score = mobility = SCORE_ZERO; // Do not include in mobility squares protected by enemy pawns or occupied by our pieces - const Bitboard mobilityArea = ~(ei.attackedBy[Them][PAWN] | pos.pieces_of_color(Us)); + const Bitboard mobilityArea = ~(ei.attackedBy[Them][PAWN] | pos.pieces(Us)); score += evaluate_pieces(pos, ei, mobility, mobilityArea); score += evaluate_pieces(pos, ei, mobility, mobilityArea); @@ -705,7 +705,7 @@ namespace { // Analyse enemy's safe queen contact checks. First find undefended // squares around the king attacked by enemy queen... - b = undefended & ei.attackedBy[Them][QUEEN] & ~pos.pieces_of_color(Them); + b = undefended & ei.attackedBy[Them][QUEEN] & ~pos.pieces(Them); if (b) { // ...then remove squares not supported by another enemy piece @@ -719,7 +719,7 @@ namespace { // Analyse enemy's safe rook contact checks. First find undefended // squares around the king attacked by enemy rooks... - b = undefended & ei.attackedBy[Them][ROOK] & ~pos.pieces_of_color(Them); + b = undefended & ei.attackedBy[Them][ROOK] & ~pos.pieces(Them); // Consider only squares where the enemy rook gives check b &= RookPseudoAttacks[ksq]; @@ -736,7 +736,7 @@ namespace { } // Analyse enemy's safe distance checks for sliders and knights - safe = ~(pos.pieces_of_color(Them) | ei.attackedBy[Us][0]); + safe = ~(pos.pieces(Them) | ei.attackedBy[Us][0]); b1 = pos.attacks_from(ksq) & safe; b2 = pos.attacks_from(ksq) & safe; @@ -832,7 +832,7 @@ namespace { && (squares_in_front_of(Them, s) & pos.pieces(ROOK, QUEEN, Them) & pos.attacks_from(s))) unsafeSquares = squaresToQueen; else - unsafeSquares = squaresToQueen & (ei.attackedBy[Them][0] | pos.pieces_of_color(Them)); + unsafeSquares = squaresToQueen & (ei.attackedBy[Them][0] | 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. @@ -847,7 +847,7 @@ namespace { // At last, add a small bonus when there are no *friendly* pieces // in the pawn's path. - if (!(squaresToQueen & pos.pieces_of_color(Us))) + if (!(squaresToQueen & pos.pieces(Us))) ebonus += Value(rr); } } // rr != 0 @@ -924,10 +924,10 @@ namespace { // Opponent king cannot block because path is defended and position // is not in check. So only friendly pieces can be blockers. assert(!pos.in_check()); - assert((queeningPath & pos.occupied_squares()) == (queeningPath & pos.pieces_of_color(c))); + assert((queeningPath & pos.occupied_squares()) == (queeningPath & pos.pieces(c))); // Add moves needed to free the path from friendly pieces and retest condition - movesToGo += count_1s(queeningPath & pos.pieces_of_color(c)); + movesToGo += count_1s(queeningPath & pos.pieces(c)); if (movesToGo >= oppMovesToGo && !pathDefended) continue; diff --git a/src/movegen.cpp b/src/movegen.cpp index cc635b84..9b4cc130 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -157,7 +157,7 @@ MoveStack* generate(const Position& pos, MoveStack* mlist) { Bitboard target; if (Type == MV_CAPTURE || Type == MV_NON_EVASION) - target = pos.pieces_of_color(opposite_color(us)); + target = pos.pieces(opposite_color(us)); else if (Type == MV_NON_CAPTURE) target = pos.empty_squares(); else @@ -289,7 +289,7 @@ MoveStack* generate(const Position& pos, MoveStack* mlist) { } while (b); // Generate evasions for king, capture and non capture moves - b = pos.attacks_from(ksq) & ~pos.pieces_of_color(us) & ~sliderAttacks; + b = pos.attacks_from(ksq) & ~pos.pieces(us) & ~sliderAttacks; from = ksq; SERIALIZE_MOVES(b); @@ -411,7 +411,7 @@ namespace { Bitboard b1, b2, dc1, dc2, pawnPushes, emptySquares; Bitboard pawns = pos.pieces(PAWN, Us); Bitboard pawnsOn7 = pawns & TRank7BB; - Bitboard enemyPieces = (Type == MV_CAPTURE ? target : pos.pieces_of_color(Them)); + Bitboard enemyPieces = (Type == MV_CAPTURE ? target : pos.pieces(Them)); // Pre-calculate pawn pushes before changing emptySquares definition if (Type != MV_CAPTURE) @@ -518,7 +518,7 @@ namespace { // It is a bit complicated to correctly handle Chess960 for (s = Min(ksq, s1); s <= Max(ksq, s1); s++) if ( (s != ksq && s != rsq && !pos.square_is_empty(s)) - ||(pos.attackers_to(s) & pos.pieces_of_color(them))) + ||(pos.attackers_to(s) & pos.pieces(them))) illegal = true; for (s = Min(rsq, s2); s <= Max(rsq, s2); s++) diff --git a/src/position.cpp b/src/position.cpp index 77c0647a..eb3cb895 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -364,7 +364,7 @@ template Bitboard Position::hidden_checkers(Color c) const { Bitboard result = EmptyBoardBB; - Bitboard pinners = pieces_of_color(FindPinned ? opposite_color(c) : c); + Bitboard pinners = pieces(FindPinned ? opposite_color(c) : c); // Pinned pieces protect our king, dicovery checks attack // the enemy king. @@ -384,7 +384,7 @@ Bitboard Position::hidden_checkers(Color c) const { assert(b); if ( !(b & (b - 1)) // Only one bit set? - && (b & pieces_of_color(c))) // Is an our piece? + && (b & pieces(c))) // Is an our piece? result |= b; } return result; @@ -485,7 +485,7 @@ bool Position::move_attacks_square(Move m, Square s) const { do_move_bb(&occ, make_move_bb(f, t)); xray = ( (rook_attacks_bb(s, occ) & pieces(ROOK, QUEEN)) |(bishop_attacks_bb(s, occ) & pieces(BISHOP, QUEEN))) - & pieces_of_color(piece_color(piece_on(f))); + & pieces(piece_color(piece_on(f))); // If we have attacks we need to verify that are caused by our move // and are not already existent ones. @@ -502,7 +502,7 @@ bool Position::move_attacks_square(Move m, Square s) const { void Position::find_checkers() { Color us = side_to_move(); - st->checkersBB = attackers_to(king_square(us)) & pieces_of_color(opposite_color(us)); + st->checkersBB = attackers_to(king_square(us)) & pieces(opposite_color(us)); } @@ -548,7 +548,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { // square is attacked by the opponent. Castling moves are checked // for legality during move generation. if (piece_type(piece_on(from)) == KING) - return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us))); + return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces(opposite_color(us))); // A non-king move is legal if and only if it is not pinned or it // is moving along the ray towards or away from the king. @@ -681,7 +681,7 @@ bool Position::move_is_pl(const Move m) const { { Bitboard b = occupied_squares(); clear_bit(&b, from); - if (attackers_to(move_to(m), b) & pieces_of_color(opposite_color(us))) + if (attackers_to(move_to(m), b) & pieces(opposite_color(us))) return false; } else @@ -1010,7 +1010,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI if (moveIsCheck) { if (ep | pm) - st->checkersBB = attackers_to(king_square(them)) & pieces_of_color(us); + st->checkersBB = attackers_to(king_square(them)) & pieces(us); else { // Direct checks @@ -1188,7 +1188,7 @@ void Position::do_castle_move(Move m) { st->rule50 = 0; // Update checkers BB - st->checkersBB = attackers_to(king_square(them)) & pieces_of_color(us); + st->checkersBB = attackers_to(king_square(them)) & pieces(us); // Finish sideToMove = opposite_color(sideToMove); @@ -1491,7 +1491,7 @@ int Position::see(Move m) const { // If the opponent has no attackers we are finished stm = opposite_color(piece_color(piece_on(from))); - stmAttackers = attackers & pieces_of_color(stm); + stmAttackers = attackers & pieces(stm); if (!stmAttackers) return PieceValueMidgame[capturedType]; @@ -1529,7 +1529,7 @@ int Position::see(Move m) const { // move before beginning the next iteration. capturedType = pt; stm = opposite_color(stm); - stmAttackers = attackers & pieces_of_color(stm); + stmAttackers = attackers & pieces(stm); // Stop before processing a king capture if (capturedType == KING && stmAttackers) @@ -1881,7 +1881,7 @@ bool Position::is_ok(int* failedStep) const { Color us = side_to_move(); Color them = opposite_color(us); Square ksq = king_square(them); - if (attackers_to(ksq) & pieces_of_color(us)) + if (attackers_to(ksq) & pieces(us)) return false; } @@ -1895,12 +1895,12 @@ bool Position::is_ok(int* failedStep) const { if (debugBitboards) { // The intersection of the white and black pieces must be empty - if ((pieces_of_color(WHITE) & pieces_of_color(BLACK)) != EmptyBoardBB) + if ((pieces(WHITE) & pieces(BLACK)) != EmptyBoardBB) return false; // The union of the white and black pieces must be equal to all // occupied squares - if ((pieces_of_color(WHITE) | pieces_of_color(BLACK)) != occupied_squares()) + if ((pieces(WHITE) | pieces(BLACK)) != occupied_squares()) return false; // Separate piece type bitboards must have empty intersections diff --git a/src/position.h b/src/position.h index 244d365b..9e4a6e4c 100644 --- a/src/position.h +++ b/src/position.h @@ -137,7 +137,7 @@ public: // Bitboard representation of the position Bitboard empty_squares() const; Bitboard occupied_squares() const; - Bitboard pieces_of_color(Color c) const; + Bitboard pieces(Color c) const; Bitboard pieces(PieceType pt) const; Bitboard pieces(PieceType pt, Color c) const; Bitboard pieces(PieceType pt1, PieceType pt2) const; @@ -333,7 +333,7 @@ inline Bitboard Position::empty_squares() const { return ~occupied_squares(); } -inline Bitboard Position::pieces_of_color(Color c) const { +inline Bitboard Position::pieces(Color c) const { return byColorBB[c]; } diff --git a/src/search.cpp b/src/search.cpp index daf40dec..092f7d73 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1524,7 +1524,7 @@ split_point_start: // At split points actual search starts from here newAtt = pos.attacks_from(pc, to, occ); // Rule 1. Checks which give opponent's king at most one escape square are dangerous - b = kingAtt & ~pos.pieces_of_color(them) & ~newAtt & ~(1ULL << to); + b = kingAtt & ~pos.pieces(them) & ~newAtt & ~(1ULL << to); if (!(b && (b & (b - 1)))) return true; @@ -1535,7 +1535,7 @@ split_point_start: // At split points actual search starts from here return true; // Rule 3. Creating new double threats with checks - b = pos.pieces_of_color(them) & newAtt & ~oldAtt & ~(1ULL << ksq); + b = pos.pieces(them) & newAtt & ~oldAtt & ~(1ULL << ksq); while (b) { -- 2.39.2