X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fevaluate.cpp;h=30b107ee9565c2254f93065cc5f76438f6f0a3e8;hb=83a574ff271ec5924976b48cf65ac62278f87558;hp=be53a73ee886633bc7775c3453856a50531e78e6;hpb=d3ffd0ffcad5e467fffd67d82d031fa1cbdba7d2;p=stockfish
diff --git a/src/evaluate.cpp b/src/evaluate.cpp
index be53a73e..30b107ee 100644
--- a/src/evaluate.cpp
+++ b/src/evaluate.cpp
@@ -17,10 +17,10 @@
along with this program. If not, see .
*/
+#include
#include
#include
#include
-#include
#include "bitcount.h"
#include "evaluate.h"
@@ -89,23 +89,15 @@ namespace {
std::string do_trace(const Position& pos);
}
- // Evaluation weights, initialized from UCI options
+ // Evaluation weights, indexed by evaluation term
enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem };
- struct Weight { int mg, eg; } Weights[6];
+ const struct Weight { int mg, eg; } Weights[] = {
+ {289, 344}, {233, 201}, {221, 273}, {46, 0}, {271, 0}, {307, 0}
+ };
typedef Value V;
#define S(mg, eg) make_score(mg, eg)
- // Internal evaluation weights. These are applied on top of the evaluation
- // weights read from UCI parameters. The purpose is to be able to change
- // the evaluation weights while keeping the default values of the UCI
- // parameters at 100, which looks prettier.
- //
- // Values modified by Joona Kiiski
- const Score WeightsInternal[] = {
- S(289, 344), S(233, 201), S(221, 273), S(46, 0), S(271, 0), S(307, 0)
- };
-
// MobilityBonus[PieceType][attacked] contains bonuses for middle and end
// game, indexed by piece type and number of attacked squares not occupied by
// friendly pieces.
@@ -169,7 +161,6 @@ namespace {
const Score RookSemiopenFile = make_score(19, 10);
const Score BishopPawns = make_score( 8, 12);
const Score MinorBehindPawn = make_score(16, 0);
- const Score UndefendedMinor = make_score(25, 10);
const Score TrappedRook = make_score(90, 0);
const Score Unstoppable = make_score( 0, 20);
@@ -214,17 +205,6 @@ namespace {
}
- // weight_option() computes the value of an evaluation weight, by combining
- // two UCI-configurable weights (midgame and endgame) with an internal weight.
-
- Weight weight_option(const std::string& mgOpt, const std::string& egOpt, Score internalWeight) {
-
- Weight w = { Options[mgOpt] * mg_value(internalWeight) / 100,
- Options[egOpt] * eg_value(internalWeight) / 100 };
- return w;
- }
-
-
// init_eval_info() initializes king bitboards for given color adding
// pawn attacks. To be done at the beginning of the evaluation.
@@ -520,16 +500,9 @@ namespace {
const Color Them = (Us == WHITE ? BLACK : WHITE);
- Bitboard b, undefendedMinors, weakEnemies;
+ Bitboard b, weakEnemies;
Score score = SCORE_ZERO;
- // Undefended minors get penalized even if they are not under attack
- undefendedMinors = pos.pieces(Them, BISHOP, KNIGHT)
- & ~ei.attackedBy[Them][ALL_PIECES];
-
- if (undefendedMinors)
- score += UndefendedMinor;
-
// Enemies not defended by a pawn and under our attack
weakEnemies = pos.pieces(Them)
& ~ei.attackedBy[Them][PAWN]
@@ -791,7 +764,7 @@ namespace {
Value v = mg_value(score) * int(ei.mi->game_phase())
+ eg_value(score) * int(PHASE_MIDGAME - ei.mi->game_phase()) * sf / SCALE_FACTOR_NORMAL;
- v /= PHASE_MIDGAME;
+ v /= int(PHASE_MIDGAME);
// In case of tracing add all single evaluation contributions for both white and black
if (Trace)
@@ -906,13 +879,6 @@ namespace Eval {
void init() {
- Weights[Mobility] = weight_option("Mobility (Midgame)", "Mobility (Endgame)", WeightsInternal[Mobility]);
- Weights[PawnStructure] = weight_option("Pawn Structure (Midgame)", "Pawn Structure (Endgame)", WeightsInternal[PawnStructure]);
- Weights[PassedPawns] = weight_option("Passed Pawns (Midgame)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]);
- Weights[Space] = weight_option("Space", "Space", WeightsInternal[Space]);
- Weights[KingDangerUs] = weight_option("Cowardice", "Cowardice", WeightsInternal[KingDangerUs]);
- Weights[KingDangerThem] = weight_option("Aggressiveness", "Aggressiveness", WeightsInternal[KingDangerThem]);
-
const double MaxSlope = 30;
const double Peak = 1280;