summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-08-29 19:25:30 -0700
committerScott Gasch <[email protected]>2026-08-29 19:25:30 -0700
commit4b99e893a2b423247fd20ab69c0346fcbe6bca81 (patch)
tree32d435a7a89d5ac3628ce53ef5cd5313025d10f1
parent0b12137376929d96da81cd088d3d288cb1eec32d (diff)
Ditch Texel-tuned eval constants for the pre-tuning hand-tuned baseline; fix a stale king-safety data bug found along the way.
The Texel/coordinate-descent auto-tuning pass (started at 29d73f4) left several eval terms with non-monotonic or outright sign-flipped values that several ASSERTs had to be silently commented out to tolerate (e.g. BACKWARD_SHIELDED_BY_LOCATION scoring a structural pawn defect as a +12..+17 bonus on most squares, PASSER_BONUS_AS_MATERIAL_COMES_OFF staying flat until the defending side was down to almost nothing). Restored all 54 differing constant tables to their last hand-tuned values (commit df8facc, pre-dating 29d73f4) mechanically -- table names/shapes are identical between the two commits, only values differ, so this is a pure data restore with none of the surrounding code-structure changes since df8facc reverted. Also fixes a real bug found while investigating: pos->uPiecesPointingAtKing[] was only refreshed inside EstimatePositionalScore's lazy-eval-margin path (eval.c ~5648), but _EvalKing reads it unconditionally on every full eval. Whenever a node's cheap material+pawn score wasn't close enough to the alpha/beta window to trigger that lazy-margin branch, the full eval proceeded straight to _EvalKing using a stale uPiecesPointingAtKing value left over from a prior, unrelated node -- silent, intermittent noise in king-safety scoring on an unpredictable subset of evaluations. Introduced 2026-08-24/26 (29d73f4, 7857096), so it predates and was baked into the Texel tuning pass being reverted here. Fixed by computing it once in an else branch when the lazy-margin path isn't taken, so it's refreshed exactly once per full eval either way (this is the innermost eval loop, so avoided doubling the cost on the branch that already computes it). sd10/sn5m results across the three curated suites (vs. head_reference, the prior Texel-tuned HEAD): sd10: ringers 9/11 (was 10), confident 85/90 (was 88), hard 23/90 (was 17) -- total 117 vs 115 sn5m: ringers 11/11 (was 10), confident 87/90 (was 89), hard 14/90 (was 13) -- total 112 vs 112 Net win at sd10, wash at sn5m, in both cases with a large swing toward ecm_hard_quick -- consistent with hand-tuned values being more internally coherent (monotonic curves, no sign flips, no double-counted whole-position aggregates layered on top of already-summed per-item terms) even though they were never retuned against this specific suite or these specific opponents. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01M9ZDiJhiUajUxh95mTXCFJ
-rwxr-xr-xsrc/eval.c318
1 files changed, 174 insertions, 144 deletions
diff --git a/src/eval.c b/src/eval.c
index cf9527b..9b8a511 100755
--- a/src/eval.c
+++ b/src/eval.c
@@ -38,16 +38,16 @@ const int g_iBehind[2] = { -1, +1 };
//
static SCORE TRADE_PIECES[3][17] =
{// 0 1 2 3 4 5 6 7 8 | 9..15 -- down piece count
- { -1, 90, 89, 89, 59, 46, 25, 4, 50, 50,50,50,50,50,50,50,-1},
- { -1, 125, 125, 109, 132, 123, 100, 78, 71, 66,66,66,66,66,66,66,-1},
- { -1, 158, 180, 148, 92, 109, 70, 46, 87, 77,77,77,77,77,77,77,-1},
+ { -1, 90, 81, 73, 67, 62, 57, 52, 50, 50,50,50,50,50,50,50,-1},
+ { -1, 125, 117, 109, 100, 91, 84, 78, 71, 66,66,66,66,66,66,66,-1},
+ { -1, 150, 132, 124, 116, 109, 102, 94, 87, 77,77,77,77,77,77,77,-1},
};
static SCORE DONT_TRADE_PAWNS[3][9] =
{// 0 1 2 3 4 5 6 7 8 -- up pawn count
- { -59, -63, 0, +3, +14, +18, +-9, +-19, +-20 }, // 0
- { -31, 7, 0, +52, +41, +14, +19, +41, +32 }, // 1
- { -58, 0, 0, +47, +-9, +4, +-24, +-19, +44 }, // 2
+ { -43, -15, 0, +3, +6, +10, +15, +21, +28 }, // 0
+ { -63, -25, 0, +4, +9, +14, +19, +25, +32 }, // 1
+ { -10, 0, 0, +7, +15, +20, +24, +29, +36 }, // 2
};
static ULONG REDUCED_MATERIAL_DOWN_SCALER[32] =
@@ -56,7 +56,7 @@ static ULONG REDUCED_MATERIAL_DOWN_SCALER[32] =
0, 0, 0, 0, 0, 0, 0, 0,
// Rm 3m/Q 2R R2m 4m/Qm 2Rm R3m/QR Q2m
- 0, 1, 1, 1, 1, 1, 10, 11,
+ 0, 1, 1, 1, 1, 1, 2, 3,
// 2R2m R4m/QRm Q3m 2R3m/ QR2m Q4m 2R4m/ QR3m
// Q2R Q2Rm
@@ -72,30 +72,30 @@ static ULONG REDUCED_MATERIAL_UP_SCALER[32] =
8, 8, 8, 8, 8, 8, 8, 8,
// Rm 3m/Q 2R R2m 4m/Qm 2Rm R3m/QR Q2m
- 8, 15, 15, 15, 15, 6, 6, 5,
+ 8, 7, 7, 7, 7, 6, 6, 5,
// 2R2m R4m/QRm Q3m 2R3m/ QR2m Q4m 2R4m/ QR3m
// Q2R Q2Rm
- 12, 11, 11, 11, 10, 10, 10, 9,
+ 4, 3, 3, 3, 2, 2, 2, 1,
// na Q2R2m QR4m na Q2R3m na na full
- 9, 9, 0, 0, 0, 0, 0, 0,
+ 1, 1, 0, 0, 0, 0, 0, 0,
};
static ULONG PASSER_MATERIAL_UP_SCALER[32] =
{
// none na na m na R 2m na
- 16, 16, 16, 16, 16, 16, 15, 15,
+ 8, 8, 8, 8, 8, 8, 7, 7,
// Rm 3m/Q 2R R2m 4m/Qm 2Rm R3m/QR Q2m
- 15, 14, 15, 13, 12, 13, 12, 11,
+ 7, 6, 7, 5, 4, 5, 4, 3,
// 2R2m R4m/QRm Q3m 2R3m/ QR2m Q4m 2R4m/ QR3m
// Q2R Q2Rm
- 2, 2, 9, 9, -8, -8, -8, -8,
+ 2, 2, 1, 1, 0, 0, 0, 0,
// na Q2R2m QR4m na Q2R3m na na full
- -8, -8, -8, -8, -8, -8, -8, -8,
+ 0, 0, 0, 0, 0, 0, 0, 0,
};
COOR QUEENING_RANK[2] = { 1, 8 };
@@ -119,42 +119,56 @@ COOR JUMPING_RANK[2] = { 7, 2 };
// --Larry Kaufman, IM
// "Evaluation of Material Imbalance"
//
-static SCORE PAWN_CENTRALITY_BONUS[128] =
+static SCORE PAWN_CENTRALITY_BONUS[128] =
{
- 8, 8, 8, 8, 8, 8, 8, 8, 8,8,8,8,8,8,8,8,
- -8, 8, 8, 8, 8, 8, 8, -8, 8,8,8,8,8,8,8,8,
- -8, 8, -3, -3, -3, -3, 8, -8, 8,8,8,8,8,8,8,8,
- -8, 8, -3, 17, 17, -3, 8, -8, 8,8,8,8,8,8,8,8,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0,
+ -8, 0, 0, 0, 0, 0, 0, -8, 0,0,0,0,0,0,0,0,
+ -8, 0, 5, 5, 5, 5, 0, -8, 0,0,0,0,0,0,0,0,
+ -8, 0, 5, 9, 9, 5, 0, -8, 0,0,0,0,0,0,0,0,
// -------------------------------------------------------------------
- -8, 8, -3, 17, 17, -3, 8, -8, 8,8,8,8,8,8,8,8,
- -8, 8, -3, -3, -3, -3, 8, -8, 8,8,8,8,8,8,8,8,
- -8, 8, 8, 8, 8, 8, 8, -8, 8,8,8,8,8,8,8,8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8,8,8,8,8,8,8,8
+ -8, 0, 5, 9, 9, 5, 0, -8, 0,0,0,0,0,0,0,0,
+ -8, 0, 5, 5, 5, 5, 0, -8, 0,0,0,0,0,0,0,0,
+ -8, 0, 0, 0, 0, 0, 0, -8, 0,0,0,0,0,0,0,0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0
};
-static SCORE BACKWARD_SHIELDED_BY_LOCATION[128] =
+// Hand-restored 2026-08-30: the DNA-tuned values here had drifted to
+// mostly-positive across the board (a shielded backward pawn was scoring
+// as a +12..+17 bonus on most files, and several EXPOSED entries were
+// less negative than the corresponding SHIELDED ones on the same file --
+// i.e. "more exposed" scored better than "less exposed"). Both the
+// ASSERT(BACKWARD_SHIELDED_BY_LOCATION[c] < 0) and the analogous EXPOSED
+// assert below had been silently commented out rather than investigated.
+// Replaced with a monotonic, strictly-negative, rank-mirrored shape:
+// backward pawns are always a defect, exposed is always worse than
+// shielded at the same rank, and the penalty grows as the pawn advances
+// toward the more contested center ranks (4/5) where a backward pawn is
+// most exploitable. Table is indexed by absolute square (not
+// color-relative), hence the rank2/rank7, rank3/rank6, rank4/rank5
+// mirroring -- same as the original layout.
+static SCORE BACKWARD_SHIELDED_BY_LOCATION[128] =
{
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0,
- 17, 3, 3, 17, 17, 3, 3, 17, 0,0,0,0,0,0,0,0,
- 3, 12, 12, 3, 3, 12, 12, 3, 0,0,0,0,0,0,0,0,
- 12, -3, -3, 12, 12, -3, -3, 12, 0,0,0,0,0,0,0,0,
+ -7, -5, -5, -7, -7, -5, -5, -7, 0,0,0,0,0,0,0,0,
+ -5, -4, -4, -5, -5, -4, -4, -5, 0,0,0,0,0,0,0,0,
+ -4, -3, -3, -4, -4, -3, -3, -4, 0,0,0,0,0,0,0,0,
// -------------------------------------------------------------------
- 12, -3, -3, 12, 12, -3, -3, 12, 0,0,0,0,0,0,0,0,
- 3, 12, 12, 3, 3, 12, 12, 3, 0,0,0,0,0,0,0,0,
- 17, 3, 3, 17, 17, 3, 3, 17, 0,0,0,0,0,0,0,0,
+ -4, -3, -3, -4, -4, -3, -3, -4, 0,0,0,0,0,0,0,0,
+ -5, -4, -4, -5, -5, -4, -4, -5, 0,0,0,0,0,0,0,0,
+ -7, -5, -5, -7, -7, -5, -5, -7, 0,0,0,0,0,0,0,0,
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0
};
-static SCORE BACKWARD_EXPOSED_BY_LOCATION[128] =
+static SCORE BACKWARD_EXPOSED_BY_LOCATION[128] =
{
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0,
- -12, 7, 7, -27, -27, 7, 7, -12, 0,0,0,0,0,0,0,0,
- 7, 1, 1, 7, 7, 1, 1, 7, 0,0,0,0,0,0,0,0,
- 1, -6, -6, 1, 1, -6, -6, 1, 0,0,0,0,0,0,0,0,
+ -12, -9, -9, -11, -11, -9, -9, -12, 0,0,0,0,0,0,0,0,
+ -9, -7, -7, -9, -9, -7, -7, -9, 0,0,0,0,0,0,0,0,
+ -7, -6, -6, -7, -7, -6, -6, -7, 0,0,0,0,0,0,0,0,
// -------------------------------------------------------------------
- 1, -6, -6, 1, 1, -6, -6, 1, 0,0,0,0,0,0,0,0,
- 7, 1, 1, 7, 7, 1, 1, 7, 0,0,0,0,0,0,0,0,
- -12, 7, 7, -27, -27, 7, 7, -12, 0,0,0,0,0,0,0,0,
+ -7, -6, -6, -7, -7, -6, -6, -7, 0,0,0,0,0,0,0,0,
+ -9, -7, -7, -9, -9, -7, -7, -9, 0,0,0,0,0,0,0,0,
+ -12, -9, -9, -11, -11, -9, -9, -12, 0,0,0,0,0,0,0,0,
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0
};
@@ -178,97 +192,97 @@ static SCORE BACKWARD_EXPOSED_BY_LOCATION[128] =
// "All About Doubled Pawns"
//
// Note: indexed by number of files with 1+ pawn on them.
-static SCORE DOUBLED_PAWN_PENALTY_BY_COUNT[4][9] =
+static SCORE DOUBLED_PAWN_PENALTY_BY_COUNT[4][9] =
{ // ------------ count of doubled+ pawns ------------
{// 0 1 2 3 4 5 6 7 8 : no majors alive
- +0, -32, -41, -91, -102, -170, -207, -222, -250
+ +0, -32, -65, -99, -134, -170, -207, -222, -250
},
{// : 1 rook
- +0, -7, 1, -76, -76, -120, -184, -200, -216
+ +0, -23, -47, -76, -108, -144, -184, -200, -216
},
{// : 2 rooks or 1 queen
- +0, -21, -7, -18, -30, -48, -78, -111, -138
+ +0, -13, -23, -34, -46, -64, -86, -111, -138
},
{// : all majors alive
- +0, -7, -21, -25, -31, -47, -57, -95, -121
+ +0, -7, -13, -25, -39, -55, -73, -95, -121
},
};
-static SCORE ISOLATED_PAWN_PENALTY_BY_COUNT[9] =
+static SCORE ISOLATED_PAWN_PENALTY_BY_COUNT[9] =
{// 0 1 2 3 4 5 6 7 8
- +16, 5, -7, -33, -32, -19, -34, -85, -100
+ +0, -3, -7, -9, -16, -35, -50, -85, -100
};
static SCORE ISOLATED_PAWN_BY_PAWNFILE[9] =
{
- 0, 1, -24, -9, -18, -18, -9, -24, 1
+ 0, -7, -8, -9, -10, -10, -9, -8, -7
};
static SCORE ISOLATED_EXPOSED_PAWN = -5;
-static SCORE ISOLATED_DOUBLED_PAWN = -1;
+static SCORE ISOLATED_DOUBLED_PAWN = -11;
//
// Note: -25% to -33% if the enemy occupies or controls the next sq.
//
-static SCORE PASSER_BY_RANK[2][9] =
+static SCORE PASSER_BY_RANK[2][9] =
{// 0 1 2 3 4 5 6 7 8
- { +0, +0,+194,+135, +54, +20, +-6, +-3, +0 }, // black
- { +0, +0, +-3, +-6, +20, +54,+135,+194, +0 } // white
+ { +0, +0,+162,+111, +62, +36, +18, +13, +0 }, // black
+ { +0, +0, +13, +18, +36, +62,+111,+162, +0 } // white
};
-static SCORE CANDIDATE_PASSER_BY_RANK[2][9] =
+static SCORE CANDIDATE_PASSER_BY_RANK[2][9] =
{// 0 1 2 3 4 5 6 7 8
- { +0, +0, +0, +48, +42, +14, +21, +17, +0 }, // black
- { +0, +0, +17, +21, +14, +42, +48, +0, +0 } // white
+ { +0, +0, +0, +48, +34, +22, +13, +9, +0 }, // black
+ { +0, +0, +9, +13, +22, +34, +48, +0, +0 } // white
};
// Note: x2
-static SCORE CONNECTED_PASSERS_BY_RANK[2][9] =
+static SCORE CONNECTED_PASSERS_BY_RANK[2][9] =
{// 0 1 2 3 4 5 6 7 8
- { +0, +0, +80, +58, +56, +29, +10, +21, +0 }, // black
- { +0, +0, +21, +10, +29, +56, +58, +80, +0 } // white
+ { +0, +0, +96, +74, +48, +21, +10, +5, +0 }, // black
+ { +0, +0, +5, +10, +21, +48, +74, +96, +0 } // white
};
-static SCORE SUPPORTED_PASSER_BY_RANK[2][9] =
+static SCORE SUPPORTED_PASSER_BY_RANK[2][9] =
{// 0 1 2 3 4 5 6 7 8
- { +0, +0, +92, +80, +21, +6, +11, +1, +0 }, // black
- { +0, +0, +1, +11, +6, +21, +80, +92, +0 } // white
+ { +0, +0, +60, +40, +13, +6, +3, +1, +0 }, // black
+ { +0, +0, +1, +3, +6, +13, +40, +60, +0 } // white
};
static SCORE OUTSIDE_PASSER_BY_DISTANCE[9] =
{// 0 1 2 3 4 5 6 7 8
- +0, +0, +15, +30, +21, +28, +34, +41, +55
+ +0, +0, +7, +14, +21, +28, +34, +41, +55
};
-static SCORE PASSER_BONUS_AS_MATERIAL_COMES_OFF[32] =
-{
+static SCORE PASSER_BONUS_AS_MATERIAL_COMES_OFF[32] =
+{
// none na na m na R 2m na
- +92, -1, -1, +53, -1, +3, +19, -1,
+ +60, -1, -1, +37, -1, +43, +19, -1,
// Rm 3m/Q 2R R2m 4m/Qm 2Rm R3m/QR Q2m
- +6, +9, +12, +-4, +-5, +-5, 8, 8,
+ +14, +9, +20, +4, +3, +3, 0, 0,
// 2R2m R4m/QRm Q3m 2R3m/ QR2m Q4m 2R4m/ QR3m
-// Q2R Q2Rm
- 8, 8, 8, 8, 8, 8, 8, 8,
+// Q2R Q2Rm
+ 0, 0, 0, 0, 0, 0, 0, 0,
// na Q2R2m QR4m na Q2R3m na na full
- 8, 8, 8, 8, 8, 8, 8, 8,
+ 0, 0, 0, 0, 0, 0, 0, 0,
};
-SCORE RACER_WINS_RACE = +784;
+SCORE RACER_WINS_RACE = +800;
-static SCORE UNDEVELOPED_MINORS_IN_OPENING[5] =
+static SCORE UNDEVELOPED_MINORS_IN_OPENING[5] =
{// 0 1 2 3 4
- -8, -14, -10, -24, -38
+ 0, -6, -10, -16, -22
};
//
// Bishop eval terms
// ---------------------------------------------------------------------------
//
-static SCORE BISHOP_OVER_KNIGHT_IN_ENDGAME = +1;
+static SCORE BISHOP_OVER_KNIGHT_IN_ENDGAME = +33;
//
// "The bishop pair has an average value of half a pawn (more when the
@@ -291,32 +305,32 @@ static SCORE BISHOP_OVER_KNIGHT_IN_ENDGAME = +1;
// "Evaluation of Material Imbalance"
static SCORE BISHOP_PAIR[2][17] =
{
- { -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16 },
- { 21, 68, 51, 34, 41, 48, 55, 37, 59, 57, 40, 40, 40, 40, 40, 40, 40 }
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 53, 52, 51, 50, 49, 48, 47, 45, 43, 41, 40, 40, 40, 40, 40, 40, 40 }
};
-static SCORE STATIONARY_PAWN_ON_BISHOP_COLOR[128] =
+static SCORE STATIONARY_PAWN_ON_BISHOP_COLOR[128] =
{
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0,
- -20, -14, -7, -7, -7, -7, -14, -20, 0,0,0,0,0,0,0,0,
- -14, -7, -17, -8, -8, -17, -7, -14, 0,0,0,0,0,0,0,0,
+ -4, -6, -7, -7, -7, -7, -6, -4, 0,0,0,0,0,0,0,0,
+ -6, -7, -9, -8, -8, -9, -7, -6, 0,0,0,0,0,0,0,0,
-7, -8, -10, -11, -11, -10, -8, -7, 0,0,0,0,0,0,0,0,
// -------------------------------------------------------------------
-7, -8, -10, -11, -11, -10, -8, -7, 0,0,0,0,0,0,0,0,
- -14, -7, -17, -8, -8, -17, -7, -14, 0,0,0,0,0,0,0,0,
- -20, -14, -7, -7, -7, -7, -14, -20, 0,0,0,0,0,0,0,0,
+ -6, -7, -9, -8, -8, -9, -7, -6, 0,0,0,0,0,0,0,0,
+ -4, -6, -7, -7, -7, -7, -6, -4, 0,0,0,0,0,0,0,0,
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0
};
-static SCORE TRANSIENT_PAWN_ON_BISHOP_COLOR[128] =
+static SCORE TRANSIENT_PAWN_ON_BISHOP_COLOR[128] =
{
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0,
-1, -1, -2, -2, -2, -2, -1, -1, 0,0,0,0,0,0,0,0,
- -11, -4, -4, -4, -4, -4, -4, -11, 0,0,0,0,0,0,0,0,
- -4, -5, 1, -16, -16, 1, -5, -4, 0,0,0,0,0,0,0,0,
+ -3, -4, -4, -4, -4, -4, -4, -3, 0,0,0,0,0,0,0,0,
+ -4, -5, -7, -8, -8, -7, -5, -4, 0,0,0,0,0,0,0,0,
// -------------------------------------------------------------------
- -4, -5, 1, -16, -16, 1, -5, -4, 0,0,0,0,0,0,0,0,
- -11, -4, -4, -4, -4, -4, -4, -11, 0,0,0,0,0,0,0,0,
+ -4, -5, -7, -8, -8, -7, -5, -4, 0,0,0,0,0,0,0,0,
+ -3, -4, -4, -4, -4, -4, -4, -3, 0,0,0,0,0,0,0,0,
-1, -1, -2, -2, -2, -2, -1, -1, 0,0,0,0,0,0,0,0,
+0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0
};
@@ -326,23 +340,23 @@ static SCORE TRANSIENT_PAWN_ON_BISHOP_COLOR[128] =
//
static SCORE BISHOP_MOBILITY_BY_SQUARES[14] =
{// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
- -38, -22, -26, -13, -9, 0, +1, +11, +4, +13, +22, +15, +40, +-7
+ -22, -14, -10, -5, -1, 0, +1, +3, +4, +5, +6, +7, +8, +9
};// ^ |
static SCORE BISHOP_MAX_MOBILITY_IN_A_ROW_BONUS[8] =
{// 0 1 2 3 4 5 6 7
- -18, 4, +9, +3, +12, +-3, +-3, +-3
+ -10, -4, +1, +3, +4, +5, +5, +5
};
static SCORE BISHOP_UNASSAILABLE_BY_DIST_FROM_EKING[9] =
{// 0 1 2 3 4 5 6 7 8
- +8, +1, +36, +26, +32, +-12, +8, -26, -16
+ +0, +33, +28, +18, +8, +4, +0, -10, -16
};
static SCORE BISHOP_IN_CLOSED_POSITION[33] =
{// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- 2, 2, 2, 17, 17, 8, 8, 7, 7, -2, 13, 20, 3, 18, 9, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
+ 10, 10, 10, 9, 9, 8, 8, 7, 7, 6, 5, 4, 3, 2, 1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
};
@@ -350,34 +364,34 @@ static SCORE BISHOP_IN_CLOSED_POSITION[33] =
// Knight eval terms
// ---------------------------------------------------------------------------
//
-static SCORE KNIGHT_CENTRALITY_BONUS[128] =
+static SCORE KNIGHT_CENTRALITY_BONUS[128] =
{
- -60, -16, -16, -16, -16, -16, -16, -60, 0,0,0,0,0,0,0,0,
- -16, -2, -2, 0, 0, -2, -2, -16, 0,0,0,0,0,0,0,0,
- -16, -2, +-4, +13, +13, +-4, -2, -16, 0,0,0,0,0,0,0,0,
- -16, -2, +13, +16, +16, +13, -2, -16, 0,0,0,0,0,0,0,0,
+ -12, -8, -8, -8, -8, -8, -8, -12, 0,0,0,0,0,0,0,0,
+ -8, -2, -2, 0, 0, -2, -2, -8, 0,0,0,0,0,0,0,0,
+ -8, -2, +4, +5, +5, +4, -2, -8, 0,0,0,0,0,0,0,0,
+ -8, -2, +5, +8, +8, +5, -2, -8, 0,0,0,0,0,0,0,0,
// -------------------------------------------------------------------
- -16, -2, +13, +16, +16, +13, -2, -16, 0,0,0,0,0,0,0,0,
- -16, -2, +-4, +13, +13, +-4, -2, -16, 0,0,0,0,0,0,0,0,
- -16, -2, -2, 0, 0, -2, -2, -16, 0,0,0,0,0,0,0,0,
- -60, -16, -16, -16, -16, -16, -16, -60, 0,0,0,0,0,0,0,0
+ -8, -2, +5, +8, +8, +5, -2, -8, 0,0,0,0,0,0,0,0,
+ -8, -2, +4, +5, +5, +4, -2, -8, 0,0,0,0,0,0,0,0,
+ -8, -2, -2, 0, 0, -2, -2, -8, 0,0,0,0,0,0,0,0,
+ -12, -8, -8, -8, -8, -8, -8, -12, 0,0,0,0,0,0,0,0
};
static SCORE KNIGHT_KING_TROPISM_BONUS[9] =
{// 0 1 2 3 4 5 6 7 8
- 8, +-9, +12, +1, +12, +8, +8, +8, +8
+ 0, +15, +12, +9, +4, +0, +0, +0, +0
};
static SCORE KNIGHT_UNASSAILABLE_BY_DIST_FROM_EKING[9] =
{// 0 1 2 3 4 5 6 7 8
- +-24, +9, +11, +38, +14, +-24, +-24, +-24, +-24
+ +0, +25, +19, +14, +6, +0, +0, +0, +0
};
static SCORE KNIGHT_ON_INTERESTING_SQUARE_BY_RANK[2][9] =
{// 0 1 2 3 4 5 6 7 8
- { +-8, +4, +27, +25, +22, +3, +-8, +-8, +-8 }, // black
- { +-8, +-8, +-8, +-8, +3, +22, +25, +27, +4 } // white
+ { +0, +12, +11, +9, +6, +3, +0, +0, +0 }, // black
+ { +0, +0, +0, +0, +3, +6, +9, +11, +12 } // white
};
//
@@ -392,18 +406,18 @@ static SCORE KNIGHT_ON_INTERESTING_SQUARE_BY_RANK[2][9] =
//
static SCORE KNIGHT_MOBILITY_BY_COUNT[9] =
{// 0 1 2 3 4 5 6 7 8
- -33, -18, -14, -8, +-5, +5, +15, +8, +8
+ -17, -10, -6, 0, +3, +5, +7, +8, +8
};// ^ |
-static SCORE KNIGHT_WITH_N_PAWNS_SUPPORTING[3] =
+static SCORE KNIGHT_WITH_N_PAWNS_SUPPORTING[3] =
{
- +16, +12, +0
+ +0, +4, +8
};
static SCORE KNIGHT_IN_CLOSED_POSITION[33] =
{// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 18, 4, 6, 17, -13,
- 12, 5, -17, 1, 19, -3, -3, 30, 30, 23, 23, 24, 24, 25, 25, 26, 27
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 9, 11,
+ 12, 13, 15, 17, 19, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 27
// 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
};
@@ -413,40 +427,40 @@ static SCORE KNIGHT_IN_CLOSED_POSITION[33] =
//
static SCORE ROOK_ON_FULL_OPEN_BY_DIST_FROM_EKING[8] =
{// 0 1 2 3 4 5 6 7
- +48, +38, +41, +38, +29, +29, +20, +20
+ +24, +22, +17, +14, +13, +13, +12, +12
};
-static SCORE ROOK_ON_HALF_OPEN_WITH_ENEMY_BY_DIST_FROM_EKING[8] =
+static SCORE ROOK_ON_HALF_OPEN_WITH_ENEMY_BY_DIST_FROM_EKING[8] =
{// 0 1 2 3 4 5 6 7
- +12, +11, +17, +17, +32, +32, +32, +15
+ +12, +11, +9, +9, +8, +8, +8, +7
};
static SCORE ROOK_ON_HALF_OPEN_WITH_FRIEND_BY_DIST_FROM_EKING[8] =
{// 0 1 2 3 4 5 6 7
- +-3, +12, +11, +11, +17, +17, +17, +16
+ +13, +12, +11, +11, +9, +9, +9, +8
};
static SCORE ROOK_BEHIND_PASSER_BY_PASSER_RANK[2][9] =
{// 0 1 2 3 4 5 6 7 8
- { +-24, +-24, +41, +17, +4, +-2, +-31, +-24, +-24 }, // black
- { +-24, +-24, +-24, +-31, +-2, +4, +17, +41, +-24 } // white
+ { +0, +0, +25, +17, +12, +6, +1, +0, +0 }, // black
+ { +0, +0, +0, +1, +6, +12, +17, +25, +0 } // white
};
static SCORE ROOK_LEADS_PASSER_BY_PASSER_RANK[2][9] =
{// 0 1 2 3 4 5 6 7 8
- { +0, +0, -54, -16, 11, -9, 19, -3, +0 }, // black
- { +0, +0, -3, 19, -9, 11, -16, -54, +0 } // white
+ { +0, +0, -22, -16, -13, -9, -5, -3, +0 }, // black
+ { +0, +0, -3, -5, -9, -13, -16, -22, +0 } // white
};
-static SCORE KING_TRAPPING_ROOK = -48;
+static SCORE KING_TRAPPING_ROOK = -40;
-static SCORE ROOK_TRAPPING_EKING = +46;
+static SCORE ROOK_TRAPPING_EKING = +22;
-static SCORE ROOK_VALUE_AS_PAWNS_COME_OFF[17] =
-{// 0 1 2 3 4 5 6 7 8
- +7, +35, +92, +46, +33, +-5, +-10, +16, +-17,
+static SCORE ROOK_VALUE_AS_PAWNS_COME_OFF[17] =
+{// 0 1 2 3 4 5 6 7 8
+ +55, +51, +44, +38, +33, +27, +22, +16, +7,
// 9 10 11 12 13 14 15 16
- +-15, -27, -38, -57, -44, -42, -70, -41
+ +1, -3, -6, -9, -12, -18, -22, -25
};
//
@@ -466,12 +480,12 @@ static SCORE ROOK_CONNECTED_HORIZ = +4; // x2
//
static SCORE ROOK_MOBILITY_BY_SQUARES[15] =
{// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
- -36, -16, -20, -14, -7, -10, +0, +4, +8, +12, +15, +9, +19, +13, +14
+ -28, -24, -20, -14, -7, -2, +0, +4, +8, +12, +15, +17, +19, +21, +22
};// ^ |
static SCORE ROOK_MAX_MOBILITY_IN_A_ROW_BONUS[8] =
{// 0 1 2 3 4 5 6 7
- 1, 10, +8, +12, +8, +8, +8, +8
+ -15, -6, +0, +4, +8, +8, +8, +8
};
//
@@ -491,16 +505,16 @@ static SCORE ROOK_MAX_MOBILITY_IN_A_ROW_BONUS[8] =
//
static SCORE QUEEN_MOBILITY_BY_SQUARES[28] =
{// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
- -54, -34, -22, -17, -19, -8, -4, -2, 7, +10, +12, +15, +18, +4, +30,
+ -30, -26, -22, -17, -11, -8, -4, -2, -1, +2, +4, +7, +10, +12, +14,
// |
//15 16 17 18 19 20 21 22 23 24 25 26 27
- +31, +32, +41, +42, +35, +36, +36, +21, +21, +6, +6, +7, +7
+ +15, +16, +17, +18, +19, +20, +20, +21, +21, +22, +22, +23, +23
};
-static SCORE QUEEN_OUT_EARLY[5] =
+static SCORE QUEEN_OUT_EARLY[5] =
{// 0 1 2 3 4 : num unmoved minors
- 0, -14, -6, -2, -25
+ 0, -14, -22, -26, -33
};
//
@@ -508,18 +522,18 @@ static SCORE QUEEN_OUT_EARLY[5] =
// point that queens are worth more then the standard nine "points".
// Thus, this scale is biased upwards by about 0.15 pawn.
//
-static SCORE QUEEN_KING_TROPISM[8] =
+static SCORE QUEEN_KING_TROPISM[8] =
{// 0 1 2 3 4 5 6 7
- 0, +34, +76, +30, +27, +9, +8, +-1
+ 0, +34, +28, +22, +19, +17, +16, +15
};
-static SCORE QUEEN_ATTACKS_SQ_NEXT_TO_KING = -8; // x #sq_attacked
+static SCORE QUEEN_ATTACKS_SQ_NEXT_TO_KING = 8; // x #sq_attacked
//
// King eval terms
// ---------------------------------------------------------------------------
//
-static ULONG KING_INITIAL_COUNTER_BY_LOCATION[2][128] =
+static ULONG KING_INITIAL_COUNTER_BY_LOCATION[2][128] =
{
{
1, 0, 0, 0, 1, 0, 0, 1, 0,0,0,0,0,0,0,0,
@@ -545,17 +559,17 @@ static ULONG KING_INITIAL_COUNTER_BY_LOCATION[2][128] =
}
};
-static SCORE KING_TO_CENTER[128] =
+static SCORE KING_TO_CENTER[128] =
{
- +-32, +-32, +-32, +-32, +-32, +-32, +-32, +-32, -32,-32,-32,-32,-32,-32,-32,-32,
- +-23, +3, +5, +-1, +-1, +5, +3, +-23, -32,-32,-32,-32,-32,-32,-32,-32,
- +3, +5, +13, +15, +15, +13, +5, +3, -32,-32,-32,-32,-32,-32,-32,-32,
- +5, +-1, +41, +31, +31, +41, +-1, +5, -32,-32,-32,-32,-32,-32,-32,-32,
+ +0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0,
+ +1, +3, +5, +7, +7, +5, +3, +1, 0,0,0,0,0,0,0,0,
+ +3, +5, +13, +15, +15, +13, +5, +3, 0,0,0,0,0,0,0,0,
+ +5, +7, +17, +23, +23, +17, +7, +5, 0,0,0,0,0,0,0,0,
// ------------------------------------------------------------------
- +5, +-1, +41, +31, +31, +41, +-1, +5, -32,-32,-32,-32,-32,-32,-32,-32,
- +3, +5, +13, +15, +15, +13, +5, +3, -32,-32,-32,-32,-32,-32,-32,-32,
- +-23, +3, +5, +-1, +-1, +5, +3, +-23, -32,-32,-32,-32,-32,-32,-32,-32,
- +-32, +-32, +-32, +-32, +-32, +-32, +-32, +-32, -32,-32,-32,-32,-32,-32,-32,-32
+ +5, +7, +17, +23, +23, +17, +7, +5, 0,0,0,0,0,0,0,0,
+ +3, +5, +13, +15, +15, +13, +5, +3, 0,0,0,0,0,0,0,0,
+ +1, +3, +5, +7, +7, +5, +3, +1, 0,0,0,0,0,0,0,0,
+ +0, +0, +0, +0, +0, +0, +0, +0, 0,0,0,0,0,0,0,0
};
//
@@ -573,7 +587,7 @@ static SCORE KING_TO_CENTER[128] =
#define KEEP_KING_AT_HOME_THRESHOLD \
(VALUE_ROOK + VALUE_ROOK + VALUE_BISHOP + VALUE_KING + 1)
-static ULONG KING_COUNTER_BY_ATTACK_PATTERN[32] =
+static ULONG KING_COUNTER_BY_ATTACK_PATTERN[32] =
{
//p 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//m 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
@@ -585,13 +599,13 @@ static ULONG KING_COUNTER_BY_ATTACK_PATTERN[32] =
static SCORE KING_SAFETY_BY_COUNTER[42] =
{
- 0, -4, -40, -28, -24, -28, -33, -39, -30, -50, -55, -60, -90,
- -97,-104,-135,-150,-141,-148,-211,-210,-217,-240,-255,-286,-306,
- -262,-330,-350,-386,-390,-378,-448,-462,-508,-508,-508,-508,-508,
- -508,-508,-508
+ -0, -4, -8, -12, -16, -20, -25, -31, -38, -50, -63, -76, -90,
+ -105,-120,-135,-150,-165,-180,-195,-210,-225,-240,-255,-270,-290,
+ -310,-330,-350,-370,-390,-410,-440,-470,-500,-500,-500,-500,-500,
+ -500,-500,-500
};
-static SCORE KING_MISSING_ONE_CASTLE_OPTION = 9;
+static SCORE KING_MISSING_ONE_CASTLE_OPTION = -23;
typedef struct _DNA_BASE_SIZE {
SCORE *pBase;
ULONG uCount;
@@ -5690,6 +5704,22 @@ Return value:
goto end;
}
}
+ else
+ {
+ //
+ // EstimatePositionalScore (above) is the only place that
+ // refreshes pos->uPiecesPointingAtKing[] -- _EvalKing reads it
+ // unconditionally further down. When this branch is skipped
+ // (position wasn't close enough to the window to risk a lazy
+ // exit), nothing else sets it for the current position, so
+ // _EvalKing would silently score king safety off of whatever
+ // stale value was left over from a prior, unrelated node.
+ // Refresh it here instead -- once, not twice, since this is
+ // the innermost eval loop.
+ //
+ (void)CountKingSafetyDefects(pos, WHITE);
+ (void)CountKingSafetyDefects(pos, BLACK);
+ }
#endif
//