Reformat SEE to better document the function

This is one of the most difficult to understand but also
most important and speed critical functions of SF.

This patch rewrites some part of it to hopefully
make it clearer and drop some redundant variables
in the process.

Same speed than master (or even a bit more).

Thanks to Chris Cain for useful feedback.

No functional change.
This commit is contained in:
Marco Costalba
2018-02-23 22:02:10 +01:00
committed by Stéphane Nicolet
parent 52f92d05a9
commit a09eee5798
4 changed files with 59 additions and 59 deletions

View File

@@ -160,15 +160,17 @@ constexpr Bitboard shift(Bitboard b) {
: 0;
}
/// pawn_attacks_bb() returns the pawn attacks for the given color from the
/// squares in the given bitboard.
template<Color c>
template<Color C>
constexpr Bitboard pawn_attacks_bb(Bitboard b) {
return c == WHITE ? shift<NORTH_WEST>(b) | shift<NORTH_EAST>(b)
return C == WHITE ? shift<NORTH_WEST>(b) | shift<NORTH_EAST>(b)
: shift<SOUTH_WEST>(b) | shift<SOUTH_EAST>(b);
}
/// adjacent_files_bb() returns a bitboard representing all the squares on the
/// adjacent files of the given one.
@@ -187,9 +189,9 @@ inline Bitboard between_bb(Square s1, Square s2) {
}
/// forward_ranks_bb() returns a bitboard representing all the squares on all the ranks
/// in front of the given one, from the point of view of the given color. For
/// instance, forward_ranks_bb(BLACK, SQ_D3) will return the 16 squares on ranks 1 and 2.
/// forward_ranks_bb() returns a bitboard representing the squares on all the ranks
/// in front of the given one, from the point of view of the given color. For instance,
/// forward_ranks_bb(BLACK, SQ_D3) will return the 16 squares on ranks 1 and 2.
inline Bitboard forward_ranks_bb(Color c, Square s) {
return ForwardRanksBB[c][rank_of(s)];