Templetize functions to get pieces by type

Use a single template to get bitboard representation of
the position given the type of piece as a constant.

This removes almost 80 lines of code and introduces an
uniform notation to be used for querying for piece type.

No functional change and no performance change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2009-08-31 17:07:03 +02:00
parent e33c94883f
commit 76bed11f7b
8 changed files with 90 additions and 167 deletions

View File

@@ -171,14 +171,14 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
mi->evaluationFunction = &EvaluateKKX;
return mi;
}
else if ( pos.pawns() == EmptyBoardBB
&& pos.rooks() == EmptyBoardBB
&& pos.queens() == EmptyBoardBB)
else if ( pos.pieces<PAWN>() == EmptyBoardBB
&& pos.pieces<ROOK>() == EmptyBoardBB
&& pos.pieces<QUEEN>() == EmptyBoardBB)
{
// Minor piece endgame with at least one minor piece per side and
// no pawns. Note that the case KmmK is already handled by KXK.
assert(pos.knights(WHITE) | pos.bishops(WHITE));
assert(pos.knights(BLACK) | pos.bishops(BLACK));
assert((pos.pieces<KNIGHT>(WHITE) | pos.pieces<BISHOP>(WHITE)));
assert((pos.pieces<KNIGHT>(BLACK) | pos.pieces<BISHOP>(BLACK)));
if ( pos.piece_count(WHITE, BISHOP) + pos.piece_count(WHITE, KNIGHT) <= 2
&& pos.piece_count(BLACK, BISHOP) + pos.piece_count(BLACK, KNIGHT) <= 2)