summaryrefslogtreecommitdiff
path: root/src/changes/._main.c
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-09-08 18:15:36 -0700
committerScott Gasch <[email protected]>2026-09-08 18:15:36 -0700
commit85b71cf793a85074d8d4483b21a2a06c84553d1d (patch)
tree767e5bb8b03976b80e578913a3fbd009571be40f /src/changes/._main.c
parentfbb138cc1dd13da2f30129206cdcd3d128344f54 (diff)
eval.c: bad-trades fix, rook cache, xColor speedups, draw scaling, main-body reorder
Continues re-applying the eval.c overhaul from stash@{0} (see fbb138c), each piece verified individually against clean 434fa04 (fast st1 matches, ~30-40 games each) before landing: - _EvalBadTrades: replaced the TRADE_PIECES/DONT_TRADE_PAWNS lookup tables with direct arithmetic (part of a broader "eval.c is too slow, cut lookup tables where possible" effort). The stash's first attempt at this had a real bug: uInverseBehindPieceCount was computed by subtracting a raw material sum from 9 in unsigned arithmetic, which underflows to ~4 billion in any non-bare-endgame position with unequal material -- confirmed via match_play (score 0.15-0.225 over 20 games vs clean 434fa04, a near-total wipeout). Fixed to use the existing uNonPawnCount piece-count field directly instead of reinventing it via material math, and restored a cheap zero-pawn guard (old DONT_TRADE_PAWNS punished "material lead with zero pawns left" specifically -- the classic KNB-vs-KRP false positive -- which the arithmetic replacement had dropped entirely). Verified back at parity (0.475/40 games) after the fix. - _EvalRook: ROOK_FULL_HALF_OPEN_BONUS is now a startup-computed cache (InitEval(), refreshed on every DNA reload) instead of a per-call local array rebuild. - xColor = FLIP(uColor) cached once instead of recomputed inline: _EvalBishop, _EvalKnight, CountKingSafetyDefects (also renamed its uSide/xSide params to uColor/xColor to match), and Eval()'s own per-piece-type loop. - _EvalBishopPairs collapsed to one FOREACH_COLOR loop instead of duplicated per-side code. - eval.c "diet" cleanup: removed pos->iTempScore (a scalar handoff between _EvalKing and Eval()'s per-color copy, now redundant -- _EvalKing writes directly into ctx->sPlyInfo[ply].iKingScore[uColor]); removed several stale comments documenting already-historical removals; _EvalPassers renamed to _ReEvalPassers; re-enabled a previously-disabled ASSERT in _EvaluateCandidatePasser (confirmed live via DEBUG smoke test, does not fire under current DNA). - Added _SideHasWinningChances (Crafty-style material-only "can this side force a win at all" classifier) plus the fifty-move-rule dampening in Eval() -- both scale the score toward g_iDrawScore when material alone rules out real winning chances, without touching Eval()'s signature (kept the existing scalar piPositional convention rather than pulling in the super-lazy exit's per-color rework). - Removed the "B over N in the endgame with 2 pawn wings" term entirely, by direct instruction -- BISHOP_OVER_KNIGHT_IN_ENDGAME is now an orphaned DNA constant (matches the stash's own choice, which left it similarly unused). - Eval()'s main per-piece-type loop reordered from "all of our minors, then all of the enemy's minors, then rooks both colors, then queens both colors" to "ours then enemy's, interleaved per type" (knights, then bishops, then rooks, then queens). Verified the real dependency this ordering has to preserve -- _EvalRook/_EvalQueen read the enemy's bbMinorAttacks, _EvalKing reads both colors' bbMinorAttacks/ bbQueenAttacks, _ReEvalPassers needs the king scores -- and confirmed the new interleaving still satisfies it (all minors both colors done before any rook/queen; both colors done before king). Verification methodology throughout: gmake clean release build, DEBUG smoke test (10 random ECM positions at sd 5, asserts compiled in), then a fast (st 1, 40-game) match_play.py run against a clean 434fa04 reference binary before landing each piece. A same-binary-vs-itself control match (score 0.500/20 games) confirms the harness itself has no structural bias, so per-checkpoint scores in the 0.44-0.58 band across this session reflect real (if noisy) parity, not measurement artifacts. Still not re-applied (remains in stash@{0}): the super-lazy exit, the material-based normal-lazy floor, and search.c's qsearch futility rework -- these three are one coupled unit (the futility margins index by which Eval() exit tier fired) and go in as the next, more carefully scrutinized step, since the original regression that started this whole investigation traced to exactly this area. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ka9o3S2eKqh4jNfmxVZ6fH
Diffstat (limited to 'src/changes/._main.c')
0 files changed, 0 insertions, 0 deletions