/// Position::move_gives_check() tests whether a pseudo-legal move gives a check
-CheckType Position::move_gives_check(Move m, const CheckInfo& ci) const {
+bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
assert(is_ok(m));
assert(ci.dcCandidates == discovered_check_candidates());
// Direct check ?
if (ci.checkSq[pt] & to)
- return DIRECT_CHECK;
+ return true;
// Discovery check ?
if (ci.dcCandidates && (ci.dcCandidates & from))
// For pawn and king moves we need to verify also direction
if ( (pt != PAWN && pt != KING)
|| !squares_aligned(from, to, king_square(~sideToMove)))
- return DISCO_CHECK;
+ return true;
}
// Can we skip the ugly special cases ?
if (type_of(m) == NORMAL)
- return NO_CHECK;
+ return false;
Color us = sideToMove;
Square ksq = king_square(~us);
// Promotion with check ?
if (type_of(m) == PROMOTION)
- return attacks_from(Piece(promotion_type(m)), to, pieces() ^ from) & ksq ? DIRECT_CHECK : NO_CHECK;
+ return attacks_from(Piece(promotion_type(m)), to, pieces() ^ from) & ksq;
// En passant capture with check ? We have already handled the case
// of direct checks and ordinary discovered check, the only case we
Bitboard b = (pieces() ^ from ^ capsq) | to;
return (attacks_bb< ROOK>(ksq, b) & pieces(us, QUEEN, ROOK))
- | (attacks_bb<BISHOP>(ksq, b) & pieces(us, QUEEN, BISHOP)) ? DISCO_CHECK : NO_CHECK;
+ | (attacks_bb<BISHOP>(ksq, b) & pieces(us, QUEEN, BISHOP));
}
// Castling with check ?
Square rto = relative_square(us, rfrom > kfrom ? SQ_F1 : SQ_D1);
Bitboard b = (pieces() ^ kfrom ^ rfrom) | rto | kto;
- return attacks_bb<ROOK>(rto, b) & ksq ? DIRECT_CHECK : NO_CHECK;
+ return attacks_bb<ROOK>(rto, b) & ksq;
}
- return NO_CHECK;
+ return false;
}
template<PieceType> Bitboard attacks_from(Square s, Color c) const;
// Properties of moves
- CheckType move_gives_check(Move m, const CheckInfo& ci) const;
+ bool move_gives_check(Move m, const CheckInfo& ci) const;
bool move_is_legal(const Move m) const;
bool pl_move_is_legal(Move m, Bitboard pinned) const;
bool is_pseudo_legal(const Move m) const;
Depth ext, newDepth;
Value bestValue, value, ttValue;
Value eval, nullValue, futilityValue;
- CheckType givesCheck;
- bool inCheck, pvMove, singularExtensionNode;
+ bool inCheck, givesCheck, pvMove, singularExtensionNode;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount, playedMoveCount;
if (PvNode && dangerous)
ext = ONE_PLY;
- else if (givesCheck && (givesCheck == DISCO_CHECK || pos.see_sign(move) >= 0))
+ else if (givesCheck && pos.see_sign(move) >= 0)
ext = ONE_PLY / 2;
// Singular extension search. If all moves but one fail low on a search of
// Prune moves with negative SEE at low depths
if ( predictedDepth < 2 * ONE_PLY
- && givesCheck != DISCO_CHECK
&& pos.see_sign(move) < 0)
{
if (SpNode)
Key posKey;
Move ttMove, move, bestMove;
Value bestValue, value, ttValue, futilityValue, futilityBase;
- CheckType givesCheck;
- bool enoughMaterial, evasionPrunable, fromNull;
+ bool givesCheck, enoughMaterial, evasionPrunable, fromNull;
Depth ttDepth;
ss->currentMove = bestMove = MOVE_NONE;
if ( !PvNode
&& (!InCheck || evasionPrunable)
&& move != ttMove
- && givesCheck != DISCO_CHECK
&& type_of(move) != PROMOTION
&& pos.see_sign(move) < 0)
continue;
CASTLE = 3 << 14
};
-enum CheckType {
- NO_CHECK,
- DIRECT_CHECK,
- DISCO_CHECK
-};
-
enum CastleRight { // Defined as in PolyGlot book hash key
CASTLES_NONE = 0,
WHITE_OO = 1,