mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 09:37:16 +08:00
Helper functions to count material for both sides
Syntactic sugar: helper functions to count material or pieces for both sides. No functional change Closes #1025
This commit is contained in:
@@ -90,6 +90,7 @@ public:
|
||||
Square ep_square() const;
|
||||
bool empty(Square s) const;
|
||||
template<PieceType Pt> int count(Color c) const;
|
||||
template<PieceType Pt> int count() const;
|
||||
template<PieceType Pt> const Square* squares(Color c) const;
|
||||
template<PieceType Pt> Square square(Color c) const;
|
||||
|
||||
@@ -154,6 +155,7 @@ public:
|
||||
int rule50_count() const;
|
||||
Score psq_score() const;
|
||||
Value non_pawn_material(Color c) const;
|
||||
Value non_pawn_material() const;
|
||||
|
||||
// Position consistency check, for debugging
|
||||
bool pos_is_ok(int* failedStep = nullptr) const;
|
||||
@@ -236,6 +238,10 @@ template<PieceType Pt> inline int Position::count(Color c) const {
|
||||
return pieceCount[make_piece(c, Pt)];
|
||||
}
|
||||
|
||||
template<PieceType Pt> inline int Position::count() const {
|
||||
return pieceCount[make_piece(WHITE, Pt)] + pieceCount[make_piece(BLACK, Pt)];
|
||||
}
|
||||
|
||||
template<PieceType Pt> inline const Square* Position::squares(Color c) const {
|
||||
return pieceList[make_piece(c, Pt)];
|
||||
}
|
||||
@@ -330,6 +336,10 @@ inline Value Position::non_pawn_material(Color c) const {
|
||||
return st->nonPawnMaterial[c];
|
||||
}
|
||||
|
||||
inline Value Position::non_pawn_material() const {
|
||||
return st->nonPawnMaterial[WHITE] + st->nonPawnMaterial[BLACK];
|
||||
}
|
||||
|
||||
inline int Position::game_ply() const {
|
||||
return gamePly;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user