summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.c')
-rwxr-xr-xsrc/eval.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/eval.c b/src/eval.c
index 876e882..99baf8a 100755
--- a/src/eval.c
+++ b/src/eval.c
@@ -206,7 +206,7 @@ static SCORE ISOLATED_PAWN_BY_PAWNFILE[9] =
static SCORE ISOLATED_EXPOSED_PAWN = -5;
-static SCORE ISOLATED_DOUBLED_PAWN = 13;
+static SCORE ISOLATED_DOUBLED_PAWN = -1;
//
// Note: -25% to -33% if the enemy occupies or controls the next sq.
@@ -1381,7 +1381,8 @@ Return value:
(((WHITE == uColor) && (RANK(c) > 5)) ||
((BLACK == uColor) && (RANK(c) < 4)))))
{
- ASSERT(CANDIDATE_PASSER_BY_RANK[uColor][RANK(c)] > 0);
+ // Tuning can (and has) flipped this sign; not a real invariant.
+ //ASSERT(CANDIDATE_PASSER_BY_RANK[uColor][RANK(c)] > 0);
EVAL_TERM(uColor,
PAWN,
c,
@@ -1936,7 +1937,8 @@ Return value:
//
// Isolated + exposed? Extra penalty.
//
- ASSERT(ISOLATED_EXPOSED_PAWN < 0);
+ // Tuning can (and has) flipped this sign; not a real invariant.
+ //ASSERT(ISOLATED_EXPOSED_PAWN < 0);
EVAL_TERM(uColor,
PAWN,
c,
@@ -1955,7 +1957,8 @@ Return value:
//
// Isolated + doubled? Extra penalty.
//
- ASSERT(ISOLATED_DOUBLED_PAWN < 0);
+ // Tuning can (and has) flipped this sign; not a real invariant.
+ //ASSERT(ISOLATED_DOUBLED_PAWN < 0);
EVAL_TERM(uColor,
PAWN,
c,
@@ -2031,7 +2034,8 @@ Return value:
<= 8);
if (pHash->uCountPerFile[FLIP(uColor)][uPawnFile])
{
- ASSERT(BACKWARD_SHIELDED_BY_LOCATION[c] < 0);
+ // Tuning can (and has) flipped this sign; not a real invariant.
+ //ASSERT(BACKWARD_SHIELDED_BY_LOCATION[c] < 0);
EVAL_TERM(uColor,
PAWN,
c,
@@ -2041,7 +2045,7 @@ Return value:
}
else
{
- ASSERT(BACKWARD_EXPOSED_BY_LOCATION[c] < 0);
+ //ASSERT(BACKWARD_EXPOSED_BY_LOCATION[c] < 0);
EVAL_TERM(uColor,
PAWN,
c,
@@ -4265,7 +4269,9 @@ Return value:
ASSERT(uTotalMobility <= 14);
ASSERT(pos->uArmyScaler[FLIP(uColor)] <= 31);
- ASSERT(REDUCED_MATERIAL_UP_SCALER[pos->uArmyScaler[FLIP(uColor)]] <= 8);
+ // Tuning can (and has) pushed this out of its original hand-picked
+ // bound; not a real invariant.
+ //ASSERT(REDUCED_MATERIAL_UP_SCALER[pos->uArmyScaler[FLIP(uColor)]] <= 8);
i = ROOK_MOBILITY_BY_SQUARES[uTotalMobility];
i *= (int)(REDUCED_MATERIAL_UP_SCALER[pos->uArmyScaler[FLIP(uColor)]] + 1);
i /= 8;
@@ -4431,7 +4437,8 @@ Return value:
//
if (!RANK1(c) && !RANK8(c))
{
- ASSERT(QUEEN_OUT_EARLY[pos->uMinorsAtHome[uColor]] < 0);
+ // Tuning can (and has) flipped this sign; not a real invariant.
+ //ASSERT(QUEEN_OUT_EARLY[pos->uMinorsAtHome[uColor]] < 0);
ASSERT(pos->uMinorsAtHome[uColor] <= 4);
EVAL_TERM(uColor,
QUEEN,
@@ -5235,7 +5242,7 @@ Return value:
pos->iScore[WHITE],
uNumPassers[WHITE] * PASSER_BONUS_AS_MATERIAL_COMES_OFF[u],
"passer value material");
- ASSERT(PASSER_BONUS_AS_MATERIAL_COMES_OFF[u] >= 0);
+ // ASSERT(PASSER_BONUS_AS_MATERIAL_COMES_OFF[u] >= 0);
u = pos->uArmyScaler[WHITE];
EVAL_TERM(BLACK,
PAWN,
@@ -5243,7 +5250,7 @@ Return value:
pos->iScore[BLACK],
uNumPassers[BLACK] * PASSER_BONUS_AS_MATERIAL_COMES_OFF[u],
"passer value material");
- ASSERT(PASSER_BONUS_AS_MATERIAL_COMES_OFF[u] >= 0);
+ // ASSERT(PASSER_BONUS_AS_MATERIAL_COMES_OFF[u] >= 0);
}
@@ -5312,7 +5319,8 @@ Return value:
((pos->uPawnCount[uAhead] != 0) *
TRADE_PIECES[uMagnitude][pos->uNonPawnCount[uBehind][0]]),
"trade pieces");
- ASSERT(TRADE_PIECES[uMagnitude][pos->uNonPawnCount[uBehind][0]] > 0);
+ // Tuning can (and has) flipped this sign; not a real invariant.
+ //ASSERT(TRADE_PIECES[uMagnitude][pos->uNonPawnCount[uBehind][0]] > 0);
EVAL_TERM(uAhead,
0,
ILLEGAL_COOR,
@@ -5372,7 +5380,7 @@ Return value:
#endif
if (_WhoControlsSquareFast(pos, c) == FLIP(uSide))
{
- StoreEnprisePiece(pos, c);
+ RecordEnprisePiece(ctx, c);
}
}
}
@@ -5416,11 +5424,16 @@ Return value:
#endif
if (OPPOSITE_COLORS(uColor, pos->uToMove))
{
- StoreEnprisePiece(pos, c);
+ // uColor is the mover at ctx->uPly - 1 (ply
+ // parity), not here -- see RecordEnprisePieceAtPly.
+ if (ctx->uPly > 0)
+ {
+ RecordEnprisePieceAtPly(ctx, ctx->uPly - 1, c);
+ }
}
else
{
- StoreTrappedPiece(pos, c);
+ RecordTrappedPiece(ctx, c);
}
}
}
@@ -5954,6 +5967,17 @@ Return value:
//
ctx->sPlyInfo[ctx->uPly].uMinMobility[BLACK] = pos->uMinMobility[BLACK];
ctx->sPlyInfo[ctx->uPly].uMinMobility[WHITE] = pos->uMinMobility[WHITE];
+
+ //
+ // _EvalLookForDanger/_EvalTrappedPieces only ever *add* a hint
+ // when they find one; a full eval that finds nothing this time
+ // would otherwise leave a stale, unrelated hint from an earlier
+ // visit to this ply sitting here (still piece-identity-valid by
+ // coincidence). Clear this ply's self-danger slots first so a
+ // clean full eval reliably means a clean slate.
+ //
+ ctx->cEnprise[ctx->uPly][0] = ctx->cEnprise[ctx->uPly][1] = ILLEGAL_COOR;
+ ctx->cTrapped[ctx->uPly] = ILLEGAL_COOR;
_EvalLookForDanger(ctx);
_EvalTrappedPieces(ctx);