}
// Reductions lookup table, initialized at startup
- int Reductions[64]; // [depth or moveNumber]
+ int Reductions[MAX_MOVES]; // [depth or moveNumber]
template <bool PvNode> Depth reduction(bool i, Depth d, int mn) {
- int r = Reductions[std::min(d / ONE_PLY, 63)] * Reductions[std::min(mn, 63)] / 1024;
+ int r = Reductions[d / ONE_PLY] * Reductions[mn] / 1024;
return ((r + 512) / 1024 + (!i && r > 1024) - PvNode) * ONE_PLY;
}
void Search::init() {
- for (int i = 1; i < 64; ++i)
+ for (int i = 1; i < MAX_MOVES; ++i)
Reductions[i] = int(1024 * std::log(i) / std::sqrt(1.95));
}
assert(0 <= ss->ply && ss->ply < MAX_PLY);
(ss+1)->ply = ss->ply + 1;
- ss->currentMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
- ss->continuationHistory = &thisThread->continuationHistory[NO_PIECE][0];
+ (ss+1)->excludedMove = bestMove = MOVE_NONE;
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
Square prevSq = to_sq((ss-1)->currentMove);
: ttHit ? tte->move() : MOVE_NONE;
ttPv = (ttHit && tte->is_pv()) || (PvNode && depth > 4 * ONE_PLY);
+ // If position has been searched at higher depths and we are shuffling,
+ // return value_draw.
+ if ( pos.rule50_count() > 36 - 6 * (pos.count<ALL_PIECES>() > 14)
+ && ss->ply > 36 - 6 * (pos.count<ALL_PIECES>() > 14)
+ && ttHit
+ && tte->depth() > depth
+ && pos.count<PAWN>() > 0)
+ return VALUE_DRAW;
+
// At non-PV nodes we check for an early TT cutoff
if ( !PvNode
&& ttHit
else if (type_of(move) == CASTLING)
extension = ONE_PLY;
+ // Shuffle extension
+ else if ( PvNode
+ && pos.rule50_count() > 18
+ && ss->ply > 18
+ && depth < 3 * ONE_PLY
+ && ss->ply < 3 * thisThread->rootDepth / ONE_PLY) // To avoid infinite loops
+ extension = ONE_PLY;
+
// Passed pawn extension
else if ( move == ss->killers[0]
&& pos.advanced_pawn_push(move)