Skip to content
Browse files

Retire Position::in_check()

It is redundant with Position::checkers()

No functional change.
  • Loading branch information...
1 parent 3b49aeb commit e82382703c96cfc480555e9db29d999e1f54a38f @mcostalba committed Dec 25, 2012
Showing with 17 additions and 22 deletions.
  1. +1 −1 src/endgame.cpp
  2. +2 −2 src/evaluate.cpp
  3. +5 −5 src/movegen.cpp
  4. +3 −3 src/movepick.cpp
  5. +3 −3 src/position.cpp
  6. +0 −5 src/position.h
  7. +3 −3 src/search.cpp
View
2 src/endgame.cpp
@@ -133,7 +133,7 @@ Value Endgame<KXK>::operator()(const Position& pos) const {
// Stalemate detection with lone king
if ( pos.side_to_move() == weakerSide
- && !pos.in_check()
+ && !pos.checkers()
&& !MoveList<LEGAL>(pos).size()) {
return VALUE_DRAW;
}
View
4 src/evaluate.cpp
@@ -361,7 +361,7 @@ namespace {
template<bool Trace>
Value do_evaluate(const Position& pos, Value& margin) {
- assert(!pos.in_check());
+ assert(!pos.checkers());
EvalInfo ei;
Score score, mobilityWhite, mobilityBlack;
@@ -1014,7 +1014,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
// 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
View
10 src/movegen.cpp
@@ -44,7 +44,7 @@ namespace {
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;
@@ -307,7 +307,7 @@ template<GenType Type>
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;
@@ -335,7 +335,7 @@ template MoveStack* generate<NON_EVASIONS>(const Position&, MoveStack*);
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);
@@ -366,7 +366,7 @@ MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
template<>
MoveStack* generate<EVASIONS>(const Position& pos, MoveStack* mlist) {
- assert(pos.in_check());
+ assert(pos.checkers());
Square from, checksq;
int checkersCnt = 0;
@@ -432,7 +432,7 @@ MoveStack* generate<LEGAL>(const Position& pos, MoveStack* mlist) {
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)
View
6 src/movepick.cpp
@@ -68,7 +68,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
endBadCaptures = moves + MAX_MOVES - 1;
ss = s;
- if (p.in_check())
+ if (p.checkers())
phase = EVASION;
else
@@ -96,7 +96,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
assert(d <= DEPTH_ZERO);
- if (p.in_check())
+ if (p.checkers())
phase = EVASION;
else if (d > DEPTH_QS_NO_CHECKS)
@@ -126,7 +126,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
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;
View
6 src/position.cpp
@@ -617,7 +617,7 @@ bool Position::is_pseudo_legal(const Move m) const {
// 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)
{
@@ -1144,7 +1144,7 @@ void Position::do_castle_move(Move m) {
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
@@ -1428,7 +1428,7 @@ bool Position::is_draw() const {
&& (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)
View
5 src/position.h
@@ -122,7 +122,6 @@ class Position {
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;
@@ -330,10 +329,6 @@ inline Bitboard Position::checkers() 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>();
}
View
6 src/search.cpp
@@ -188,7 +188,7 @@ void Search::think() {
{
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;
@@ -491,7 +491,7 @@ namespace {
// Step 1. Initialize node
Thread* thisThread = pos.this_thread();
moveCount = playedMoveCount = 0;
- inCheck = pos.in_check();
+ inCheck = pos.checkers();
if (SpNode)
{
@@ -1081,7 +1081,7 @@ namespace {
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);

0 comments on commit e823827

Please sign in to comment.
Something went wrong with that request. Please try again.