StateInfo st;
const TTEntry *tte;
Key posKey;
- Bitboard pinned;
Move ttMove, move, excludedMove, threatMove;
Depth ext, newDepth;
ValueType vt;
return VALUE_DRAW;
// Step 3. Mate distance pruning
- alpha = Max(value_mated_in(ss->ply), alpha);
- beta = Min(value_mate_in(ss->ply+1), beta);
- if (alpha >= beta)
- return alpha;
+ if (!RootNode)
+ {
+ alpha = Max(value_mated_in(ss->ply), alpha);
+ beta = Min(value_mate_in(ss->ply+1), beta);
+ if (alpha >= beta)
+ return alpha;
+ }
// Step 4. Transposition table lookup
// We don't want the score of a partial search to overwrite a previous full search
assert(rdepth >= ONE_PLY);
MovePicker mp(pos, ttMove, H, Position::see_value(pos.captured_piece_type()));
- pinned = pos.pinned_pieces(pos.side_to_move());
+ CheckInfo ci(pos);
while ((move = mp.get_next_move()) != MOVE_NONE)
- if (pos.pl_move_is_legal(move, pinned))
+ if (pos.pl_move_is_legal(move, ci.pinned))
{
- pos.do_move(move, st);
+ pos.do_move(move, st, ci, pos.move_gives_check(move, ci));
value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth);
pos.undo_move(move);
if (value >= rbeta)
// Initialize a MovePicker object for the current position
MovePickerExt<NT> mp(pos, ttMove, depth, H, ss, PvNode ? -VALUE_INFINITE : beta);
CheckInfo ci(pos);
- pinned = pos.pinned_pieces(pos.side_to_move());
ss->bestMove = MOVE_NONE;
futilityBase = ss->eval + ss->evalMargin;
singularExtensionNode = !RootNode
continue;
// At PV and SpNode nodes we want the moves to be legal
- if ((PvNode || SpNode) && !pos.pl_move_is_legal(move, pinned))
+ if ((PvNode || SpNode) && !pos.pl_move_is_legal(move, ci.pinned))
continue;
if (SpNode)
}
// At Root and at first iteration do a PV search on all the moves to score root moves
- isPvMove = (PvNode && moveCount <= (RootNode ? depth <= ONE_PLY ? 1000 : MultiPV : 1));
+ isPvMove = (PvNode && moveCount <= (RootNode ? depth <= ONE_PLY ? MAX_MOVES : MultiPV : 1));
givesCheck = pos.move_gives_check(move, ci);
captureOrPromotion = pos.move_is_capture(move) || move_is_promotion(move);
// a margin then we extend ttMove.
if ( singularExtensionNode
&& move == ttMove
- && pos.pl_move_is_legal(move, pinned)
+ && pos.pl_move_is_legal(move, ci.pinned)
&& ext < ONE_PLY)
{
Value ttValue = value_from_tt(tte->value(), ss->ply);
}
// Check for legality only before to do the move
- if (!pos.pl_move_is_legal(move, pinned))
+ if (!pos.pl_move_is_legal(move, ci.pinned))
{
moveCount--;
continue;
// Step extra. pv search (only in PV nodes)
// The first move in list is the expected PV
if (isPvMove)
- {
- // Aspiration window is disabled in multi-pv case
- if (RootNode && MultiPV > 1)
- alpha = -VALUE_INFINITE;
-
value = newDepth < ONE_PLY ? -qsearch<PV>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
: - search<PV>(pos, ss+1, -beta, -alpha, newDepth);
- }
else
{
// Step 15. Reduced depth search
// be generated.
MovePicker mp(pos, ttMove, depth, H, move_to((ss-1)->currentMove));
CheckInfo ci(pos);
- Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
// Loop through the moves until no moves remain or a beta cutoff occurs
while ( alpha < beta
}
// Check for legality only before to do the move
- if (!pos.pl_move_is_legal(move, pinned))
+ if (!pos.pl_move_is_legal(move, ci.pinned))
continue;
// Update current move