summaryrefslogtreecommitdiff
path: root/src/dynamic.c
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-10-10 10:29:48 -0700
committerScott Gasch <[email protected]>2026-10-10 10:29:48 -0700
commit03545c4600df81b1a47dbc63fc606c065e857d8b (patch)
treea433fdce69fd27359679ad91e0ebedd52e2506cd /src/dynamic.c
parentfbdcb9d76dd2444d8bc631331eaeb9435cc247f8 (diff)
Eval mobility/pseudo-mobility tweaks; drop unproductive move-ordering experiments.
eval.c: add bishop/rook x-ray pseudo-mobility terms (squares seen past a directly-attacked higher-value piece), trim pawn-centrality edge penalty and bishop-pair bonus. chess.h/dynamic.c/generate.c/search.c/searchsup.c: revert three move-ordering experiments (recapture bonus, flee-to-safety GOOD_MOVE promotion, ply-2 move-pair bonus) that calibrated with real fail-high signal but never converted into a measurable node-count or solve-rate win on the curated suites -- see MOVE_ORDERING_IDEAS.md for the evidence and reasoning behind each drop. Add MOVE_ORDERING_EVIDENCE_COLLECTION as its own GNUmakefile flag, independent of PERF_COUNTERS, for any future such harness. command.c: remove the KING_DEFECT_DUMP-gated evalkingdump command, dead since the king-safety remine work moved to eval_tune/king_safety_data/. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/dynamic.c')
-rw-r--r--src/dynamic.c108
1 files changed, 27 insertions, 81 deletions
diff --git a/src/dynamic.c b/src/dynamic.c
index b0bad91..a56cf29 100644
--- a/src/dynamic.c
+++ b/src/dynamic.c
@@ -389,6 +389,7 @@ Return value:
}
u = MOVE_TO_INDEX(mvLast);
+#ifdef MOVE_ORDERING_EVIDENCE_COLLECTION
//
// Hit-rate instrumentation: did the counter-move slot for this
// previous move already predict the move that just won here?
@@ -397,13 +398,14 @@ Return value:
if ((ctx->mvCounter[u][0].uMove != 0) ||
(ctx->mvCounter[u][1].uMove != 0))
{
- INC(ctx->sCounters.tree.u64CounterMoveTries);
+ MOI_INC(ctx->sCounters.tree.u64CounterMoveTries);
if (IS_SAME_MOVE(mv, ctx->mvCounter[u][0]) ||
IS_SAME_MOVE(mv, ctx->mvCounter[u][1]))
{
- INC(ctx->sCounters.tree.u64CounterMoveHits);
+ MOI_INC(ctx->sCounters.tree.u64CounterMoveHits);
}
}
+#endif
// A/B test: write-gating by depth (reject shallower overwrites)
// measured *worse* hit rate with no EBF gain -- this table is
@@ -686,37 +688,18 @@ Return value:
**/
{
- ULONG x, y;
- ULONG uVal;
ULONG *pu;
ASSERT(!IS_CAPTURE_OR_PROMOTION(mv));
- uVal = uDepth / ONE_PLY;
- ASSERT(uVal >= 0);
- ASSERT(uVal <= MAX_PLY_PER_SEARCH);
- uVal += 1;
- uVal *= uVal;
- ASSERT(uVal > 0);
-
- pu = &(g_HistoryCounters[mv.pMoved][mv.cTo]);
- LOCK_DYN;
- *pu += uVal;
//
- // Make sure that the history weight doesn't get large enough to
- // affect the move flags or else our move ordering algorithm is
- // screwed.
+ // EXPERIMENT: flat/saturating update (see HISTORY_MAX/
+ // HISTORY_UPDATE_SHIFT comment, chess.h) -- depth-independent,
+ // asymptotically approaches HISTORY_MAX, never exceeds it.
//
- while (*pu & ~STRIP_OFF_FLAGS)
- {
- for (x = 0; x <= WHITE_KING; x++)
- {
- FOREACH_SQUARE(y)
- {
- g_HistoryCounters[x][y] >>= 4;
- }
- }
- }
+ pu = &(g_HistoryCounters[mv.pMoved][mv.cTo]);
+ LOCK_DYN;
+ *pu += (HISTORY_MAX - *pu) >> HISTORY_UPDATE_SHIFT;
#ifdef MP
//
@@ -734,14 +717,16 @@ Return value:
UNLOCK_DYN;
}
-static void
-_DecrementMoveHistoryCounter(MOVE mv,
+static void
+_DecrementMoveHistoryCounter(MOVE mv,
ULONG uDepth)
/**
-
+
Routine description:
Decrease a move's history counter in the global history table.
+ EXPERIMENT: flat/saturating decay, depth-independent -- see
+ HISTORY_MAX/HISTORY_UPDATE_SHIFT comment in chess.h.
Parameters:
@@ -754,27 +739,14 @@ Return value:
**/
{
- ULONG uVal;
ULONG *pu;
ASSERT(!IS_CAPTURE_OR_PROMOTION(mv));
- uVal = uDepth / ONE_PLY;
- ASSERT(uVal >= 0);
- ASSERT(uVal <= MAX_PLY_PER_SEARCH);
- uVal /= 4;
- uVal += 1;
- ASSERT(uVal > 0);
+ ASSERT(uDepth <= MAX_PLY_PER_SEARCH * ONE_PLY); // param kept for signature parity w/ increment
pu = &(g_HistoryCounters[mv.pMoved][mv.cTo]);
LOCK_DYN;
- if (*pu >= uVal)
- {
- *pu -= uVal;
- }
- else
- {
- *pu = 0;
- }
+ *pu -= (*pu >> HISTORY_UPDATE_SHIFT);
_RecordMoveFailure(mv);
UNLOCK_DYN;
}
@@ -787,9 +759,9 @@ _IncrementContinuationCounter(MOVE mvPrev, MOVE mv, ULONG uRemainingDepth)
Routine description:
Continuation-history counterpart to _IncrementMoveHistoryCounter --
- same (depth+1)^2 growth, same overflow-driven rescale, but keyed by
- (mvPrev, mv) instead of mv alone. No-op if there was no previous
- move (root).
+ EXPERIMENT: same flat/saturating depth-independent update (see
+ HISTORY_MAX/HISTORY_UPDATE_SHIFT, chess.h), keyed by (mvPrev, mv)
+ instead of mv alone. No-op if there was no previous move (root).
Parameters:
@@ -803,33 +775,19 @@ Return value:
**/
{
- ULONG uVal;
ULONG *pu;
- ULONG x;
ASSERT(!IS_CAPTURE_OR_PROMOTION(mv));
if (0 == mvPrev.uMove)
{
return;
}
- uVal = uRemainingDepth / ONE_PLY;
- ASSERT(uVal >= 0);
- ASSERT(uVal <= MAX_PLY_PER_SEARCH);
- uVal += 1;
- uVal *= uVal;
- ASSERT(uVal > 0);
+ ASSERT(uRemainingDepth <= MAX_PLY_PER_SEARCH * ONE_PLY); // unused by design now
pu = &(g_ContinuationHistory[(MOVE_TO_CONT_KEY(mvPrev) * CONT_KEY_RANGE) +
MOVE_TO_CONT_KEY(mv)]);
LOCK_DYN;
- *pu += uVal;
- while (*pu & ~STRIP_OFF_FLAGS)
- {
- for (x = 0; x < CONTINUATION_TABLE_SIZE; x++)
- {
- g_ContinuationHistory[x] >>= 4;
- }
- }
+ *pu += (HISTORY_MAX - *pu) >> HISTORY_UPDATE_SHIFT;
UNLOCK_DYN;
}
@@ -840,8 +798,9 @@ _DecrementContinuationCounter(MOVE mvPrev, MOVE mv, ULONG uRemainingDepth)
Routine description:
- Continuation-history counterpart to _DecrementMoveHistoryCounter.
- No-op if there was no previous move (root).
+ Continuation-history counterpart to _DecrementMoveHistoryCounter --
+ EXPERIMENT: flat/saturating decay, depth-independent. No-op if there
+ was no previous move (root).
Parameters:
@@ -855,7 +814,6 @@ Return value:
**/
{
- ULONG uVal;
ULONG *pu;
ASSERT(!IS_CAPTURE_OR_PROMOTION(mv));
@@ -863,24 +821,12 @@ Return value:
{
return;
}
- uVal = uRemainingDepth / ONE_PLY;
- ASSERT(uVal >= 0);
- ASSERT(uVal <= MAX_PLY_PER_SEARCH);
- uVal /= 4;
- uVal += 1;
- ASSERT(uVal > 0);
+ ASSERT(uRemainingDepth <= MAX_PLY_PER_SEARCH * ONE_PLY); // unused by design now
pu = &(g_ContinuationHistory[(MOVE_TO_CONT_KEY(mvPrev) * CONT_KEY_RANGE) +
MOVE_TO_CONT_KEY(mv)]);
LOCK_DYN;
- if (*pu >= uVal)
- {
- *pu -= uVal;
- }
- else
- {
- *pu = 0;
- }
+ *pu -= (*pu >> HISTORY_UPDATE_SHIFT);
UNLOCK_DYN;
}