summaryrefslogtreecommitdiff
path: root/src/chess.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/chess.h')
-rwxr-xr-xsrc/chess.h41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/chess.h b/src/chess.h
index 2bfec4d..0f7bf61 100755
--- a/src/chess.h
+++ b/src/chess.h
@@ -189,6 +189,7 @@ typedef struct _DLIST_ENTRY
#define THREE_PLY 192
#define FOUR_PLY 256
#define MAX_DEPTH_PER_SEARCH (MAX_PLY_PER_SEARCH * ONE_PLY)
+#define MAX_EXTEND_PER_LINE (MAX_PLY_PER_SEARCH * ONE_PLY / 2)
#define IS_VALID_DEPTH(x) (((x) >= 0) && \
((x) <= MAX_DEPTH_PER_SEARCH) && \
@@ -863,6 +864,9 @@ typedef struct _CUMULATIVE_SEARCH_FLAGS
FLAG fInReducedDepthBranch; // not used
FLAG fAvoidNullmove; // restore
FLAG fVerifyNullmove; // restore
+ INT iCumulativeExtend; // restore; total extension
+ // plies spent so far on
+ // this line, root to here
// qsearch
ULONG uQsearchDepth; // restore
@@ -946,10 +950,29 @@ PLY_INFO;
#define EVAL_HASH
#ifdef EVAL_HASH
#define EVAL_HASH_TABLE_SIZE (2097152) // 32Mb (per thread)
+
+//
+// bvFlags values for EVAL_HASH_ENTRY. EXACT means iEval is the real,
+// fully-computed static eval. UPPER/LOWER mean the entry came from a
+// lazy-eval early exit: iEval is the (uncorrected) partial score that
+// would be returned and iBound is the proven bound on the true, fully
+// computed eval (true score <= iBound for UPPER, true score >= iBound
+// for LOWER). Because the bound is a fact about the position -- not
+// about whatever alpha/beta window triggered the lazy exit -- it can
+// be reused by a later probe with a different window, as long as that
+// window is still resolved by the bound (mirrors HASH_FLAG_UPPER /
+// HASH_FLAG_LOWER in the main hash table).
+//
+#define EVAL_HASH_EXACT 0x1
+#define EVAL_HASH_UPPER 0x2
+#define EVAL_HASH_LOWER 0x4
+
typedef struct _EVAL_HASH_ENTRY
{
UINT64 u64Key;
SCORE iEval;
+ SCORE iBound;
+ UCHAR bvFlags;
ULONG uPositional;
COOR cTrapped[2];
@@ -1214,7 +1237,18 @@ _assert(CHAR *szFile, ULONG uLine);
#ifdef DEBUG
#define DISTANCE(a, b) DistanceBetweenSquares((a), (b))
#else
-#define DISTANCE(a, b) g_pDistance[(a) - (b)]
+//
+// (a) and (b) are COOR, i.e. unsigned; the subtraction below must be
+// forced into signed arithmetic before it's used as an index into
+// g_pDistance (which points to the middle of g_uDistance so that
+// negative differences work). Without the cast, (a)-(b) is computed
+// as unsigned and wraps instead of going negative; on a 32-bit build
+// that wrapped value, added to a 32-bit pointer, happens to wrap back
+// to the right address by accident, but on a 64-bit build the 32-bit
+// unsigned result gets zero-extended (not sign-extended) into the
+// 64-bit index and reads wildly out of bounds.
+//
+#define DISTANCE(a, b) g_pDistance[(int)(a) - (int)(b)]
#endif // DEBUG
#define IS_EMPTY( square ) (!(square))
@@ -2966,7 +3000,7 @@ void
ReportEvalHashStats(void);
SCORE
-ProbeEvalHash(SEARCHER_THREAD_CONTEXT *ctx);
+ProbeEvalHash(SEARCHER_THREAD_CONTEXT *ctx, SCORE iAlpha, SCORE iBeta);
SCORE
GetRoughEvalScore(IN SEARCHER_THREAD_CONTEXT *ctx,
@@ -2975,7 +3009,8 @@ GetRoughEvalScore(IN SEARCHER_THREAD_CONTEXT *ctx,
IN FLAG fUseHash);
void
-StoreEvalHash(SEARCHER_THREAD_CONTEXT *ctx, SCORE iScore);
+StoreEvalHash(SEARCHER_THREAD_CONTEXT *ctx, SCORE iScore, SCORE iBound,
+ UCHAR bvFlags);
#endif // EVAL_HASH
#endif // CHESS