Move game phase computation to MaterialInfo

Game phase is a strictly function of the material
combination so its natural place is MaterialInfo,
not position.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2009-11-13 13:29:04 +01:00
parent 314faa905a
commit 71e852ea81
4 changed files with 40 additions and 24 deletions

View File

@@ -255,7 +255,6 @@ public:
// Incremental evaluation
Score value() const;
Value non_pawn_material(Color c) const;
Phase game_phase() const;
Score pst_delta(Piece piece, Square from, Square to) const;
// Game termination checks
@@ -526,22 +525,6 @@ inline Value Position::non_pawn_material(Color c) const {
return st->npMaterial[c];
}
inline Phase Position::game_phase() const {
// Values modified by Joona Kiiski
static const Value MidgameLimit = Value(15581);
static const Value EndgameLimit = Value(3998);
Value npm = non_pawn_material(WHITE) + non_pawn_material(BLACK);
if (npm >= MidgameLimit)
return PHASE_MIDGAME;
else if(npm <= EndgameLimit)
return PHASE_ENDGAME;
else
return Phase(((npm - EndgameLimit) * 128) / (MidgameLimit - EndgameLimit));
}
inline bool Position::move_is_passed_pawn_push(Move m) const {
Color c = side_to_move();