mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 02:27:00 +08:00
Use type aliases instead of enums for Value types
The primary rationale behind this lies in the fact that enums were not originally designed to be employed in the manner we currently utilize them. The Value enum was used like a type alias throughout the code and was often misused. Furthermore, changing the underlying size of the enum to int16_t broke everything, mostly because of the operator overloads for the Value enum, were causing data to be truncated. Since Value is now a type alias, the operator overloads are no longer required. Passed Non-Regression STC: https://tests.stockfishchess.org/tests/view/6593b8bb79aa8af82b95b401 LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 235296 W: 59919 L: 59917 D: 115460 Ptnml(0-2): 743, 27085, 62054, 26959, 807 closes https://github.com/official-stockfish/Stockfish/pull/4960 No functional change
This commit is contained in:
@@ -148,7 +148,7 @@ void NNUE::verify() {
|
||||
// Returns a static, purely materialistic evaluation of the position from
|
||||
// the point of view of the given color. It can be divided by PawnValue to get
|
||||
// an approximation of the material advantage on the board in terms of pawns.
|
||||
Value Eval::simple_eval(const Position& pos, Color c) {
|
||||
int Eval::simple_eval(const Position& pos, Color c) {
|
||||
return PawnValue * (pos.count<PAWN>(c) - pos.count<PAWN>(~c))
|
||||
+ (pos.non_pawn_material(c) - pos.non_pawn_material(~c));
|
||||
}
|
||||
@@ -160,7 +160,7 @@ Value Eval::evaluate(const Position& pos) {
|
||||
|
||||
assert(!pos.checkers());
|
||||
|
||||
Value v;
|
||||
int v;
|
||||
Color stm = pos.side_to_move();
|
||||
int shuffling = pos.rule50_count();
|
||||
int simpleEval = simple_eval(pos, stm) + (int(pos.key() & 7) - 3);
|
||||
@@ -170,13 +170,13 @@ Value Eval::evaluate(const Position& pos) {
|
||||
+ std::abs(pos.this_thread()->rootSimpleEval);
|
||||
|
||||
if (lazy)
|
||||
v = Value(simpleEval);
|
||||
v = simpleEval;
|
||||
else
|
||||
{
|
||||
int nnueComplexity;
|
||||
Value nnue = NNUE::evaluate(pos, true, &nnueComplexity);
|
||||
|
||||
Value optimism = pos.this_thread()->optimism[stm];
|
||||
int optimism = pos.this_thread()->optimism[stm];
|
||||
|
||||
// Blend optimism and eval with nnue complexity and material imbalance
|
||||
optimism += optimism * (nnueComplexity + std::abs(simpleEval - nnue)) / 512;
|
||||
@@ -190,7 +190,7 @@ Value Eval::evaluate(const Position& pos) {
|
||||
v = v * (200 - shuffling) / 214;
|
||||
|
||||
// Guarantee evaluation does not hit the tablebase range
|
||||
v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
|
||||
v = std::clamp(int(v), VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user