+ (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))];
else if (Type == QUIETS)
- m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
- + (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
- + (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
- + (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
- + (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)] / 2;
+ m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
+ + 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
+ + 2 * (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
+ + 2 * (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
+ + (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)];
else // Type == EVASIONS
{
endMoves = generate<QUIETS>(pos, cur);
score<QUIETS>();
- partial_insertion_sort(cur, endMoves, -4000 * depth);
+ partial_insertion_sort(cur, endMoves, -3000 * depth);
}
++stage;
std::memset(ss-7, 0, 10 * sizeof(Stack));
for (int i = 7; i > 0; i--)
- (ss-i)->continuationHistory = &this->continuationHistory[NO_PIECE][0]; // Use as sentinel
+ (ss-i)->continuationHistory = &this->continuationHistory[0][NO_PIECE][0]; // Use as a sentinel
+
ss->pv = pv;
bestValue = delta = alpha = -VALUE_INFINITE;
Value bestValue, value, ttValue, eval, maxValue;
bool ttHit, ttPv, inCheck, givesCheck, improving, doLMR;
bool captureOrPromotion, doFullDepthSearch, moveCountPruning, ttCapture;
- Piece movedPiece;
+ Piece movedPiece, priorCapture;
int moveCount, captureCount, quietCount, singularLMR;
// Step 1. Initialize node
Thread* thisThread = pos.this_thread();
inCheck = pos.checkers();
+ priorCapture = pos.captured_piece();
Color us = pos.side_to_move();
moveCount = captureCount = quietCount = singularLMR = ss->moveCount = 0;
bestValue = -VALUE_INFINITE;
update_quiet_stats(pos, ss, ttMove, nullptr, 0, stat_bonus(depth));
// Extra penalty for early quiet moves of the previous ply
- if ((ss-1)->moveCount <= 2 && !pos.captured_piece())
+ if ((ss-1)->moveCount <= 2 && !priorCapture)
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + 1));
}
// Penalty for a quiet ttMove that fails low
Depth R = (835 + 70 * depth) / 256 + std::min(int(eval - beta) / 185, 3);
ss->currentMove = MOVE_NULL;
- ss->continuationHistory = &thisThread->continuationHistory[NO_PIECE][0];
+ ss->continuationHistory = &thisThread->continuationHistory[0][NO_PIECE][0];
pos.do_null_move(st);
probCutCount++;
ss->currentMove = move;
- ss->continuationHistory = &thisThread->continuationHistory[pos.moved_piece(move)][to_sq(move)];
+ ss->continuationHistory = &thisThread->continuationHistory[!!priorCapture][pos.moved_piece(move)][to_sq(move)];
assert(depth >= 5);
// Update the current move (this must be done after singular extension search)
ss->currentMove = move;
- ss->continuationHistory = &thisThread->continuationHistory[movedPiece][to_sq(move)];
+ ss->continuationHistory = &thisThread->continuationHistory[!!priorCapture][movedPiece][to_sq(move)];
// Step 15. Make the move
pos.do_move(move, st, givesCheck);
// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
if ( ((ss-1)->moveCount == 1 || ((ss-1)->currentMove == (ss-1)->killers[0]))
- && !pos.captured_piece())
+ && !priorCapture)
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + 1));
}
// Bonus for prior countermove that caused the fail low
else if ( (depth >= 3 || PvNode)
- && !pos.captured_piece())
+ && !priorCapture)
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, stat_bonus(depth));
if (PvNode)
Move ttMove, move, bestMove;
Depth ttDepth;
Value bestValue, value, ttValue, futilityValue, futilityBase, oldAlpha;
+ Piece priorCapture;
bool ttHit, pvHit, inCheck, givesCheck, evasionPrunable;
int moveCount;
(ss+1)->ply = ss->ply + 1;
bestMove = MOVE_NONE;
inCheck = pos.checkers();
+ priorCapture = pos.captured_piece();
moveCount = 0;
// Check for an immediate draw or maximum ply reached
}
ss->currentMove = move;
- ss->continuationHistory = &thisThread->continuationHistory[pos.moved_piece(move)][to_sq(move)];
+ ss->continuationHistory = &thisThread->continuationHistory[!!priorCapture][pos.moved_piece(move)][to_sq(move)];
// Make and search the move
pos.do_move(move, st, givesCheck);