mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 17:19:36 +00:00
Retire Position::in_check()
It is redundant with Position::checkers() No functional change.
This commit is contained in:
parent
3b49aeb4f2
commit
e82382703c
7 changed files with 17 additions and 22 deletions
|
@ -133,7 +133,7 @@ Value Endgame<KXK>::operator()(const Position& pos) const {
|
||||||
|
|
||||||
// Stalemate detection with lone king
|
// Stalemate detection with lone king
|
||||||
if ( pos.side_to_move() == weakerSide
|
if ( pos.side_to_move() == weakerSide
|
||||||
&& !pos.in_check()
|
&& !pos.checkers()
|
||||||
&& !MoveList<LEGAL>(pos).size()) {
|
&& !MoveList<LEGAL>(pos).size()) {
|
||||||
return VALUE_DRAW;
|
return VALUE_DRAW;
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,7 +361,7 @@ namespace {
|
||||||
template<bool Trace>
|
template<bool Trace>
|
||||||
Value do_evaluate(const Position& pos, Value& margin) {
|
Value do_evaluate(const Position& pos, Value& margin) {
|
||||||
|
|
||||||
assert(!pos.in_check());
|
assert(!pos.checkers());
|
||||||
|
|
||||||
EvalInfo ei;
|
EvalInfo ei;
|
||||||
Score score, mobilityWhite, mobilityBlack;
|
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
|
// Opponent king cannot block because path is defended and position
|
||||||
// is not in check. So only friendly pieces can be blockers.
|
// 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)));
|
assert((queeningPath & pos.pieces()) == (queeningPath & pos.pieces(c)));
|
||||||
|
|
||||||
// Add moves needed to free the path from friendly pieces and retest condition
|
// Add moves needed to free the path from friendly pieces and retest condition
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace {
|
||||||
Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
|
Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
|
||||||
Bitboard enemies = pos.pieces(~us);
|
Bitboard enemies = pos.pieces(~us);
|
||||||
|
|
||||||
assert(!pos.in_check());
|
assert(!pos.checkers());
|
||||||
|
|
||||||
const int K = Chess960 ? kto > kfrom ? -1 : 1
|
const int K = Chess960 ? kto > kfrom ? -1 : 1
|
||||||
: Side == KING_SIDE ? -1 : 1;
|
: Side == KING_SIDE ? -1 : 1;
|
||||||
|
@ -307,7 +307,7 @@ template<GenType Type>
|
||||||
MoveStack* generate(const Position& pos, MoveStack* mlist) {
|
MoveStack* generate(const Position& pos, MoveStack* mlist) {
|
||||||
|
|
||||||
assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS);
|
assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS);
|
||||||
assert(!pos.in_check());
|
assert(!pos.checkers());
|
||||||
|
|
||||||
Color us = pos.side_to_move();
|
Color us = pos.side_to_move();
|
||||||
Bitboard target;
|
Bitboard target;
|
||||||
|
@ -335,7 +335,7 @@ template MoveStack* generate<NON_EVASIONS>(const Position&, MoveStack*);
|
||||||
template<>
|
template<>
|
||||||
MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
|
MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
|
||||||
|
|
||||||
assert(!pos.in_check());
|
assert(!pos.checkers());
|
||||||
|
|
||||||
Color us = pos.side_to_move();
|
Color us = pos.side_to_move();
|
||||||
CheckInfo ci(pos);
|
CheckInfo ci(pos);
|
||||||
|
@ -366,7 +366,7 @@ MoveStack* generate<QUIET_CHECKS>(const Position& pos, MoveStack* mlist) {
|
||||||
template<>
|
template<>
|
||||||
MoveStack* generate<EVASIONS>(const Position& pos, MoveStack* mlist) {
|
MoveStack* generate<EVASIONS>(const Position& pos, MoveStack* mlist) {
|
||||||
|
|
||||||
assert(pos.in_check());
|
assert(pos.checkers());
|
||||||
|
|
||||||
Square from, checksq;
|
Square from, checksq;
|
||||||
int checkersCnt = 0;
|
int checkersCnt = 0;
|
||||||
|
@ -432,7 +432,7 @@ MoveStack* generate<LEGAL>(const Position& pos, MoveStack* mlist) {
|
||||||
Bitboard pinned = pos.pinned_pieces();
|
Bitboard pinned = pos.pinned_pieces();
|
||||||
Square ksq = pos.king_square(pos.side_to_move());
|
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);
|
: generate<NON_EVASIONS>(pos, mlist);
|
||||||
while (cur != end)
|
while (cur != end)
|
||||||
if ( (pinned || from_sq(cur->move) == ksq || type_of(cur->move) == ENPASSANT)
|
if ( (pinned || from_sq(cur->move) == ksq || type_of(cur->move) == ENPASSANT)
|
||||||
|
|
|
@ -68,7 +68,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||||
endBadCaptures = moves + MAX_MOVES - 1;
|
endBadCaptures = moves + MAX_MOVES - 1;
|
||||||
ss = s;
|
ss = s;
|
||||||
|
|
||||||
if (p.in_check())
|
if (p.checkers())
|
||||||
phase = EVASION;
|
phase = EVASION;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -96,7 +96,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
|
||||||
|
|
||||||
assert(d <= DEPTH_ZERO);
|
assert(d <= DEPTH_ZERO);
|
||||||
|
|
||||||
if (p.in_check())
|
if (p.checkers())
|
||||||
phase = EVASION;
|
phase = EVASION;
|
||||||
|
|
||||||
else if (d > DEPTH_QS_NO_CHECKS)
|
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)
|
MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType pt)
|
||||||
: pos(p), H(h), cur(moves), end(moves) {
|
: pos(p), H(h), cur(moves), end(moves) {
|
||||||
|
|
||||||
assert(!pos.in_check());
|
assert(!pos.checkers());
|
||||||
|
|
||||||
phase = PROBCUT;
|
phase = PROBCUT;
|
||||||
|
|
||||||
|
|
|
@ -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
|
// 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
|
// and pl_move_is_legal() relies on this. So we have to take care that the
|
||||||
// same kind of moves are filtered out here.
|
// same kind of moves are filtered out here.
|
||||||
if (in_check())
|
if (checkers())
|
||||||
{
|
{
|
||||||
if (type_of(pc) != KING)
|
if (type_of(pc) != KING)
|
||||||
{
|
{
|
||||||
|
@ -1144,7 +1144,7 @@ void Position::do_castle_move(Move m) {
|
||||||
template<bool Do>
|
template<bool Do>
|
||||||
void Position::do_null_move(StateInfo& backupSt) {
|
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
|
// Back up the information necessary to undo the null move to the supplied
|
||||||
// StateInfo object. Note that differently from normal case here backupSt
|
// 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))
|
&& (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (st->rule50 > 99 && (!in_check() || MoveList<LEGAL>(*this).size()))
|
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (CheckRepetition)
|
if (CheckRepetition)
|
||||||
|
|
|
@ -122,7 +122,6 @@ public:
|
||||||
Square castle_rook_square(Color c, CastlingSide s) const;
|
Square castle_rook_square(Color c, CastlingSide s) const;
|
||||||
|
|
||||||
// Checking
|
// Checking
|
||||||
bool in_check() const;
|
|
||||||
Bitboard checkers() const;
|
Bitboard checkers() const;
|
||||||
Bitboard discovered_check_candidates() const;
|
Bitboard discovered_check_candidates() const;
|
||||||
Bitboard pinned_pieces() const;
|
Bitboard pinned_pieces() const;
|
||||||
|
@ -330,10 +329,6 @@ inline Bitboard Position::checkers() const {
|
||||||
return st->checkersBB;
|
return st->checkersBB;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Position::in_check() const {
|
|
||||||
return st->checkersBB != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Bitboard Position::discovered_check_candidates() const {
|
inline Bitboard Position::discovered_check_candidates() const {
|
||||||
return hidden_checkers<false>();
|
return hidden_checkers<false>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ void Search::think() {
|
||||||
{
|
{
|
||||||
RootMoves.push_back(MOVE_NONE);
|
RootMoves.push_back(MOVE_NONE);
|
||||||
sync_cout << "info depth 0 score "
|
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;
|
<< sync_endl;
|
||||||
|
|
||||||
goto finalize;
|
goto finalize;
|
||||||
|
@ -491,7 +491,7 @@ namespace {
|
||||||
// Step 1. Initialize node
|
// Step 1. Initialize node
|
||||||
Thread* thisThread = pos.this_thread();
|
Thread* thisThread = pos.this_thread();
|
||||||
moveCount = playedMoveCount = 0;
|
moveCount = playedMoveCount = 0;
|
||||||
inCheck = pos.in_check();
|
inCheck = pos.checkers();
|
||||||
|
|
||||||
if (SpNode)
|
if (SpNode)
|
||||||
{
|
{
|
||||||
|
@ -1081,7 +1081,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
const bool PvNode = (NT == PV);
|
const bool PvNode = (NT == PV);
|
||||||
|
|
||||||
assert(NT == PV || NT == NonPV);
|
assert(NT == PV || NT == NonPV);
|
||||||
assert(InCheck == pos.in_check());
|
assert(InCheck == !!pos.checkers());
|
||||||
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
|
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
|
||||||
assert(PvNode || (alpha == beta - 1));
|
assert(PvNode || (alpha == beta - 1));
|
||||||
assert(depth <= DEPTH_ZERO);
|
assert(depth <= DEPTH_ZERO);
|
||||||
|
|
Loading…
Add table
Reference in a new issue