summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-09-20 10:20:16 -0700
committerScott Gasch <[email protected]>2026-09-20 10:20:16 -0700
commit48a958fb6e14607a68067a09b4a4cb576bf6b742 (patch)
tree8951c83088995df8c3e5efe328634478c27ba5b4
parent8c0d66f13f08cb5e760d787a878260ad67d17c13 (diff)
INFINITY -> INFINITY_SCORE to not collide with math.h.
-rw-r--r--src/book.c2
-rwxr-xr-xsrc/chess.h14
-rw-r--r--src/command.c6
-rw-r--r--src/dynamic.c2
-rw-r--r--src/eval.c4
-rw-r--r--src/hash.c16
-rw-r--r--src/movesup.c2
-rw-r--r--src/root.c18
-rw-r--r--src/script.c4
-rw-r--r--src/search.c8
-rw-r--r--src/searchsup.c16
-rw-r--r--src/split.c2
-rw-r--r--src/testeval.c4
-rw-r--r--src/util.c4
14 files changed, 51 insertions, 51 deletions
diff --git a/src/book.c b/src/book.c
index 1a5580b..4a39790 100644
--- a/src/book.c
+++ b/src/book.c
@@ -2967,7 +2967,7 @@ Return value:
pos = GetRootPosition();
InitializeSearcherContext(pos, ctx);
DumpPosition(pos);
- (void)Eval(ctx, -INFINITY, +INFINITY, NULL);
+ (void)Eval(ctx, -INFINITY_SCORE, +INFINITY_SCORE, NULL);
Trace("King safeties: W=%d, B=%d\n",
ctx->sPlyInfo[ctx->uPly].iKingScore[WHITE],
ctx->sPlyInfo[ctx->uPly].iKingScore[BLACK]);
diff --git a/src/chess.h b/src/chess.h
index e98c99f..1dcb517 100755
--- a/src/chess.h
+++ b/src/chess.h
@@ -194,12 +194,12 @@ typedef struct _DLIST_ENTRY
((x) <= MAX_DEPTH_PER_SEARCH) && \
(((x) & 0xfffff00f) == 0))
-#define INFINITY (MAX_SHORT)
-#define INVALID_SCORE (INFINITY + 1)
-#define IS_VALID_SCORE(x) (((x) >= -INFINITY) && \
- ((x) <= +INFINITY))
-#define NMATE (+INFINITY - 200)
-#define MATED_SCORE(ply) (-INFINITY + (ply))
+#define INFINITY_SCORE (MAX_SHORT)
+#define INVALID_SCORE (INFINITY_SCORE + 1)
+#define IS_VALID_SCORE(x) (((x) >= -INFINITY_SCORE) && \
+ ((x) <= +INFINITY_SCORE))
+#define NMATE (+INFINITY_SCORE - 200)
+#define MATED_SCORE(ply) (-INFINITY_SCORE + (ply))
#define IS_A_POWER_OF_2(x) (((x) & (x - 1)) == 0)
//
@@ -2230,7 +2230,7 @@ TestFenCode(void);
#define INVERT_ROOK 180
#define VALUE_QUEEN 975
#define INVERT_QUEEN 100
-#define VALUE_KING (INFINITY)
+#define VALUE_KING (INFINITY_SCORE)
#define INVERT_KING 1
#define VALUE_FULL_ARMY (8 * VALUE_PAWN) + (2 * VALUE_KNIGHT) + \
diff --git a/src/command.c b/src/command.c
index b201c31..1902784 100644
--- a/src/command.c
+++ b/src/command.c
@@ -542,7 +542,7 @@ Return value:
{
ReInitializeSearcherContext(pos, ctx);
}
- i = Eval(ctx, -INFINITY, +INFINITY, NULL);
+ i = Eval(ctx, -INFINITY_SCORE, +INFINITY_SCORE, NULL);
Trace("Static eval: %s\n", ScoreToString(i));
}
@@ -608,7 +608,7 @@ Return value:
{
ReInitializeSearcherContext(pos, ctx);
}
- (void)Eval(ctx, -INFINITY, +INFINITY, NULL);
+ (void)Eval(ctx, -INFINITY_SCORE, +INFINITY_SCORE, NULL);
for (uColor = 0; uColor < 2; uColor++)
{
@@ -767,7 +767,7 @@ Return value:
ULONG uSavedHardExtendLimit = g_uHardExtendLimit;
SetMoveTimerToThinkForever();
g_uHardExtendLimit = MAX_PLY_PER_SEARCH;
- i = QSearch(ctx, -INFINITY, +INFINITY);
+ i = QSearch(ctx, -INFINITY_SCORE, +INFINITY_SCORE);
g_MoveTimer = SavedMoveTimer;
g_uHardExtendLimit = uSavedHardExtendLimit;
}
diff --git a/src/dynamic.c b/src/dynamic.c
index c64794a..687fa74 100644
--- a/src/dynamic.c
+++ b/src/dynamic.c
@@ -38,7 +38,7 @@ Revision History:
#include "chess.h"
// Declared directly instead of #include <math.h> -- that header
-// #defines its own INFINITY, which collides with ours (chess.h:198,
+// #defines its own INFINITY_SCORE, which collides with ours (chess.h:198,
// MAX_SHORT). Only needed once, at startup, to build g_iLMRQuietReduction.
extern double log(double);
diff --git a/src/eval.c b/src/eval.c
index 02dab53..7d3f38b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3393,8 +3393,8 @@ Return value:
// Plain Newton's-method sqrt, no <math.h> -- chess.h's own VALUE_KING
-// #defines INFINITY as a board-eval sentinel, which collides with
-// <math.h>'s own INFINITY macro, so libm's sqrt() isn't available
+// #defines INFINITY_SCORE as a board-eval sentinel, which collides with
+// <math.h>'s own INFINITY_SCORE macro, so libm's sqrt() isn't available
// here without one shadowing the other. Variance is always small
// (swings are bounded well under 2^31), so a fixed handful of Newton
// iterations from a decent seed converges to full double precision.
diff --git a/src/hash.c b/src/hash.c
index 803376d..d5d9a03 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -472,7 +472,7 @@ Return value:
//
// It does not make sense to store hash positions that are worth
- // at best ~INFINITY. Every position is and this is a waste of
+ // at best ~INFINITY_SCORE. Every position is and this is a waste of
// hash space. Ignore these.
//
if (iValue >= +NMATE) return;
@@ -510,8 +510,8 @@ Return value:
if (iValue <= -NMATE)
{
//
- // If this is an upper bound near -INFINITY
- // (i.e. ~-INFINITY at best) convert it into -NMATE at
+ // If this is an upper bound near -INFINITY_SCORE
+ // (i.e. ~-INFINITY_SCORE at best) convert it into -NMATE at
// best (at best mate in N).
//
pHash->iValue = -NMATE;
@@ -597,8 +597,8 @@ Return value:
if (iValue >= +NMATE)
{
#ifdef ADJUST_MATE_IN_N
- ASSERT((iValue + (int)uPly) < +INFINITY);
- ASSERT((iValue + (int)uPly) > -INFINITY);
+ ASSERT((iValue + (int)uPly) < +INFINITY_SCORE);
+ ASSERT((iValue + (int)uPly) > -INFINITY_SCORE);
pHash->iValue = (signed short)(iValue + (int)uPly);
#else
pHash->bvFlags = g_cDirty | HASH_FLAG_LOWER;
@@ -609,8 +609,8 @@ Return value:
else if (iValue <= -NMATE)
{
#ifdef ADJUST_MATE_IN_N
- ASSERT((iValue + (int)uPly) < +INFINITY);
- ASSERT((iValue - (int)uPly) > -INFINITY);
+ ASSERT((iValue + (int)uPly) < +INFINITY_SCORE);
+ ASSERT((iValue - (int)uPly) > -INFINITY_SCORE);
pHash->iValue = (signed short)(iValue - (int)uPly);
#else
pHash->bvFlags = g_cDirty | HASH_FLAG_UPPER;
@@ -667,7 +667,7 @@ Return value:
//
// Do not bother to hash this node if it is telling us that the
- // value of this position is worth at least ~-INFINITY. This is
+ // value of this position is worth at least ~-INFINITY_SCORE. This is
// useless information and a waste of hash space.
//
if (iValue <= -NMATE) return;
diff --git a/src/movesup.c b/src/movesup.c
index 4a5f973..e39e52a 100644
--- a/src/movesup.c
+++ b/src/movesup.c
@@ -1591,7 +1591,7 @@ Return value:
{
ULONG v = u;
ULONG uEnd = ctx->sMoveStack.uEnd[ctx->uPly];
- SCORE iBestVal = -INFINITY;
+ SCORE iBestVal = -INFINITY_SCORE;
ULONG uLoc = v;
SCORE iVal;
MOVE_STACK_MOVE_VALUE_FLAGS mvfTemp;
diff --git a/src/root.c b/src/root.c
index 74d2327..a8a61bf 100644
--- a/src/root.c
+++ b/src/root.c
@@ -819,7 +819,7 @@ Return value:
**/
{
PLY_INFO *pi = &ctx->sPlyInfo[ctx->uPly];
- SCORE iBestScore = -INFINITY;
+ SCORE iBestScore = -INFINITY_SCORE;
SCORE iInitialAlpha = iAlpha;
MOVE mv;
ULONG x, y;
@@ -981,7 +981,7 @@ Return value:
iScore,
x + 1);
UtilPrintPV(ctx, iAlpha, iBeta, iScore, mv);
- KEEP_TRACK_OF_FIRST_MOVE_FHs(iBestScore == -INFINITY);
+ KEEP_TRACK_OF_FIRST_MOVE_FHs(iBestScore == -INFINITY_SCORE);
ctx->sMoveStack.mvf[x].bvFlags &= ~MVF_MOVE_SEARCHED;
goto end;
}
@@ -1265,7 +1265,7 @@ _IterateWidenWindow(ULONG uColor,
{
FIRST_FAIL_STEP,
SECOND_FAIL_STEP,
- INFINITY
+ INFINITY_SCORE
};
// Trace("State = %u.\n", *puState);
@@ -1273,7 +1273,7 @@ _IterateWidenWindow(ULONG uColor,
if ((abs(iRoughScore - iScore) > SKIP_GRADUAL_OPENING) ||
(*puState == 2))
{
- *piBound = iDir * INFINITY;
+ *piBound = iDir * INFINITY_SCORE;
*puState = 2;
}
else
@@ -1313,8 +1313,8 @@ Return value:
ULONG uFailState = 0;
ULONG uColor;
ULONG u;
- SCORE iAlpha = -INFINITY;
- SCORE iBeta = +INFINITY;
+ SCORE iAlpha = -INFINITY_SCORE;
+ SCORE iBeta = +INFINITY_SCORE;
SCORE iScore;
FLAG fInCheck = InCheck(&(ctx->sPosition), ctx->sPosition.uToMove);
MOVE mv;
@@ -1422,8 +1422,8 @@ Return value:
//
do
{
- if (iBeta > INFINITY) iBeta = +INFINITY;
- if (iAlpha < -INFINITY) iAlpha = -INFINITY;
+ if (iBeta > INFINITY_SCORE) iBeta = +INFINITY_SCORE;
+ if (iAlpha < -INFINITY_SCORE) iAlpha = -INFINITY_SCORE;
if (iAlpha >= iBeta) iAlpha = iBeta - 1;
// Was + HALF_PLY. Trimmed by QUARTER_PLY to compensate for
// search.c's qsearch-entry threshold moving from ONE_PLY down
@@ -1513,7 +1513,7 @@ Return value:
// Mate-in-n when we have searched n? Stop searching.
//
if (IS_VALID_SCORE(iScore) &&
- (ULONG)abs(iScore) >= (INFINITY - uDepth))
+ (ULONG)abs(iScore) >= (INFINITY_SCORE - uDepth))
{
Trace("FORCED MATE --> stop searching now\n");
g_MoveTimer.bvFlags |= TIMER_STOPPING;
diff --git a/src/script.c b/src/script.c
index 57145a6..532a0d5 100644
--- a/src/script.c
+++ b/src/script.c
@@ -24,8 +24,8 @@ Revision History:
#include "chess.h"
// Declared directly instead of #include <math.h> -- that header #defines
-// its own INFINITY, which collides with ours (chess.h:198, MAX_SHORT) and
-// would silently change what INFINITY means for the rest of this file.
+// its own INFINITY_SCORE, which collides with ours (chess.h:198, MAX_SHORT) and
+// would silently change what INFINITY_SCORE means for the rest of this file.
extern double pow(double, double);
// ----------------------------------------------------------------------
diff --git a/src/search.c b/src/search.c
index cb82ea4..0362701 100644
--- a/src/search.c
+++ b/src/search.c
@@ -165,7 +165,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
PLY_INFO *pi = &ctx->sPlyInfo[ctx->uPly];
CUMULATIVE_SEARCH_FLAGS *pf = &ctx->sSearchFlags;
MOVE mvLast = (pi-1)->mv;
- SCORE iBestScore = -INFINITY;
+ SCORE iBestScore = -INFINITY_SCORE;
SCORE iInitialAlpha;
SCORE iEval;
MOVE mv, mvBest, mvHash;
@@ -414,7 +414,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
case TRY_HASH_MOVE:
uStage++;
x = 0;
- ASSERT(iBestScore == -INFINITY);
+ ASSERT(iBestScore == -INFINITY_SCORE);
ASSERT(uLegalMoves == 0);
if (mvHash.uMove != 0)
{
@@ -921,7 +921,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
if (uNextDepth >= MAX_DEPTH_PER_SEARCH) uNextDepth = 0;
pf->iCumulativeExtend += iExtend;
ASSERT(pf->fAvoidNullmove == FALSE);
- if (iBestScore == -INFINITY)
+ if (iBestScore == -INFINITY_SCORE)
{
// First move, full a..b window.
ASSERT(uLegalMoves == 1);
@@ -2296,7 +2296,7 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
}
#endif
- // Note: iBestScore can be +INFINITY or -INFINITY here even in the
+ // Note: iBestScore can be +INFINITY_SCORE or -INFINITY_SCORE here even in the
// absence of a legitimate mate detected if we disallowed stand
// pat due to perceived danger early on, when the a..b window had
// an extreme bound. This is "legitimate" but weird.
diff --git a/src/searchsup.c b/src/searchsup.c
index 49027db..781c702 100644
--- a/src/searchsup.c
+++ b/src/searchsup.c
@@ -804,7 +804,7 @@ Return value:
ULONG x, uBegin, uEnd;
MOVE mv;
SCORE iScore;
- SCORE iBestScore = -INFINITY;
+ SCORE iBestScore = -INFINITY_SCORE;
ULONG uBest;
FLAG fFailHigh = FALSE;
SCORE rgScores[MAX_MOVES_PER_PLY];
@@ -840,7 +840,7 @@ Return value:
// honest score for every move at this ply (a fail-high partway
// through means we stop early, deliberately, without searching the
// rest). Committing partial data into iValue and then patching the
- // gaps with a sentinel (this function used to write -INFINITY into
+ // gaps with a sentinel (this function used to write -INFINITY_SCORE into
// every unsearched move) makes the whole ply look "rescored" to
// downstream code when it isn't really -- see the fail-high handling
// below for why that matters.
@@ -855,7 +855,7 @@ Return value:
mv.bvFlags |= WouldGiveCheck(ctx, mv);
if (TRUE == MakeMove(ctx, mv))
{
- if (-INFINITY == iBestScore)
+ if (-INFINITY_SCORE == iBestScore)
{
iScore = -Search(ctx, -iBeta, -iAlpha, uDepth);
}
@@ -885,7 +885,7 @@ Return value:
// Genuinely illegal (pseudo-legal but leaves king in check)
// -- this isn't "unknown," we know for a fact it's worthless
// and the caller will skip it too when MakeMove fails again.
- rgScores[x - uBegin] = -INFINITY;
+ rgScores[x - uBegin] = -INFINITY_SCORE;
}
}
@@ -908,7 +908,7 @@ Return value:
// for the rest (deliberately -- searching them would burn nodes
// solely to confirm what we've already decided to do, which is
// play uBest). Rather than inventing eval-axis values for moves
- // we never examined (the old code wrote -INFINITY into all of
+ // we never examined (the old code wrote -INFINITY_SCORE into all of
// them, including -- until fixed -- overwriting uBest's own
// just-computed score), leave every move's original generate.c
// ordering value completely untouched and just bump uBest into
@@ -1088,7 +1088,7 @@ Return value:
Trace(" \t");
}
- iEval = Eval(&temp, -INFINITY, +INFINITY, NULL);
+ iEval = Eval(&temp, -INFINITY_SCORE, +INFINITY_SCORE, NULL);
Trace("%5s (%+2d) | ", ScoreToString(iEval),
temp.sPosition.iMaterialBalance[temp.sPosition.uToMove] / 100);
Trace("%5s (%2u) | ",
@@ -1335,7 +1335,7 @@ Return value:
piAlpha,
piBeta))
{
- ASSERT(*piScore != -INFINITY);
+ ASSERT(*piScore != -INFINITY_SCORE);
ASSERT((*piScore <= *piAlpha) || (*piScore >= *piBeta));
goto end;
}
@@ -1420,7 +1420,7 @@ FLAG WeShouldTryNullmovePruning(SEARCHER_THREAD_CONTEXT *ctx,
if ((FALSE == pf->fAvoidNullmove) &&
(TotalNonPawnCount(pos, pos->uToMove) > 2) &&
(FALSE == pi->fInCheck) &&
- (iBeta != +INFINITY) &&
+ (iBeta != +INFINITY_SCORE) &&
(NODE_PV != pi->eNodeType))
{
if (uNullDepth <= 6 * ONE_PLY)
diff --git a/src/split.c b/src/split.c
index 679d26d..183f4fa 100644
--- a/src/split.c
+++ b/src/split.c
@@ -516,7 +516,7 @@ Return value:
ASSERT(IS_VALID_SCORE(*piAlpha));
ASSERT(IS_VALID_SCORE(iBeta));
ASSERT(IS_VALID_SCORE(*piBestScore));
- ASSERT(*piBestScore > -INFINITY);
+ ASSERT(*piBestScore > -INFINITY_SCORE);
ASSERT(pmvBest->uMove);
ASSERT(*piAlpha < iBeta);
diff --git a/src/testeval.c b/src/testeval.c
index ee9c6a2..97d950c 100644
--- a/src/testeval.c
+++ b/src/testeval.c
@@ -265,7 +265,7 @@ Return value:
GenerateRandomLegalSymetricPosition(&pos);
InitializeSearcherContext(&pos, ctx);
- i = Eval(ctx, -INFINITY, INFINITY, NULL);
+ i = Eval(ctx, -INFINITY_SCORE, INFINITY_SCORE, NULL);
if (i != 0)
{
DumpPosition(&ctx->sPosition);
@@ -429,7 +429,7 @@ Return value:
__FILE__, __LINE__);
}
- i = Eval(&ctx, -INFINITY, +INFINITY, NULL);
+ i = Eval(&ctx, -INFINITY_SCORE, +INFINITY_SCORE, NULL);
Trace("Position %u: SCORE %d for side to move.\n", u, i);
if (ctx.sPosition.uToMove == WHITE)
{
diff --git a/src/util.c b/src/util.c
index deeb77d..f3c5521 100644
--- a/src/util.c
+++ b/src/util.c
@@ -484,7 +484,7 @@ Return value:
if (iScore > 0)
{
- uDist = +INFINITY - iScore;
+ uDist = +INFINITY_SCORE - iScore;
uDist /= 2;
if (uDist)
{
@@ -497,7 +497,7 @@ Return value:
}
else
{
- uDist = +INFINITY + iScore;
+ uDist = +INFINITY_SCORE + iScore;
uDist /= 2;
if (uDist)
{