// Stalemate detection with lone king
if ( pos.side_to_move() == weakerSide
- && !pos.in_check()
+ && !pos.checkers()
&& !MoveList<LEGAL>(pos).size()) {
return VALUE_DRAW;
}
template<bool Trace>
Value do_evaluate(const Position& pos, Value& margin) {
- assert(!pos.in_check());
+ assert(!pos.checkers());
EvalInfo ei;
Score score, mobilityWhite, mobilityBlack;
// Opponent king cannot block because path is defended and position
// is not in check. So only friendly pieces can be blockers.
- assert(!pos.in_check());
+ assert(!pos.checkers());
assert((queeningPath & pos.pieces()) == (queeningPath & pos.pieces(c)));
// Add moves needed to free the path from friendly pieces and retest condition
Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
Bitboard enemies = pos.pieces(~us);
- assert(!pos.in_check());
+ assert(!pos.checkers());
const int K = Chess960 ? kto > kfrom ? -1 : 1
: Side == KING_SIDE ? -1 : 1;
MoveStack* generate(const Position& pos, MoveStack* mlist) {
assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS);
- assert(!pos.in_check());
+ assert(!pos.checkers());
Color us = pos.side_to_move();
Bitboard target;
template<>
MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
- assert(!pos.in_check());
+ assert(!pos.checkers());
Color us = pos.side_to_move();
CheckInfo ci(pos);
template<>
MoveStack* generate<EVASIONS>(const Position& pos, MoveStack* mlist) {
- assert(pos.in_check());
+ assert(pos.checkers());
Square from, checksq;
int checkersCnt = 0;
Bitboard pinned = pos.pinned_pieces();
Square ksq = pos.king_square(pos.side_to_move());
- end = pos.in_check() ? generate<EVASIONS>(pos, mlist)
+ end = pos.checkers() ? generate<EVASIONS>(pos, mlist)
: generate<NON_EVASIONS>(pos, mlist);
while (cur != end)
if ( (pinned || from_sq(cur->move) == ksq || type_of(cur->move) == ENPASSANT)
endBadCaptures = moves + MAX_MOVES - 1;
ss = s;
- if (p.in_check())
+ if (p.checkers())
phase = EVASION;
else
assert(d <= DEPTH_ZERO);
- if (p.in_check())
+ if (p.checkers())
phase = EVASION;
else if (d > DEPTH_QS_NO_CHECKS)
MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType pt)
: pos(p), H(h), cur(moves), end(moves) {
- assert(!pos.in_check());
+ assert(!pos.checkers());
phase = PROBCUT;
// Evasions generator already takes care to avoid some kind of illegal moves
// and pl_move_is_legal() relies on this. So we have to take care that the
// same kind of moves are filtered out here.
- if (in_check())
+ if (checkers())
{
if (type_of(pc) != KING)
{
template<bool Do>
void Position::do_null_move(StateInfo& backupSt) {
- assert(!in_check());
+ assert(!checkers());
// Back up the information necessary to undo the null move to the supplied
// StateInfo object. Note that differently from normal case here backupSt
&& (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
return true;
- if (st->rule50 > 99 && (!in_check() || MoveList<LEGAL>(*this).size()))
+ if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
return true;
if (CheckRepetition)
Square castle_rook_square(Color c, CastlingSide s) const;
// Checking
- bool in_check() const;
Bitboard checkers() const;
Bitboard discovered_check_candidates() const;
Bitboard pinned_pieces() const;
return st->checkersBB;
}
-inline bool Position::in_check() const {
- return st->checkersBB != 0;
-}
-
inline Bitboard Position::discovered_check_candidates() const {
return hidden_checkers<false>();
}
{
RootMoves.push_back(MOVE_NONE);
sync_cout << "info depth 0 score "
- << score_to_uci(RootPos.in_check() ? -VALUE_MATE : VALUE_DRAW)
+ << score_to_uci(RootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
<< sync_endl;
goto finalize;
// Step 1. Initialize node
Thread* thisThread = pos.this_thread();
moveCount = playedMoveCount = 0;
- inCheck = pos.in_check();
+ inCheck = pos.checkers();
if (SpNode)
{
const bool PvNode = (NT == PV);
assert(NT == PV || NT == NonPV);
- assert(InCheck == pos.in_check());
+ assert(InCheck == !!pos.checkers());
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
assert(PvNode || (alpha == beta - 1));
assert(depth <= DEPTH_ZERO);