Skip to content

Commit

Permalink
Remove make_bitboard()
Browse files Browse the repository at this point in the history
In current master, the function make_bitboard() does nothing apart from
helping initialize the SquareBB[] array. This seems like an unnecessary
abstraction layer.

The advantage of make_bitboard() is we can define a bitboard, in a simple
and general way, not only from a single square but also from a list of
squares. It is more elegant, faster and  readable than combining multiple
SquareBB explicitly, but the last complex use case in evaluation was
simplified away a few months ago.

If make_bitboard() becomes useful again to define complicated bitboards,
it will be easy enough to reintroduce it using this pull request as
an implementation reference.

No functional change.
  • Loading branch information
protonspring authored and snicolet committed Jun 26, 2018
1 parent 1e9397a commit af6072c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion src/bitboard.cpp
Expand Up @@ -89,7 +89,7 @@ void Bitboards::init() {
PopCnt16[i] = (uint8_t) popcount16(i);

for (Square s = SQ_A1; s <= SQ_H8; ++s)
SquareBB[s] = make_bitboard(s);
SquareBB[s] = (1ULL << s);

for (File f = FILE_A; f <= FILE_H; ++f)
FileBB[f] = f > FILE_A ? FileBB[f - 1] << 1 : FileABB;
Expand Down
10 changes: 0 additions & 10 deletions src/bitboard.h
Expand Up @@ -155,16 +155,6 @@ inline Bitboard file_bb(Square s) {
}


/// make_bitboard() returns a bitboard from a list of squares

constexpr Bitboard make_bitboard() { return 0; }

template<typename ...Squares>
constexpr Bitboard make_bitboard(Square s, Squares... squares) {
return (1ULL << s) | make_bitboard(squares...);
}


/// shift() moves a bitboard one step along direction D (mainly for pawns)

template<Direction D>
Expand Down

0 comments on commit af6072c

Please sign in to comment.