No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
// Initialize by reading the incrementally updated scores included in the
// position object (material + piece square tables)
// Initialize by reading the incrementally updated scores included in the
// position object (material + piece square tables)
- ei.value = Score(pos.mg_value(), pos.eg_value());
+ ei.value = pos.value();
// Probe the material hash table
ei.mi = MaterialTable[threadID]->get_material_info(pos);
// Probe the material hash table
ei.mi = MaterialTable[threadID]->get_material_info(pos);
static const
ScaleFactor sf[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL};
static const
ScaleFactor sf[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL};
- Score v = Score(pos.mg_value(), pos.eg_value());
Phase ph = pos.game_phase();
Color stm = pos.side_to_move();
Phase ph = pos.game_phase();
Color stm = pos.side_to_move();
- return Sign[stm] * scale_by_game_phase(v, ph, sf);
+ return Sign[stm] * scale_by_game_phase(pos.value(), ph, sf);
st->key = compute_key();
st->pawnKey = compute_pawn_key();
st->materialKey = compute_material_key();
st->key = compute_key();
st->pawnKey = compute_pawn_key();
st->materialKey = compute_material_key();
- st->mgValue = compute_value<MidGame>();
- st->egValue = compute_value<EndGame>();
+ st->value = Score(compute_value<MidGame>(), compute_value<EndGame>());
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
}
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
}
}
// Update incremental scores
}
// Update incremental scores
- st->mgValue += pst_delta<MidGame>(piece, from, to);
- st->egValue += pst_delta<EndGame>(piece, from, to);
+ st->value += Score(pst_delta<MidGame>(piece, from, to), pst_delta<EndGame>(piece, from, to));
st->pawnKey ^= zobrist[us][PAWN][to];
// Partially revert and update incremental scores
st->pawnKey ^= zobrist[us][PAWN][to];
// Partially revert and update incremental scores
- st->mgValue -= pst<MidGame>(us, PAWN, to);
- st->mgValue += pst<MidGame>(us, promotion, to);
- st->egValue -= pst<EndGame>(us, PAWN, to);
- st->egValue += pst<EndGame>(us, promotion, to);
+ st->value -= Score(pst<MidGame>(us, PAWN, to), pst<EndGame>(us, PAWN, to));
+ st->value += Score(pst<MidGame>(us, promotion, to), pst<EndGame>(us, promotion, to));
// Update material
st->npMaterial[us] += piece_value_midgame(promotion);
// Update material
st->npMaterial[us] += piece_value_midgame(promotion);
// Finish
sideToMove = opposite_color(sideToMove);
// Finish
sideToMove = opposite_color(sideToMove);
-
- st->mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
- st->egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame;
+ st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
key ^= zobrist[them][capture][capsq];
// Update incremental scores
key ^= zobrist[them][capture][capsq];
// Update incremental scores
- st->mgValue -= pst<MidGame>(them, capture, capsq);
- st->egValue -= pst<EndGame>(them, capture, capsq);
+ st->value -= Score(pst<MidGame>(them, capture, capsq), pst<EndGame>(them, capture, capsq));
// If the captured piece was a pawn, update pawn hash key,
// otherwise update non-pawn material.
// If the captured piece was a pawn, update pawn hash key,
// otherwise update non-pawn material.
index[rto] = tmp;
// Update incremental scores
index[rto] = tmp;
// Update incremental scores
- st->mgValue += pst_delta<MidGame>(king, kfrom, kto);
- st->egValue += pst_delta<EndGame>(king, kfrom, kto);
- st->mgValue += pst_delta<MidGame>(rook, rfrom, rto);
- st->egValue += pst_delta<EndGame>(rook, rfrom, rto);
+ st->value += Score(pst_delta<MidGame>(king, kfrom, kto), pst_delta<EndGame>(king, kfrom, kto));
+ st->value += Score(pst_delta<MidGame>(rook, rfrom, rto), pst_delta<EndGame>(rook, rfrom, rto));
// Update hash key
st->key ^= zobrist[us][KING][kfrom] ^ zobrist[us][KING][kto];
// Update hash key
st->key ^= zobrist[us][KING][kfrom] ^ zobrist[us][KING][kto];
// Finish
sideToMove = opposite_color(sideToMove);
// Finish
sideToMove = opposite_color(sideToMove);
-
- st->mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
- st->egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame;
+ st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
// a backup storage not as a new state to be used.
backupSt.key = st->key;
backupSt.epSquare = st->epSquare;
// a backup storage not as a new state to be used.
backupSt.key = st->key;
backupSt.epSquare = st->epSquare;
- backupSt.mgValue = st->mgValue;
- backupSt.egValue = st->egValue;
+ backupSt.value = st->value;
backupSt.previous = st->previous;
backupSt.pliesFromNull = st->pliesFromNull;
st->previous = &backupSt;
backupSt.previous = st->previous;
backupSt.pliesFromNull = st->pliesFromNull;
st->previous = &backupSt;
st->epSquare = SQ_NONE;
st->rule50++;
st->pliesFromNull = 0;
st->epSquare = SQ_NONE;
st->rule50++;
st->pliesFromNull = 0;
+ st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
-
- st->mgValue += (sideToMove == WHITE)? TempoValueMidgame : -TempoValueMidgame;
- st->egValue += (sideToMove == WHITE)? TempoValueEndgame : -TempoValueEndgame;
StateInfo* backupSt = st->previous;
st->key = backupSt->key;
st->epSquare = backupSt->epSquare;
StateInfo* backupSt = st->previous;
st->key = backupSt->key;
st->epSquare = backupSt->epSquare;
- st->mgValue = backupSt->mgValue;
- st->egValue = backupSt->egValue;
+ st->value = backupSt->value;
st->previous = backupSt->previous;
st->pliesFromNull = backupSt->pliesFromNull;
st->previous = backupSt->previous;
st->pliesFromNull = backupSt->pliesFromNull;
- const Value TempoValue = (Phase == MidGame ? TempoValueMidgame : TempoValueEndgame);
- result += (side_to_move() == WHITE)? TempoValue / 2 : -TempoValue / 2;
+ const Value tv = (Phase == MidGame ? TempoValue.mg() : TempoValue.eg());
+ result += (side_to_move() == WHITE)? tv / 2 : -tv / 2;
st->materialKey = compute_material_key();
// Incremental scores
st->materialKey = compute_material_key();
// Incremental scores
- st->mgValue = compute_value<MidGame>();
- st->egValue = compute_value<EndGame>();
+ st->value = Score(compute_value<MidGame>(), compute_value<EndGame>());
// Material
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
// Material
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
if (failedStep) (*failedStep)++;
if (debugIncrementalEval)
{
if (failedStep) (*failedStep)++;
if (debugIncrementalEval)
{
- if (st->mgValue != compute_value<MidGame>())
+ if (st->value.mg() != compute_value<MidGame>())
- if (st->egValue != compute_value<EndGame>())
+ if (st->value.eg() != compute_value<EndGame>())
Key key, pawnKey, materialKey;
int castleRights, rule50, pliesFromNull;
Square epSquare;
Key key, pawnKey, materialKey;
int castleRights, rule50, pliesFromNull;
Square epSquare;
- Value mgValue, egValue;
Value npMaterial[2];
PieceType capture;
Value npMaterial[2];
PieceType capture;
Key get_material_key() const;
// Incremental evaluation
Key get_material_key() const;
// Incremental evaluation
- Value mg_value() const;
- Value eg_value() const;
Value non_pawn_material(Color c) const;
Phase game_phase() const;
template<GamePhase> Value pst_delta(Piece piece, Square from, Square to) const;
Value non_pawn_material(Color c) const;
Phase game_phase() const;
template<GamePhase> Value pst_delta(Piece piece, Square from, Square to) const;
: EgPieceSquareTable[piece][to] - EgPieceSquareTable[piece][from]);
}
: EgPieceSquareTable[piece][to] - EgPieceSquareTable[piece][from]);
}
-inline Value Position::mg_value() const {
- return st->mgValue;
-}
-
-inline Value Position::eg_value() const {
- return st->egValue;
+inline Score Position::value() const {
+ return st->value;
}
inline Value Position::non_pawn_material(Color c) const {
}
inline Value Position::non_pawn_material(Color c) const {
else if (token == "eval")
{
EvalInfo ei;
else if (token == "eval")
{
EvalInfo ei;
- cout << "Incremental mg: " << RootPosition.mg_value()
- << "\nIncremental eg: " << RootPosition.eg_value()
+ cout << "Incremental mg: " << RootPosition.value().mg()
+ << "\nIncremental eg: " << RootPosition.value().eg()
<< "\nFull eval: " << evaluate(RootPosition, ei, 0) << endl;
}
else if (token == "key")
<< "\nFull eval: " << evaluate(RootPosition, ei, 0) << endl;
}
else if (token == "key")