summaryrefslogtreecommitdiff
path: root/src/chess.h
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-09-15 13:31:36 -0700
committerScott Gasch <[email protected]>2026-09-15 13:31:36 -0700
commit390e675849ff42c8b7e1806f75552de988741fff (patch)
tree17b8792aeaf74373bbaef3bac6b71bb5c0d74c69 /src/chess.h
parentca73728f7dbf01c4b39c7496729f81b1fbffa00b (diff)
Rewrite _EvalKing as a linear ring-scan and promote its terms to DNA-tunable constants; retune via mate-mining regression, ElasticNet/Ridge, and logistic-vs-material refits.
Splits _EvalKing's own king-location table from CountKingSafetyDefects' search-gate copy so future eval retunes can't silently perturb extension/reduction gate frequency. Bumps KING_BACK_FLIGHT_BONUS (+1 -> +3) and reorders/nudges the ring-scan sub-terms (minor/pawn/xray/undefended) to match relative rankings that replicated across three independent calibration methods, while leaving KING_QUEEN_PROXIMITY_DANGER and KING_MISSING_ONE_CASTLE_OPTION untouched pending further discussion. Self-play (640 games) is roughly even (score 0.509, llr=+0.17, far from either SPRT bound) but consistently faster (nps candidate=1362140 vs head=1333682) at equal average depth -- landing as a wash/speed-neutral checkpoint, not a confirmed tactical improvement, for further tuning to build on. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/chess.h')
-rwxr-xr-xsrc/chess.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/chess.h b/src/chess.h
index df59626..4d7015e 100755
--- a/src/chess.h
+++ b/src/chess.h
@@ -1363,7 +1363,12 @@ PAWN_HASH_ENTRY;
typedef struct _KING_SAFETY_HASH_ENTRY
{
UINT64 u64Key;
- ULONG uFileStormDefects[2];
+ // 2026-09-15: SCORE (direct centipawns), not a counter -- see
+ // eval.c's _ComputeFileStormDefects. KING_DEFECT_DUMP's debug
+ // sibling _ComputeFileStormDefectsSplit is untouched and still
+ // reports old counter units into KING_DEFECT_DUMP_INFO, unrelated
+ // to this cache.
+ SCORE iFileStormDefects[2];
}
KING_SAFETY_HASH_ENTRY;
@@ -1427,6 +1432,15 @@ typedef struct _KING_DEFECT_DUMP_INFO
ULONG uMinorsAtHome;
FLAG fMissingCastleShort;
FLAG fMissingCastleLong;
+ // 2026-09-15: the REAL, current _EvalKing output (post-rewrite linear
+ // ring-scan sum, AFTER the REDUCED_MATERIAL_DOWN_SCALER multiply --
+ // i.e. exactly what gets added into this side's total eval) -- unlike
+ // every other field in this struct, which all come from the
+ // deliberately-frozen OLD counter mechanism (see uSafetyTableValue's
+ // comment). Added for a magnitude sanity check against other engines'
+ // king-safety terms (Crafty/Glaurung), not for regression mining --
+ // it postdates the CSVs the mining pipeline already produced.
+ SCORE iRealSafety;
}
KING_DEFECT_DUMP_INFO;
#endif
@@ -2714,6 +2728,20 @@ extern const int g_BishopRayDeltas[4];
extern const FLAG g_BishopRayPositiveDir[4];
extern BITBOARD g_KnightAttacksBB[128];
extern BITBOARD g_KingAttacksBB[128];
+
+// 2026-09-15: king-ring bitboard split for _EvalKing's linear-SCORE
+// rewrite -- front/back mirror EmptyAttackedSquare's old color-dependent
+// asymmetry and eval_tune/train_king_safety_model.py's BUCKET_SLOTS
+// (WHITE's front = the -17/-16/-15 delta triplet, BLACK's = +15/+16/+17);
+// side is the two same-rank neighbors (-1/+1), color-independent.
+// g_KingRingFrontBB[uColor][c] | g_KingRingBackBB[uColor][c] |
+// g_KingRingSideBB[c] == g_KingAttacksBB[c] always. Precomputed once at
+// startup (InitializeKingAttackTables, data.c) so the hot ring-scan can
+// intersect these with attack bitboards and CountBits() instead of
+// branching per square.
+extern BITBOARD g_KingRingFrontBB[2][128];
+extern BITBOARD g_KingRingBackBB[2][128];
+extern BITBOARD g_KingRingSideBB[128];
extern BITBOARD g_PawnAttackOriginBB[2][128];
extern BITBOARD g_RookOccupancyMask[128];
extern BITBOARD g_BishopOccupancyMask[128];