summaryrefslogtreecommitdiff
path: root/src/root.c
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-09-13 15:03:09 -0700
committerScott Gasch <[email protected]>2026-09-13 15:03:09 -0700
commit78d1889fe38db1fd45b58509c8b3bd535ce691b7 (patch)
tree994a213816c19c6654faf89eca74880f0fa79f47 /src/root.c
parentd2699c47d6d0abf0f018e5ba37d4f1bfe05ecd33 (diff)
Fix several MP/qsearch correctness bugs found by auditing ctx->uPly
indexing and per-thread state across MakeMove/recursion boundaries; add a position-signature stamp so full-eval-only data can be validated cheaply instead of approximated. - chess.h/searchsup.c/search.c/root.c: add NODE_TYPE (PV/CUT/ALL) classification, set centrally in CommonSearchInit, replacing the old binary fPvNode flag. Fixes split.c's node-type check reading stale data on helper threads (they never call CommonSearchInit for the split-point ply) and removes a redundant, always-true parent-type check in search.c's own LMR gate. - split.c: StartParallelSearch now copies the split point's eNodeType into SPLIT_INFO for helper threads to read (mirroring the existing iEval/iImprovement pattern); a split-node fail-high is now detected explicitly in search.c's move loop instead of falling through to the generic no_more_moves classifier, which misread it as a fail-low (skipping killer/history updates and storing an inverted-sense upper bound instead of a lower bound); ThreadUnderTerminatingSplit now checks all nested split pointers instead of just the first, so a thread notices when an inner split terminates while it's still helping an outer one; MAX_SPLITS bumped 20->64 for higher thread counts. - chess.h/searchsup.c/search.c: convert SEARCHER_THREAD_CONTEXT.uLastPositionalSource (a single per-thread scalar) to PLY_INFO.uLastPositionalSource (per-ply). The scalar version was clobbered whenever QSearch's own move loop recursed before a later iteration read it back, corrupting which qsearch futility margin got applied; also fixes the same hazard in the newly-added check-evasion futility prune. - chess.h/generate.c/searchsup.c: generalize move-scoring interpretation via a new MOVE_SCORING_SCHEME tag (per-ply, set by whichever generate.c routine last scored that ply's moves) and a single shared DecodeMoveValueEstimate, replacing scheme-blind decode logic in ComputeMoveScore and _ShouldWeConsiderThisMove. - chess.h/eval.c/dynamic.c: stamp PLY_INFO.u64FullEvalSig with the position signature whenever a node completes a full (non-lazy) Eval() call. cEnprise/pEnprise/cTrapped/pTrapped/iKingScore/the eval-scoped bb*Attacks bitboards are only valid when this matches the position's live signature; _EnpriseSlotValid/_TrappedSlotValid now compare sigs directly instead of re-checking piece identity on the live board. - searchsup.c: CommonSearchInit clears pi->mvBest on both its IsDraw and too-deep early-exit paths to prevent a later sibling node from reading stale mvBest data left by an unrelated earlier visit to the same ply. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01C9r36BydPnfpyYLFhkTo6d
Diffstat (limited to 'src/root.c')
-rw-r--r--src/root.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/root.c b/src/root.c
index 702dd47..46a7a80 100644
--- a/src/root.c
+++ b/src/root.c
@@ -468,6 +468,13 @@ Return value:
ASSERT(d);
Trace("Null move cutoff rate: %5.3f percent.\n",
((n / d) * 100.0));
+#ifdef PERF_COUNTERS
+ Trace("Node-type surprises: PV failed high/low=%llu, ALL failed high=%llu, "
+ "CUT failed low=%llu.\n",
+ ctx->sCounters.tree.u64PVNodeSurprised,
+ ctx->sCounters.tree.u64AllNodeFailedHigh,
+ ctx->sCounters.tree.u64CutNodeFailedLow);
+#endif
if (ctx->sCounters.egtb.uProbes > 0)
{
n = (double)(ctx->sCounters.egtb.uHits);
@@ -806,6 +813,13 @@ Return value:
UINT64 u64StartingNodeCount;
ULONG uNumLegalMoves;
+ // This function's own move loop overwrites sMoveStack[ctx->uPly]'s
+ // iValue with a node-count/score composite for next-iteration move
+ // ordering -- not a generate.c tier encoding, and not meaningful to
+ // ComputeMoveScore's decoder (see MOVE_SCORING_SCHEME's own comment,
+ // chess.h).
+ pi->eMoveScoringScheme = MOVE_SCORING_ROOT;
+
#ifdef DEBUG
POSITION *pos = &ctx->sPosition;
ASSERT(IS_VALID_SCORE(iAlpha));