Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
syzygy1 committed Jul 1, 2020
1 parent a63197f commit 855bee2
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/ntsearch.c
Original file line number Diff line number Diff line change
@@ -57,8 +57,8 @@ Value search_NonPV(Pos *pos, Stack *ss, Value alpha, Depth depth, int cutNode)
Move ttMove, move, excludedMove, bestMove;
Depth extension, newDepth;
Value bestValue, value, ttValue, eval, maxValue;
int ttHit, ttPv, inCheck, givesCheck, improving, didLMR;
bool doFullDepthSearch, moveCountPruning;
int ttHit, ttPv, inCheck, givesCheck, didLMR;
bool improving, doFullDepthSearch, moveCountPruning;
bool ttCapture, captureOrPromotion, singularLMR;
Piece movedPiece;
int moveCount, captureCount, quietCount;
@@ -228,7 +228,7 @@ Value search_NonPV(Pos *pos, Stack *ss, Value alpha, Depth depth, int cutNode)
// Step 6. Static evaluation of the position
if (inCheck) {
ss->staticEval = eval = VALUE_NONE;
improving = 0;
improving = false;
goto moves_loop; // Skip early pruning when in check
} else if (ttHit) {
// Never assume anything about values stored in TT
@@ -458,7 +458,7 @@ Value search_NonPV(Pos *pos, Stack *ss, Value alpha, Depth depth, int cutNode)
&& bestValue > VALUE_MATED_IN_MAX_PLY)
{
// Skip quiet moves if movecount exceeds our FutilityMoveCount threshold
moveCountPruning = moveCount >= FutilityMoveCounts[improving][depth];
moveCountPruning = moveCount >= futility_move_count(improving, depth);

if ( !captureOrPromotion
&& !givesCheck)
13 changes: 6 additions & 7 deletions src/search.c
Original file line number Diff line number Diff line change
@@ -63,8 +63,7 @@ INLINE int futility_margin(Depth d, int improving) {
return 217 * (d - improving);
}

// Futility and reductions lookup tables, initialized at startup
static int FutilityMoveCounts[2][16]; // [improving][depth]
// Reductions lookup table, initialized at startup
static int Reductions[MAX_MOVES]; // [depth or moveNumber]

INLINE Depth reduction(int i, Depth d, int mn)
@@ -73,6 +72,11 @@ INLINE Depth reduction(int i, Depth d, int mn)
return ((r + 511) / 1024 + (!i && r > 1007));
}

INLINE int futility_move_count(bool improving, Depth depth)
{
return improving ? 5 + depth * depth - 1 : (5 + depth * depth) / 2 - 1;
}

// History and stats update bonus, based on depth
static Value stat_bonus(Depth depth)
{
@@ -130,11 +134,6 @@ void search_init(void)
{
for (int i = 1; i < MAX_MOVES; i++)
Reductions[i] = (24.8 + log(Threads.numThreads)) * log(i);

for (int d = 0; d < 16; ++d) {
FutilityMoveCounts[0][d] = (5 + d * d) / 2 - 1;
FutilityMoveCounts[1][d] = 5 + d * d - 1;
}
}


0 comments on commit 855bee2

Please sign in to comment.