summaryrefslogtreecommitdiff
path: root/src/probe.c
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-10-07 08:17:51 -0700
committerScott Gasch <[email protected]>2026-10-07 08:17:51 -0700
commitd14dbe2a50c220b2adac758c3d4f1a1fa67ece0b (patch)
treecbf6d9928bcc41ef833b62b70479113f7d419925 /src/probe.c
parent447130db3df87b40d080dc26429d45e9213c19f7 (diff)
Speed up eval/move-gen/SEE; remove EvalLookForDanger, overhaul _EvalKing
SPRT-confirmed improvement (1814 games, st 4.0): candidate nps=1498118 vs head=1378448, avg depth 14.30 vs 13.87, ELO=+24.2+/-16.0, LOWER95=0.5118, LLR=+3.126 crossing the H1 bound. Most of the diff is non-semantic speed work across eval.c, generate.c, movesup.c, see.c, probe.c and friends. Two real semantic changes: removed EvalLookForDanger and overhauled _EvalKing's king-safety scoring. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/probe.c')
-rw-r--r--src/probe.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/probe.c b/src/probe.c
index 269a1b9..d08ef75 100644
--- a/src/probe.c
+++ b/src/probe.c
@@ -515,28 +515,21 @@ Return value:
(mv.cTo == cTo) &&
(mv.pPromoted == pPromotes))
{
- // Root-only: use the DTZ ply count tb_probe_root already
- // packed into uResult (no extra probe) to report a real,
- // ply-distance-aware mate score instead of the flat
- // EGTB_WIN_SCORE/LOSS_SCORE used by in-search probes
- // (ProbeEGTB/RecognLookup) -- those stay WDL-only and
- // untouched. util.c's SCORE-to-string formatter already
- // treats any |score| >= NMATE as a mate score and derives
- // the move count as (INFINITY_SCORE - iScore) / 2, so
- // INFINITY_SCORE -/+ uDtz round-trips through that
- // unmodified as "+MATE<n>"/"-MATE<n>". Clamp defensively:
- // a uDtz large enough to push the score below NMATE would
- // just silently fall back to plain-decimal display, not
- // corrupt anything, but keep it a real mate score at every
- // legal DTZ value we could plausibly see (TB_MAX_PLY=256
- // exceeds NMATE's 200-point margin in principle, however
- // unlikely in practice for <=7-man tables).
- ULONG uDtz = TB_GET_DTZ(uResult);
- if (uDtz >= (+INFINITY_SCORE - NMATE)) uDtz = (+INFINITY_SCORE - NMATE - 1);
+ // DTZ (distance to the next fifty-move-rule-zeroing move)
+ // is not the same thing as distance to mate -- a previous
+ // version of this code reported (INFINITY_SCORE -/+ uDtz)
+ // as a mate score, which is wrong in general: DTZ can be
+ // small in a dead-won position that's still many plies
+ // from actual mate (e.g. right as pos->uFifty climbs
+ // towards 100, a reset becomes forced soon even though
+ // mate itself is nowhere near), producing a bogus
+ // "+MATE<n>"/"-MATE<n>" display untethered from reality.
+ // The draw/cursed-win/blessed-loss cases already returned
+ // FALSE above, so uWdl here is only ever TB_WIN or
+ // TB_LOSS -- report the same flat mate-magnitude score
+ // ProbeEGTB/RecognLookup use at interior nodes instead.
*pmv = mv;
- *piScore = (TB_WIN == uWdl) ?
- (SCORE)(+INFINITY_SCORE - uDtz) :
- (SCORE)(-INFINITY_SCORE + uDtz);
+ *piScore = (TB_WIN == uWdl) ? +NMATE : -NMATE;
return(TRUE);
}
}