Skip to content

Commit a4c11b7

Browse files
committed
Retire in_front_bb(Color c, Square s) overload
Explciitly call rank_of() in the few places where it is used. No functional change.
1 parent b2fadf3 commit a4c11b7

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

src/bitboard.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,15 @@ inline Bitboard adjacent_files_bb(File f) {
135135
}
136136

137137

138-
/// in_front_bb() takes a color and a rank or square as input, and returns a
139-
/// bitboard representing all the squares on all ranks in front of the rank
140-
/// (or square), from the given color's point of view. For instance,
141-
/// in_front_bb(WHITE, RANK_5) will give all squares on ranks 6, 7 and 8, while
142-
/// in_front_bb(BLACK, SQ_D3) will give all squares on ranks 1 and 2.
138+
/// in_front_bb() takes a color and a rank as input, and returns a bitboard
139+
/// representing all the squares on all ranks in front of the rank, from the
140+
/// given color's point of view. For instance, in_front_bb(BLACK, RANK_3) will
141+
/// give all squares on ranks 1 and 2.
143142

144143
inline Bitboard in_front_bb(Color c, Rank r) {
145144
return InFrontBB[c][r];
146145
}
147146

148-
inline Bitboard in_front_bb(Color c, Square s) {
149-
return InFrontBB[c][rank_of(s)];
150-
}
151-
152147

153148
/// between_bb returns a bitboard representing all squares between two squares.
154149
/// For instance, between_bb(SQ_C4, SQ_F7) returns a bitboard with the bits for

src/endgame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
704704
// Does the defending king block the pawns?
705705
if ( square_distance(ksq, relative_square(strongerSide, SQ_A8)) <= 1
706706
|| ( file_of(ksq) == FILE_A
707-
&& !(in_front_bb(strongerSide, ksq) & pawns)))
707+
&& !(in_front_bb(strongerSide, rank_of(ksq)) & pawns)))
708708
return SCALE_FACTOR_DRAW;
709709
}
710710
// Are all pawns on the 'h' file?
@@ -713,7 +713,7 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
713713
// Does the defending king block the pawns?
714714
if ( square_distance(ksq, relative_square(strongerSide, SQ_H8)) <= 1
715715
|| ( file_of(ksq) == FILE_H
716-
&& !(in_front_bb(strongerSide, ksq) & pawns)))
716+
&& !(in_front_bb(strongerSide, rank_of(ksq)) & pawns)))
717717
return SCALE_FACTOR_DRAW;
718718
}
719719
return SCALE_FACTOR_NONE;

src/evaluate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
989989
// black pawns: a4, b4 white: b2 then pawn in b4 is giving support.
990990
if (!opposed)
991991
{
992-
b2 = supporters & in_front_bb(winnerSide, blockSq + pawn_push(winnerSide));
992+
b2 = supporters & in_front_bb(winnerSide, rank_of(blockSq + pawn_push(winnerSide)));
993993

994994
while (b2) // This while-loop could be replaced with LSB/MSB (depending on color)
995995
{

src/pawns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
220220
const Color Them = (Us == WHITE ? BLACK : WHITE);
221221

222222
Value safety = MaxSafetyBonus;
223-
Bitboard b = pos.pieces(PAWN) & (in_front_bb(Us, ksq) | rank_bb(ksq));
223+
Bitboard b = pos.pieces(PAWN) & (in_front_bb(Us, rank_of(ksq)) | rank_bb(ksq));
224224
Bitboard ourPawns = b & pos.pieces(Us) & ~rank_bb(ksq);
225225
Bitboard theirPawns = b & pos.pieces(Them);
226226
Rank rkUs, rkThem;

0 commit comments

Comments
 (0)