mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-17 15:46:24 +08:00
Define Score as an enum
Increases performance because now we use one integer for both midgame and endgame scores. Unfortunatly the latest patches seem to have reduced a bit the speed so at the end we are more or less at the same performance level of the beginning. But this patch series introduced also some code cleanup so it is the main reason we commit anyway. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -894,7 +894,7 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) {
|
||||
|
||||
// Finish
|
||||
sideToMove = opposite_color(sideToMove);
|
||||
st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
|
||||
st->value += (sideToMove == WHITE ? TempoValue : -TempoValue);
|
||||
|
||||
assert(is_ok());
|
||||
}
|
||||
@@ -1054,7 +1054,7 @@ void Position::do_castle_move(Move m) {
|
||||
|
||||
// Finish
|
||||
sideToMove = opposite_color(sideToMove);
|
||||
st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
|
||||
st->value += (sideToMove == WHITE ? TempoValue : -TempoValue);
|
||||
|
||||
assert(is_ok());
|
||||
}
|
||||
@@ -1631,7 +1631,7 @@ Key Position::compute_material_key() const {
|
||||
/// updated by do_move and undo_move when the program is running in debug mode.
|
||||
Score Position::compute_value() const {
|
||||
|
||||
Score result(0, 0);
|
||||
Score result = make_score(0, 0);
|
||||
Bitboard b;
|
||||
Square s;
|
||||
|
||||
@@ -1647,7 +1647,7 @@ Score Position::compute_value() const {
|
||||
}
|
||||
}
|
||||
|
||||
result += (side_to_move() == WHITE)? TempoValue / 2 : -TempoValue / 2;
|
||||
result += (side_to_move() == WHITE ? TempoValue / 2 : -TempoValue / 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1796,7 +1796,7 @@ void Position::init_piece_square_tables() {
|
||||
for (Piece p = WP; p <= WK; p++)
|
||||
{
|
||||
i = (r == 0)? 0 : (genrand_int32() % (r*2) - r);
|
||||
PieceSquareTable[p][s] = Score(MgPST[p][s] + i, EgPST[p][s] + i);
|
||||
PieceSquareTable[p][s] = make_score(MgPST[p][s] + i, EgPST[p][s] + i);
|
||||
}
|
||||
|
||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||
|
||||
Reference in New Issue
Block a user