Cleanup history stats

And other assorted trivia.

No functional change.
This commit is contained in:
Marco Costalba
2015-10-24 07:27:24 +02:00
parent 55758344d3
commit 307a5a4f63
8 changed files with 114 additions and 112 deletions

View File

@@ -171,8 +171,8 @@ namespace {
// PassedFile[File] contains a bonus according to the file of a passed pawn.
const Score PassedFile[] = {
S( 12, 10), S( 3, 10), S( 1, -8), S(-27, -12),
S(-27, -12), S( 1, -8), S( 3, 10), S( 12, 10)
S( 12, 10), S( 3, 10), S( 1, -8), S(-27, -12),
S(-27, -12), S( 1, -8), S( 3, 10), S( 12, 10)
};
const Score ThreatenedByHangingPawn = S(40, 60);
@@ -677,20 +677,18 @@ namespace {
// evaluate_initiative() computes the initiative correction value for the
// position, i.e. second order bonus/malus based on the known attacking/defending
// status of the players.
Score evaluate_initiative(const Position& pos, const EvalInfo& ei, const Score positional_score) {
Score evaluate_initiative(const Position& pos, int asymmetry, Value eg) {
int king_separation = distance<File>(pos.square<KING>(WHITE), pos.square<KING>(BLACK));
int pawns = pos.count<PAWN>(WHITE) + pos.count<PAWN>(BLACK);
int asymmetry = ei.pi->pawn_asymmetry();
int kingDistance = distance<File>(pos.square<KING>(WHITE), pos.square<KING>(BLACK));
int pawns = pos.count<PAWN>(WHITE) + pos.count<PAWN>(BLACK);
// Compute the initiative bonus for the attacking side
int attacker_bonus = 8 * (pawns + asymmetry + king_separation) - 120;
int initiative = 8 * (pawns + asymmetry + kingDistance - 15);
// Now apply the bonus: note that we find the attacking side by extracting the sign
// of the endgame value of "positional_score", and that we carefully cap the bonus so
// that the endgame score with the correction will never be divided by more than two.
int eg = eg_value(positional_score);
int value = ((eg > 0) - (eg < 0)) * std::max(attacker_bonus, -abs(eg / 2));
// Now apply the bonus: note that we find the attacking side by extracting
// the sign of the endgame value, and that we carefully cap the bonus so
// that the endgame score will never be divided by more than two.
int value = ((eg > 0) - (eg < 0)) * std::max(initiative, -abs(eg / 2));
return make_score(0, value);
}
@@ -777,8 +775,8 @@ Value Eval::evaluate(const Position& pos) {
if (pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) >= 12222)
score += (evaluate_space<WHITE>(pos, ei) - evaluate_space<BLACK>(pos, ei)) * Weights[Space];
// Evaluate initiative
score += evaluate_initiative(pos, ei, score);
// Evaluate position potential for the winning side
score += evaluate_initiative(pos, ei.pi->pawn_asymmetry(), eg_value(score));
// Scale winning side if position is more drawish than it appears
Color strongSide = eg_value(score) > VALUE_DRAW ? WHITE : BLACK;