mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 16:47:37 +00:00
Unify compute_mg_value() and compute_eg_value()
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
+10
-29
@@ -210,8 +210,8 @@ void Position::from_fen(const std::string& fen) {
|
|||||||
key = compute_key();
|
key = compute_key();
|
||||||
pawnKey = compute_pawn_key();
|
pawnKey = compute_pawn_key();
|
||||||
materialKey = compute_material_key();
|
materialKey = compute_material_key();
|
||||||
mgValue = compute_mg_value();
|
mgValue = compute_value(MidGame);
|
||||||
egValue = compute_eg_value();
|
egValue = compute_value(EndGame);
|
||||||
npMaterial[WHITE] = compute_non_pawn_material(WHITE);
|
npMaterial[WHITE] = compute_non_pawn_material(WHITE);
|
||||||
npMaterial[BLACK] = compute_non_pawn_material(BLACK);
|
npMaterial[BLACK] = compute_non_pawn_material(BLACK);
|
||||||
}
|
}
|
||||||
@@ -1817,7 +1817,7 @@ Key Position::compute_material_key() const {
|
|||||||
/// up, and to verify that the scores are correctly updated by do_move
|
/// up, and to verify that the scores are correctly updated by do_move
|
||||||
/// and undo_move when the program is running in debug mode.
|
/// and undo_move when the program is running in debug mode.
|
||||||
|
|
||||||
Value Position::compute_mg_value() const {
|
Value Position::compute_value(GamePhase p) const {
|
||||||
|
|
||||||
Value result = Value(0);
|
Value result = Value(0);
|
||||||
Bitboard b;
|
Bitboard b;
|
||||||
@@ -1831,31 +1831,12 @@ Value Position::compute_mg_value() const {
|
|||||||
{
|
{
|
||||||
s = pop_1st_bit(&b);
|
s = pop_1st_bit(&b);
|
||||||
assert(piece_on(s) == piece_of_color_and_type(c, pt));
|
assert(piece_on(s) == piece_of_color_and_type(c, pt));
|
||||||
result += mg_pst(c, pt, s);
|
result += (p == MidGame ? mg_pst(c, pt, s) : eg_pst(c, pt, s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result += (side_to_move() == WHITE)? TempoValueMidgame / 2 : -TempoValueMidgame / 2;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Value Position::compute_eg_value() const {
|
const Value TempoValue = (p == MidGame ? TempoValueMidgame : TempoValueEndgame);
|
||||||
|
result += (side_to_move() == WHITE)? TempoValue / 2 : -TempoValue / 2;
|
||||||
Value result = Value(0);
|
|
||||||
Bitboard b;
|
|
||||||
Square s;
|
|
||||||
|
|
||||||
for (Color c = WHITE; c <= BLACK; c++)
|
|
||||||
for (PieceType pt = PAWN; pt <= KING; pt++)
|
|
||||||
{
|
|
||||||
b = pieces_of_color_and_type(c, pt);
|
|
||||||
while(b)
|
|
||||||
{
|
|
||||||
s = pop_1st_bit(&b);
|
|
||||||
assert(piece_on(s) == piece_of_color_and_type(c, pt));
|
|
||||||
result += eg_pst(c, pt, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result += (side_to_move() == WHITE)? TempoValueEndgame / 2 : -TempoValueEndgame / 2;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2076,8 +2057,8 @@ void Position::flipped_copy(const Position &pos) {
|
|||||||
materialKey = compute_material_key();
|
materialKey = compute_material_key();
|
||||||
|
|
||||||
// Incremental scores
|
// Incremental scores
|
||||||
mgValue = compute_mg_value();
|
mgValue = compute_value(MidGame);
|
||||||
egValue = compute_eg_value();
|
egValue = compute_value(EndGame);
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
npMaterial[WHITE] = compute_non_pawn_material(WHITE);
|
npMaterial[WHITE] = compute_non_pawn_material(WHITE);
|
||||||
@@ -2206,10 +2187,10 @@ bool Position::is_ok(int* failedStep) const {
|
|||||||
if (failedStep) (*failedStep)++;
|
if (failedStep) (*failedStep)++;
|
||||||
if (debugIncrementalEval)
|
if (debugIncrementalEval)
|
||||||
{
|
{
|
||||||
if (mgValue != compute_mg_value())
|
if (mgValue != compute_value(MidGame))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (egValue != compute_eg_value())
|
if (egValue != compute_value(EndGame))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -315,10 +315,13 @@ private:
|
|||||||
Key compute_material_key() const;
|
Key compute_material_key() const;
|
||||||
|
|
||||||
// Computing incremental evaluation scores and material counts
|
// Computing incremental evaluation scores and material counts
|
||||||
|
enum GamePhase {
|
||||||
|
MidGame,
|
||||||
|
EndGame
|
||||||
|
};
|
||||||
Value mg_pst(Color c, PieceType pt, Square s) const;
|
Value mg_pst(Color c, PieceType pt, Square s) const;
|
||||||
Value eg_pst(Color c, PieceType pt, Square s) const;
|
Value eg_pst(Color c, PieceType pt, Square s) const;
|
||||||
Value compute_mg_value() const;
|
Value compute_value(GamePhase p) const;
|
||||||
Value compute_eg_value() const;
|
|
||||||
Value compute_non_pawn_material(Color c) const;
|
Value compute_non_pawn_material(Color c) const;
|
||||||
|
|
||||||
// Bitboards
|
// Bitboards
|
||||||
|
|||||||
Reference in New Issue
Block a user