Position: Unify and templetize mg_pst() and eg_pst()

Also templetize compute_value() can be simpler now that
the above is templetized too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2009-02-20 12:21:52 +01:00
parent f30aa83f8a
commit b7cb6180cf
2 changed files with 44 additions and 48 deletions

View File

@@ -319,9 +319,8 @@ private:
MidGame,
EndGame
};
Value mg_pst(Color c, PieceType pt, Square s) const;
Value eg_pst(Color c, PieceType pt, Square s) const;
Value compute_value(GamePhase p) const;
template<GamePhase> Value pst(Color c, PieceType pt, Square s) const;
template<GamePhase> Value compute_value() const;
Value compute_non_pawn_material(Color c) const;
// Bitboards
@@ -633,8 +632,10 @@ inline Key Position::get_material_key() const {
return materialKey;
}
inline Value Position::mg_pst(Color c, PieceType pt, Square s) const {
return MgPieceSquareTable[piece_of_color_and_type(c, pt)][s];
template<Position::GamePhase Phase>
inline Value Position::pst(Color c, PieceType pt, Square s) const {
return (Phase == MidGame ? MgPieceSquareTable[piece_of_color_and_type(c, pt)][s]
: EgPieceSquareTable[piece_of_color_and_type(c, pt)][s]);
}
inline Value Position::mg_pst_delta(Move m) const {
@@ -642,10 +643,6 @@ inline Value Position::mg_pst_delta(Move m) const {
-MgPieceSquareTable[piece_on(move_from(m))][move_from(m)];
}
inline Value Position::eg_pst(Color c, PieceType pt, Square s) const {
return EgPieceSquareTable[piece_of_color_and_type(c, pt)][s];
}
inline Value Position::mg_value() const {
return mgValue;
}