ksq = pos.king_square(them);
dcCandidates = pos.discovered_check_candidates(us);
+ pinned = pos.pinned_pieces(us);
- checkSq[PAWN] = pos.attacks_from<PAWN>(ksq, them);
+ checkSq[PAWN] = pos.attacks_from<PAWN>(ksq, them);
checkSq[KNIGHT] = pos.attacks_from<KNIGHT>(ksq);
checkSq[BISHOP] = pos.attacks_from<BISHOP>(ksq);
- checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
- checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
- checkSq[KING] = EmptyBoardBB;
+ checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
+ checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
+ checkSq[KING] = EmptyBoardBB;
}
/// Position::move_gives_check() tests whether a pseudo-legal move is a check
-bool Position::move_gives_check(Move m) const {
-
- return move_gives_check(m, CheckInfo(*this));
-}
-
bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
assert(is_ok());
StateInfo st;
const TTEntry *tte;
Key posKey;
- Bitboard pinned;
Move ttMove, move, excludedMove, threatMove;
Depth ext, newDepth;
ValueType vt;
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)
// 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;
// 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