st->nonPawnMaterial[us] += PieceValue[MG][promotion];
}
- // Update pawn hash key and prefetch access to pawnsTable
+ // Update pawn hash key
st->pawnKey ^= Zobrist::psq[pc][from] ^ Zobrist::psq[pc][to];
// Reset rule 50 draw counter
}
-/// Position::do(undo)_null_move() is used to do(undo) a "null move": It flips
+/// Position::do(undo)_null_move() is used to do(undo) a "null move": it flips
/// the side to move without executing any move on the board.
void Position::do_null_move(StateInfo& newSt) {
if (swap <= 0)
return true;
- Bitboard occ = pieces() ^ from ^ to;
+ Bitboard occupied = pieces() ^ from ^ to;
Color stm = color_of(piece_on(from));
- Bitboard attackers = attackers_to(to, occ);
+ Bitboard attackers = attackers_to(to, occupied);
Bitboard stmAttackers, bb;
int res = 1;
while (true)
{
stm = ~stm;
- attackers &= occ;
+ attackers &= occupied;
// If stm has no more attackers then give up: stm loses
if (!(stmAttackers = attackers & pieces(stm)))
// Don't allow pinned pieces to attack (except the king) as long as
// there are pinners on their original square.
- if (st->pinners[~stm] & occ)
+ if (st->pinners[~stm] & occupied)
stmAttackers &= ~st->blockersForKing[stm];
if (!stmAttackers)
if ((swap = PawnValueMg - swap) < res)
break;
- occ ^= lsb(bb);
- attackers |= attacks_bb<BISHOP>(to, occ) & pieces(BISHOP, QUEEN);
+ occupied ^= lsb(bb);
+ attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
else if ((bb = stmAttackers & pieces(KNIGHT)))
if ((swap = KnightValueMg - swap) < res)
break;
- occ ^= lsb(bb);
+ occupied ^= lsb(bb);
}
else if ((bb = stmAttackers & pieces(BISHOP)))
if ((swap = BishopValueMg - swap) < res)
break;
- occ ^= lsb(bb);
- attackers |= attacks_bb<BISHOP>(to, occ) & pieces(BISHOP, QUEEN);
+ occupied ^= lsb(bb);
+ attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
else if ((bb = stmAttackers & pieces(ROOK)))
if ((swap = RookValueMg - swap) < res)
break;
- occ ^= lsb(bb);
- attackers |= attacks_bb<ROOK>(to, occ) & pieces(ROOK, QUEEN);
+ occupied ^= lsb(bb);
+ attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
}
else if ((bb = stmAttackers & pieces(QUEEN)))
if ((swap = QueenValueMg - swap) < res)
break;
- occ ^= lsb(bb);
- attackers |= (attacks_bb<BISHOP>(to, occ) & pieces(BISHOP, QUEEN))
- | (attacks_bb<ROOK >(to, occ) & pieces(ROOK , QUEEN));
+ occupied ^= lsb(bb);
+ attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
+ | (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
}
else // KING
return (attackers & ~pieces(stm)) ? res ^ 1 : res;
}
- return res;
+ return bool(res);
}
/// Position::is_draw() tests whether the position is drawn by 50-move rule