/// SEE value of move is greater or equal to the given threshold. We'll use an
/// algorithm similar to alpha-beta pruning with a null window.
-bool Position::see_ge(Move m, Bitboard& occupied, Value threshold) const {
+bool Position::see_ge(Move m, Value threshold) const {
assert(is_ok(m));
return true;
assert(color_of(piece_on(from)) == sideToMove);
- occupied = pieces() ^ from ^ to; // xoring to is important for pinned piece logic
+ Bitboard occupied = pieces() ^ from ^ to; // xoring to is important for pinned piece logic
Color stm = sideToMove;
Bitboard attackers = attackers_to(to, occupied);
Bitboard stmAttackers, bb;
// the bitboard 'attackers' any X-ray attackers behind it.
if ((bb = stmAttackers & pieces(PAWN)))
{
- occupied ^= least_significant_square_bb(bb);
if ((swap = PawnValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
else if ((bb = stmAttackers & pieces(KNIGHT)))
{
- occupied ^= least_significant_square_bb(bb);
if ((swap = KnightValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
}
else if ((bb = stmAttackers & pieces(BISHOP)))
{
- occupied ^= least_significant_square_bb(bb);
if ((swap = BishopValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
}
else if ((bb = stmAttackers & pieces(ROOK)))
{
- occupied ^= least_significant_square_bb(bb);
if ((swap = RookValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
}
else if ((bb = stmAttackers & pieces(QUEEN)))
{
- occupied ^= least_significant_square_bb(bb);
if ((swap = QueenValueMg - swap) < res)
break;
+ occupied ^= least_significant_square_bb(bb);
attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
| (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
return bool(res);
}
-bool Position::see_ge(Move m, Value threshold) const {
- Bitboard occupied;
- return see_ge(m, occupied, threshold);
-}
-
/// Position::is_draw() tests whether the position is drawn by 50-move rule
/// or by repetition. It does not detect stalemates.
+ captureHistory[movedPiece][to_sq(move)][type_of(pos.piece_on(to_sq(move)))] / 7 < alpha)
continue;
- Bitboard occupied;
// SEE based pruning (~11 Elo)
- if (!pos.see_ge(move, occupied, Value(-212) * depth))
- {
- // Don't prune the move if opponent King/Queen/Rook gets a discovered attack during or after the exchanges
- Bitboard leftEnemies = pos.pieces(~us, KING, QUEEN, ROOK);
- Bitboard attacks = 0;
- occupied |= to_sq(move);
- while (leftEnemies && !attacks)
- {
- Square sq = pop_lsb(leftEnemies);
- attacks = pos.attackers_to(sq, occupied) & pos.pieces(us) & occupied;
- // Exclude Queen/Rook(s) which were already threatened before SEE (opponent King can't be in check when it's our turn)
- if (attacks && sq != pos.square<KING>(~us) && (pos.attackers_to(sq, pos.pieces()) & pos.pieces(us)))
- attacks = 0;
- }
- if (!attacks)
+ if (!pos.see_ge(move, Value(-205) * depth))
continue;
- }
}
else
{