- // check_is_dangerous() tests if a checking move can be pruned in qsearch()
-
- bool check_is_dangerous(const Position& pos, Move move, Value futilityBase, Value beta)
- {
- Piece pc = pos.piece_moved(move);
- Square from = from_sq(move);
- Square to = to_sq(move);
- Color them = ~pos.side_to_move();
- Square ksq = pos.king_square(them);
- Bitboard enemies = pos.pieces(them);
- Bitboard kingAtt = pos.attacks_from<KING>(ksq);
- Bitboard occ = pos.pieces() ^ from ^ ksq;
- Bitboard oldAtt = pos.attacks_from(pc, from, occ);
- Bitboard newAtt = pos.attacks_from(pc, to, occ);
-
- // Checks which give opponent's king at most one escape square are dangerous
- if (!more_than_one(kingAtt & ~(enemies | newAtt | to)))
- return true;
-
- // Queen contact check is very dangerous
- if (type_of(pc) == QUEEN && (kingAtt & to))
- return true;
-
- // Creating new double threats with checks is dangerous
- Bitboard b = (enemies ^ ksq) & newAtt & ~oldAtt;
- while (b)
- {
- // Note that here we generate illegal "double move"!
- if (futilityBase + PieceValue[EG][pos.piece_on(pop_lsb(&b))] >= beta)
- return true;
- }
-
- return false;
- }
-
-