checkSq[BISHOP] = pos.attacks_from<BISHOP>(ksq);
checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
checkSq[BISHOP] = pos.attacks_from<BISHOP>(ksq);
checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
/// or the FEN string, we want the new born Position object do not depend
/// on any external data so we detach state pointer from the source one.
/// or the FEN string, we want the new born Position object do not depend
/// on any external data so we detach state pointer from the source one.
// Copy some fields of old state to our new StateInfo object except the ones
// which are recalculated from scratch anyway, then switch our state pointer
// Copy some fields of old state to our new StateInfo object except the ones
// which are recalculated from scratch anyway, then switch our state pointer
// Increment the 50 moves rule draw counter. Resetting it to zero in the
// case of non-reversible moves is taken care of later.
// Increment the 50 moves rule draw counter. Resetting it to zero in the
// case of non-reversible moves is taken care of later.
if ( st->castleRights != CASTLES_NONE
&& (castleRightsMask[from] & castleRightsMask[to]) != ALL_CASTLES)
{
if ( st->castleRights != CASTLES_NONE
&& (castleRightsMask[from] & castleRightsMask[to]) != ALL_CASTLES)
{
&& (attacks_from<PAWN>(from + pawn_push(us), us) & pieces(PAWN, them)))
{
st->epSquare = Square((from + to) / 2);
&& (attacks_from<PAWN>(from + pawn_push(us), us) & pieces(PAWN, them)))
{
st->epSquare = Square((from + to) / 2);
st->pawnKey ^= zobrist[us][PAWN][to];
st->materialKey ^= zobrist[us][promotion][pieceCount[us][promotion]++]
^ zobrist[us][PAWN][pieceCount[us][PAWN]];
st->pawnKey ^= zobrist[us][PAWN][to];
st->materialKey ^= zobrist[us][promotion][pieceCount[us][promotion]++]
^ zobrist[us][PAWN][pieceCount[us][PAWN]];