1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 01:03:09 +00:00

Rename pieces_of_color() in pieces()

To be uniform with other overloads.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-06-28 15:36:39 +02:00
parent 01a191936e
commit e5077dc11e
5 changed files with 30 additions and 30 deletions

View file

@ -619,7 +619,7 @@ namespace {
Score score = SCORE_ZERO; Score score = SCORE_ZERO;
// Enemy pieces not defended by a pawn and under our attack // 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[Them][PAWN]
& ei.attackedBy[Us][0]; & ei.attackedBy[Us][0];
if (!weakEnemies) if (!weakEnemies)
@ -651,7 +651,7 @@ namespace {
Score score = mobility = SCORE_ZERO; Score score = mobility = SCORE_ZERO;
// Do not include in mobility squares protected by enemy pawns or occupied by our pieces // 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<KNIGHT, Us, HasPopCnt, Trace>(pos, ei, mobility, mobilityArea); score += evaluate_pieces<KNIGHT, Us, HasPopCnt, Trace>(pos, ei, mobility, mobilityArea);
score += evaluate_pieces<BISHOP, Us, HasPopCnt, Trace>(pos, ei, mobility, mobilityArea); score += evaluate_pieces<BISHOP, Us, HasPopCnt, Trace>(pos, ei, mobility, mobilityArea);
@ -705,7 +705,7 @@ namespace {
// Analyse enemy's safe queen contact checks. First find undefended // Analyse enemy's safe queen contact checks. First find undefended
// squares around the king attacked by enemy queen... // 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) if (b)
{ {
// ...then remove squares not supported by another enemy piece // ...then remove squares not supported by another enemy piece
@ -719,7 +719,7 @@ namespace {
// Analyse enemy's safe rook contact checks. First find undefended // Analyse enemy's safe rook contact checks. First find undefended
// squares around the king attacked by enemy rooks... // 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 // Consider only squares where the enemy rook gives check
b &= RookPseudoAttacks[ksq]; b &= RookPseudoAttacks[ksq];
@ -736,7 +736,7 @@ namespace {
} }
// Analyse enemy's safe distance checks for sliders and knights // 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<ROOK>(ksq) & safe; b1 = pos.attacks_from<ROOK>(ksq) & safe;
b2 = pos.attacks_from<BISHOP>(ksq) & safe; b2 = pos.attacks_from<BISHOP>(ksq) & safe;
@ -832,7 +832,7 @@ namespace {
&& (squares_in_front_of(Them, s) & pos.pieces(ROOK, QUEEN, Them) & pos.attacks_from<ROOK>(s))) && (squares_in_front_of(Them, s) & pos.pieces(ROOK, QUEEN, Them) & pos.attacks_from<ROOK>(s)))
unsafeSquares = squaresToQueen; unsafeSquares = squaresToQueen;
else 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 // 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. // 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 // At last, add a small bonus when there are no *friendly* pieces
// in the pawn's path. // in the pawn's path.
if (!(squaresToQueen & pos.pieces_of_color(Us))) if (!(squaresToQueen & pos.pieces(Us)))
ebonus += Value(rr); ebonus += Value(rr);
} }
} // rr != 0 } // rr != 0
@ -924,10 +924,10 @@ namespace {
// Opponent king cannot block because path is defended and position // Opponent king cannot block because path is defended and position
// is not in check. So only friendly pieces can be blockers. // is not in check. So only friendly pieces can be blockers.
assert(!pos.in_check()); 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 // Add moves needed to free the path from friendly pieces and retest condition
movesToGo += count_1s<Max15>(queeningPath & pos.pieces_of_color(c)); movesToGo += count_1s<Max15>(queeningPath & pos.pieces(c));
if (movesToGo >= oppMovesToGo && !pathDefended) if (movesToGo >= oppMovesToGo && !pathDefended)
continue; continue;

View file

@ -157,7 +157,7 @@ MoveStack* generate(const Position& pos, MoveStack* mlist) {
Bitboard target; Bitboard target;
if (Type == MV_CAPTURE || Type == MV_NON_EVASION) 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) else if (Type == MV_NON_CAPTURE)
target = pos.empty_squares(); target = pos.empty_squares();
else else
@ -289,7 +289,7 @@ MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
} while (b); } while (b);
// Generate evasions for king, capture and non capture moves // Generate evasions for king, capture and non capture moves
b = pos.attacks_from<KING>(ksq) & ~pos.pieces_of_color(us) & ~sliderAttacks; b = pos.attacks_from<KING>(ksq) & ~pos.pieces(us) & ~sliderAttacks;
from = ksq; from = ksq;
SERIALIZE_MOVES(b); SERIALIZE_MOVES(b);
@ -411,7 +411,7 @@ namespace {
Bitboard b1, b2, dc1, dc2, pawnPushes, emptySquares; Bitboard b1, b2, dc1, dc2, pawnPushes, emptySquares;
Bitboard pawns = pos.pieces(PAWN, Us); Bitboard pawns = pos.pieces(PAWN, Us);
Bitboard pawnsOn7 = pawns & TRank7BB; 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 // Pre-calculate pawn pushes before changing emptySquares definition
if (Type != MV_CAPTURE) if (Type != MV_CAPTURE)
@ -518,7 +518,7 @@ namespace {
// It is a bit complicated to correctly handle Chess960 // It is a bit complicated to correctly handle Chess960
for (s = Min(ksq, s1); s <= Max(ksq, s1); s++) for (s = Min(ksq, s1); s <= Max(ksq, s1); s++)
if ( (s != ksq && s != rsq && !pos.square_is_empty(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; illegal = true;
for (s = Min(rsq, s2); s <= Max(rsq, s2); s++) for (s = Min(rsq, s2); s <= Max(rsq, s2); s++)

View file

@ -364,7 +364,7 @@ template<bool FindPinned>
Bitboard Position::hidden_checkers(Color c) const { Bitboard Position::hidden_checkers(Color c) const {
Bitboard result = EmptyBoardBB; 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 // Pinned pieces protect our king, dicovery checks attack
// the enemy king. // the enemy king.
@ -384,7 +384,7 @@ Bitboard Position::hidden_checkers(Color c) const {
assert(b); assert(b);
if ( !(b & (b - 1)) // Only one bit set? 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; result |= b;
} }
return result; 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)); do_move_bb(&occ, make_move_bb(f, t));
xray = ( (rook_attacks_bb(s, occ) & pieces(ROOK, QUEEN)) xray = ( (rook_attacks_bb(s, occ) & pieces(ROOK, QUEEN))
|(bishop_attacks_bb(s, occ) & pieces(BISHOP, 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 // If we have attacks we need to verify that are caused by our move
// and are not already existent ones. // and are not already existent ones.
@ -502,7 +502,7 @@ bool Position::move_attacks_square(Move m, Square s) const {
void Position::find_checkers() { void Position::find_checkers() {
Color us = side_to_move(); 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 // square is attacked by the opponent. Castling moves are checked
// for legality during move generation. // for legality during move generation.
if (piece_type(piece_on(from)) == KING) 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 // 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. // 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(); Bitboard b = occupied_squares();
clear_bit(&b, from); 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; return false;
} }
else else
@ -1010,7 +1010,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
if (moveIsCheck) if (moveIsCheck)
{ {
if (ep | pm) if (ep | pm)
st->checkersBB = attackers_to(king_square(them)) & pieces_of_color(us); st->checkersBB = attackers_to(king_square(them)) & pieces(us);
else else
{ {
// Direct checks // Direct checks
@ -1188,7 +1188,7 @@ void Position::do_castle_move(Move m) {
st->rule50 = 0; st->rule50 = 0;
// Update checkers BB // Update checkers BB
st->checkersBB = attackers_to(king_square(them)) & pieces_of_color(us); st->checkersBB = attackers_to(king_square(them)) & pieces(us);
// Finish // Finish
sideToMove = opposite_color(sideToMove); sideToMove = opposite_color(sideToMove);
@ -1491,7 +1491,7 @@ int Position::see(Move m) const {
// If the opponent has no attackers we are finished // If the opponent has no attackers we are finished
stm = opposite_color(piece_color(piece_on(from))); stm = opposite_color(piece_color(piece_on(from)));
stmAttackers = attackers & pieces_of_color(stm); stmAttackers = attackers & pieces(stm);
if (!stmAttackers) if (!stmAttackers)
return PieceValueMidgame[capturedType]; return PieceValueMidgame[capturedType];
@ -1529,7 +1529,7 @@ int Position::see(Move m) const {
// move before beginning the next iteration. // move before beginning the next iteration.
capturedType = pt; capturedType = pt;
stm = opposite_color(stm); stm = opposite_color(stm);
stmAttackers = attackers & pieces_of_color(stm); stmAttackers = attackers & pieces(stm);
// Stop before processing a king capture // Stop before processing a king capture
if (capturedType == KING && stmAttackers) if (capturedType == KING && stmAttackers)
@ -1881,7 +1881,7 @@ bool Position::is_ok(int* failedStep) const {
Color us = side_to_move(); Color us = side_to_move();
Color them = opposite_color(us); Color them = opposite_color(us);
Square ksq = king_square(them); Square ksq = king_square(them);
if (attackers_to(ksq) & pieces_of_color(us)) if (attackers_to(ksq) & pieces(us))
return false; return false;
} }
@ -1895,12 +1895,12 @@ bool Position::is_ok(int* failedStep) const {
if (debugBitboards) if (debugBitboards)
{ {
// The intersection of the white and black pieces must be empty // 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; return false;
// The union of the white and black pieces must be equal to all // The union of the white and black pieces must be equal to all
// occupied squares // occupied squares
if ((pieces_of_color(WHITE) | pieces_of_color(BLACK)) != occupied_squares()) if ((pieces(WHITE) | pieces(BLACK)) != occupied_squares())
return false; return false;
// Separate piece type bitboards must have empty intersections // Separate piece type bitboards must have empty intersections

View file

@ -137,7 +137,7 @@ public:
// Bitboard representation of the position // Bitboard representation of the position
Bitboard empty_squares() const; Bitboard empty_squares() const;
Bitboard occupied_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) const;
Bitboard pieces(PieceType pt, Color c) const; Bitboard pieces(PieceType pt, Color c) const;
Bitboard pieces(PieceType pt1, PieceType pt2) const; Bitboard pieces(PieceType pt1, PieceType pt2) const;
@ -333,7 +333,7 @@ inline Bitboard Position::empty_squares() const {
return ~occupied_squares(); return ~occupied_squares();
} }
inline Bitboard Position::pieces_of_color(Color c) const { inline Bitboard Position::pieces(Color c) const {
return byColorBB[c]; return byColorBB[c];
} }

View file

@ -1524,7 +1524,7 @@ split_point_start: // At split points actual search starts from here
newAtt = pos.attacks_from(pc, to, occ); newAtt = pos.attacks_from(pc, to, occ);
// Rule 1. Checks which give opponent's king at most one escape square are dangerous // 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)))) if (!(b && (b & (b - 1))))
return true; return true;
@ -1535,7 +1535,7 @@ split_point_start: // At split points actual search starts from here
return true; return true;
// Rule 3. Creating new double threats with checks // 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) while (b)
{ {