1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Rename check related functions

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-04-29 16:26:48 +02:00
parent 92d70fb667
commit 4dc7ba1619
8 changed files with 53 additions and 54 deletions

View file

@ -68,5 +68,4 @@ private:
template<int n> inline uint64_t Book::get_int() { return 256 * get_int<n-1>() + bookFile.get(); } template<int n> inline uint64_t Book::get_int() { return 256 * get_int<n-1>() + bookFile.get(); }
template<> inline uint64_t Book::get_int<1>() { return bookFile.get(); } template<> inline uint64_t Book::get_int<1>() { return bookFile.get(); }
#endif // !defined(BOOK_H_INCLUDED) #endif // !defined(BOOK_H_INCLUDED)

View file

@ -292,7 +292,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
assert(pos.is_ok()); assert(pos.is_ok());
assert(pos.thread() >= 0 && pos.thread() < MAX_THREADS); assert(pos.thread() >= 0 && pos.thread() < MAX_THREADS);
assert(!pos.is_check()); assert(!pos.in_check());
// Initialize value by reading the incrementally updated scores included // Initialize value by reading the incrementally updated scores included
// in the position object (material + piece square tables). // in the position object (material + piece square tables).

View file

@ -156,11 +156,11 @@ const string move_to_san(Position& pos, Move m) {
} }
} }
// The move gives check? We don't use pos.move_is_check() here // The move gives check? We don't use pos.move_gives_check() here
// because we need to test for a mate after the move is done. // because we need to test for a mate after the move is done.
StateInfo st; StateInfo st;
pos.do_move(m, st); pos.do_move(m, st);
if (pos.is_check()) if (pos.in_check())
san += pos.is_mate() ? "#" : "+"; san += pos.is_mate() ? "#" : "+";
pos.undo_move(m); pos.undo_move(m);

View file

@ -151,7 +151,7 @@ template<MoveType Type>
MoveStack* generate(const Position& pos, MoveStack* mlist) { MoveStack* generate(const Position& pos, MoveStack* mlist) {
assert(pos.is_ok()); assert(pos.is_ok());
assert(!pos.is_check()); assert(!pos.in_check());
Color us = pos.side_to_move(); Color us = pos.side_to_move();
Bitboard target; Bitboard target;
@ -202,7 +202,7 @@ template<>
MoveStack* generate<MV_NON_CAPTURE_CHECK>(const Position& pos, MoveStack* mlist) { MoveStack* generate<MV_NON_CAPTURE_CHECK>(const Position& pos, MoveStack* mlist) {
assert(pos.is_ok()); assert(pos.is_ok());
assert(!pos.is_check()); assert(!pos.in_check());
Bitboard b, dc; Bitboard b, dc;
Square from; Square from;
@ -243,7 +243,7 @@ template<>
MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) { MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
assert(pos.is_ok()); assert(pos.is_ok());
assert(pos.is_check()); assert(pos.in_check());
Bitboard b, target; Bitboard b, target;
Square from, checksq; Square from, checksq;
@ -311,7 +311,7 @@ MoveStack* generate<MV_PSEUDO_LEGAL>(const Position& pos, MoveStack* mlist) {
assert(pos.is_ok()); assert(pos.is_ok());
return pos.is_check() ? generate<MV_EVASION>(pos, mlist) return pos.in_check() ? generate<MV_EVASION>(pos, mlist)
: generate<MV_NON_EVASION>(pos, mlist); : generate<MV_NON_EVASION>(pos, mlist);
} }

View file

@ -65,7 +65,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
pinned = p.pinned_pieces(pos.side_to_move()); pinned = p.pinned_pieces(pos.side_to_move());
if (p.is_check()) if (p.in_check())
{ {
ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE; ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE;
phasePtr = EvasionTable; phasePtr = EvasionTable;
@ -99,7 +99,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h)
pinned = p.pinned_pieces(pos.side_to_move()); pinned = p.pinned_pieces(pos.side_to_move());
if (p.is_check()) if (p.in_check())
phasePtr = EvasionTable; phasePtr = EvasionTable;
else if (d >= DEPTH_QS_CHECKS) else if (d >= DEPTH_QS_CHECKS)
phasePtr = QsearchWithChecksTable; phasePtr = QsearchWithChecksTable;
@ -157,7 +157,7 @@ void MovePicker::go_next_phase() {
return; return;
case PH_EVASIONS: case PH_EVASIONS:
assert(pos.is_check()); assert(pos.in_check());
lastMove = generate<MV_EVASION>(pos, moves); lastMove = generate<MV_EVASION>(pos, moves);
score_evasions(); score_evasions();
return; return;

View file

@ -623,7 +623,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
bool Position::pl_move_is_evasion(Move m, Bitboard pinned) const bool Position::pl_move_is_evasion(Move m, Bitboard pinned) const
{ {
assert(is_check()); assert(in_check());
Color us = side_to_move(); Color us = side_to_move();
Square from = move_from(m); Square from = move_from(m);
@ -750,18 +750,18 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const {
return false; return false;
// The move is pseudo-legal, check if it is also legal // The move is pseudo-legal, check if it is also legal
return is_check() ? pl_move_is_evasion(m, pinned) : pl_move_is_legal(m, pinned); return in_check() ? pl_move_is_evasion(m, pinned) : pl_move_is_legal(m, pinned);
} }
/// Position::move_is_check() tests whether a pseudo-legal move is a check /// Position::move_gives_check() tests whether a pseudo-legal move is a check
bool Position::move_is_check(Move m) const { bool Position::move_gives_check(Move m) const {
return move_is_check(m, CheckInfo(*this)); return move_gives_check(m, CheckInfo(*this));
} }
bool Position::move_is_check(Move m, const CheckInfo& ci) const { bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
assert(is_ok()); assert(is_ok());
assert(move_is_ok(m)); assert(move_is_ok(m));
@ -883,7 +883,7 @@ void Position::do_setup_move(Move m) {
void Position::do_move(Move m, StateInfo& newSt) { void Position::do_move(Move m, StateInfo& newSt) {
CheckInfo ci(*this); CheckInfo ci(*this);
do_move(m, newSt, ci, move_is_check(m, ci)); do_move(m, newSt, ci, move_gives_check(m, ci));
} }
void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveIsCheck) { void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveIsCheck) {
@ -1430,7 +1430,7 @@ void Position::undo_castle_move(Move m) {
void Position::do_null_move(StateInfo& backupSt) { void Position::do_null_move(StateInfo& backupSt) {
assert(is_ok()); assert(is_ok());
assert(!is_check()); assert(!in_check());
// 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. // StateInfo object.
@ -1467,7 +1467,7 @@ void Position::do_null_move(StateInfo& backupSt) {
void Position::undo_null_move() { void Position::undo_null_move() {
assert(is_ok()); assert(is_ok());
assert(!is_check()); assert(!in_check());
// Restore information from the our backup StateInfo object // Restore information from the our backup StateInfo object
StateInfo* backupSt = st->previous; StateInfo* backupSt = st->previous;
@ -1798,7 +1798,7 @@ bool Position::is_draw() const {
bool Position::is_mate() const { bool Position::is_mate() const {
MoveStack moves[MAX_MOVES]; MoveStack moves[MAX_MOVES];
return is_check() && generate<MV_LEGAL>(*this, moves) == moves; return in_check() && generate<MV_LEGAL>(*this, moves) == moves;
} }

View file

@ -168,7 +168,7 @@ public:
// Checking pieces and under check information // Checking pieces and under check information
Bitboard checkers() const; Bitboard checkers() const;
bool is_check() const; bool in_check() const;
// Piece lists // Piece lists
Square piece_list(Color c, PieceType pt, int index) const; Square piece_list(Color c, PieceType pt, int index) const;
@ -186,8 +186,8 @@ public:
bool pl_move_is_evasion(Move m, Bitboard pinned) const; bool pl_move_is_evasion(Move m, Bitboard pinned) const;
bool move_is_legal(const Move m) const; bool move_is_legal(const Move m) const;
bool move_is_legal(const Move m, Bitboard pinned) const; bool move_is_legal(const Move m, Bitboard pinned) const;
bool move_is_check(Move m) const; bool move_gives_check(Move m) const;
bool move_is_check(Move m, const CheckInfo& ci) const; bool move_gives_check(Move m, const CheckInfo& ci) const;
bool move_is_capture(Move m) const; bool move_is_capture(Move m) const;
bool move_is_capture_or_promotion(Move m) const; bool move_is_capture_or_promotion(Move m) const;
bool move_is_passed_pawn_push(Move m) const; bool move_is_passed_pawn_push(Move m) const;
@ -454,7 +454,7 @@ inline Bitboard Position::checkers() const {
return st->checkersBB; return st->checkersBB;
} }
inline bool Position::is_check() const { inline bool Position::in_check() const {
return st->checkersBB != EmptyBoardBB; return st->checkersBB != EmptyBoardBB;
} }

View file

@ -341,7 +341,7 @@ int64_t perft(Position& pos, Depth depth) {
for (MoveStack* cur = mlist; cur != last; cur++) for (MoveStack* cur = mlist; cur != last; cur++)
{ {
m = cur->move; m = cur->move;
pos.do_move(m, st, ci, pos.move_is_check(m, ci)); pos.do_move(m, st, ci, pos.move_gives_check(m, ci));
sum += perft(pos, depth - ONE_PLY); sum += perft(pos, depth - ONE_PLY);
pos.undo_move(m); pos.undo_move(m);
} }
@ -512,7 +512,7 @@ namespace {
if (Rml.size() == 0) if (Rml.size() == 0)
{ {
cout << "info depth 0 score " cout << "info depth 0 score "
<< value_to_uci(pos.is_check() ? -VALUE_MATE : VALUE_DRAW) << value_to_uci(pos.in_check() ? -VALUE_MATE : VALUE_DRAW)
<< endl; << endl;
return MOVE_NONE; return MOVE_NONE;
@ -681,14 +681,14 @@ namespace {
ValueType vt; ValueType vt;
Value bestValue, value, oldAlpha; Value bestValue, value, oldAlpha;
Value refinedValue, nullValue, futilityBase, futilityValueScaled; // Non-PV specific Value refinedValue, nullValue, futilityBase, futilityValueScaled; // Non-PV specific
bool isPvMove, isCheck, singularExtensionNode, moveIsCheck, captureOrPromotion, dangerous, isBadCap; bool isPvMove, inCheck, singularExtensionNode, givesCheck, captureOrPromotion, dangerous, isBadCap;
int moveCount = 0, playedMoveCount = 0; int moveCount = 0, playedMoveCount = 0;
int threadID = pos.thread(); int threadID = pos.thread();
SplitPoint* sp = NULL; SplitPoint* sp = NULL;
refinedValue = bestValue = value = -VALUE_INFINITE; refinedValue = bestValue = value = -VALUE_INFINITE;
oldAlpha = alpha; oldAlpha = alpha;
isCheck = pos.is_check(); inCheck = pos.in_check();
ss->ply = (ss-1)->ply + 1; ss->ply = (ss-1)->ply + 1;
// Used to send selDepth info to GUI // Used to send selDepth info to GUI
@ -753,7 +753,7 @@ namespace {
} }
// Step 5. Evaluate the position statically and update parent's gain statistics // Step 5. Evaluate the position statically and update parent's gain statistics
if (isCheck) if (inCheck)
ss->eval = ss->evalMargin = VALUE_NONE; ss->eval = ss->evalMargin = VALUE_NONE;
else if (tte) else if (tte)
{ {
@ -775,7 +775,7 @@ namespace {
// Step 6. Razoring (is omitted in PV nodes) // Step 6. Razoring (is omitted in PV nodes)
if ( !PvNode if ( !PvNode
&& depth < RazorDepth && depth < RazorDepth
&& !isCheck && !inCheck
&& refinedValue + razor_margin(depth) < beta && refinedValue + razor_margin(depth) < beta
&& ttMove == MOVE_NONE && ttMove == MOVE_NONE
&& abs(beta) < VALUE_MATE_IN_PLY_MAX && abs(beta) < VALUE_MATE_IN_PLY_MAX
@ -795,7 +795,7 @@ namespace {
if ( !PvNode if ( !PvNode
&& !ss->skipNullMove && !ss->skipNullMove
&& depth < RazorDepth && depth < RazorDepth
&& !isCheck && !inCheck
&& refinedValue - futility_margin(depth, 0) >= beta && refinedValue - futility_margin(depth, 0) >= beta
&& abs(beta) < VALUE_MATE_IN_PLY_MAX && abs(beta) < VALUE_MATE_IN_PLY_MAX
&& pos.non_pawn_material(pos.side_to_move())) && pos.non_pawn_material(pos.side_to_move()))
@ -805,7 +805,7 @@ namespace {
if ( !PvNode if ( !PvNode
&& !ss->skipNullMove && !ss->skipNullMove
&& depth > ONE_PLY && depth > ONE_PLY
&& !isCheck && !inCheck
&& refinedValue >= beta && refinedValue >= beta
&& abs(beta) < VALUE_MATE_IN_PLY_MAX && abs(beta) < VALUE_MATE_IN_PLY_MAX
&& pos.non_pawn_material(pos.side_to_move())) && pos.non_pawn_material(pos.side_to_move()))
@ -863,7 +863,7 @@ namespace {
// Step 9. Internal iterative deepening // Step 9. Internal iterative deepening
if ( depth >= IIDDepth[PvNode] if ( depth >= IIDDepth[PvNode]
&& ttMove == MOVE_NONE && ttMove == MOVE_NONE
&& (PvNode || (!isCheck && ss->eval + IIDMargin >= beta))) && (PvNode || (!inCheck && ss->eval + IIDMargin >= beta)))
{ {
Depth d = (PvNode ? depth - 2 * ONE_PLY : depth / 2); Depth d = (PvNode ? depth - 2 * ONE_PLY : depth / 2);
@ -937,11 +937,11 @@ split_point_start: // At split points actual search starts from here
// At Root and at first iteration do a PV search on all the moves to score root moves // At Root and at first iteration do a PV search on all the moves to score root moves
isPvMove = (PvNode && moveCount <= (Root ? depth <= ONE_PLY ? 1000 : MultiPV : 1)); isPvMove = (PvNode && moveCount <= (Root ? depth <= ONE_PLY ? 1000 : MultiPV : 1));
moveIsCheck = pos.move_is_check(move, ci); givesCheck = pos.move_gives_check(move, ci);
captureOrPromotion = pos.move_is_capture_or_promotion(move); captureOrPromotion = pos.move_is_capture_or_promotion(move);
// Step 11. Decide the new search depth // Step 11. Decide the new search depth
ext = extension<PvNode>(pos, move, captureOrPromotion, moveIsCheck, &dangerous); ext = extension<PvNode>(pos, move, captureOrPromotion, givesCheck, &dangerous);
// Singular extension search. If all moves but one fail low on a search of // Singular extension search. If all moves but one fail low on a search of
// (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move // (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
@ -975,7 +975,7 @@ split_point_start: // At split points actual search starts from here
// Step 12. Futility pruning (is omitted in PV nodes) // Step 12. Futility pruning (is omitted in PV nodes)
if ( !PvNode if ( !PvNode
&& !captureOrPromotion && !captureOrPromotion
&& !isCheck && !inCheck
&& !dangerous && !dangerous
&& move != ttMove && move != ttMove
&& !move_is_castle(move)) && !move_is_castle(move))
@ -1035,7 +1035,7 @@ split_point_start: // At split points actual search starts from here
&& pos.see_sign(move) < 0; && pos.see_sign(move) < 0;
// Step 13. Make the move // Step 13. Make the move
pos.do_move(move, st, ci, moveIsCheck); pos.do_move(move, st, ci, givesCheck);
if (!SpNode && !captureOrPromotion) if (!SpNode && !captureOrPromotion)
movesSearched[playedMoveCount++] = move; movesSearched[playedMoveCount++] = move;
@ -1202,7 +1202,7 @@ split_point_start: // At split points actual search starts from here
// no legal moves, it must be mate or stalemate. // no legal moves, it must be mate or stalemate.
// If one move was excluded return fail low score. // If one move was excluded return fail low score.
if (!SpNode && !moveCount) if (!SpNode && !moveCount)
return excludedMove ? oldAlpha : isCheck ? value_mated_in(ss->ply) : VALUE_DRAW; return excludedMove ? oldAlpha : inCheck ? value_mated_in(ss->ply) : VALUE_DRAW;
// Step 20. Update tables // Step 20. Update tables
// If the search is not aborted, update the transposition table, // If the search is not aborted, update the transposition table,
@ -1257,7 +1257,7 @@ split_point_start: // At split points actual search starts from here
StateInfo st; StateInfo st;
Move ttMove, move; Move ttMove, move;
Value bestValue, value, evalMargin, futilityValue, futilityBase; Value bestValue, value, evalMargin, futilityValue, futilityBase;
bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable; bool inCheck, enoughMaterial, givesCheck, evasionPrunable;
const TTEntry* tte; const TTEntry* tte;
Depth ttDepth; Depth ttDepth;
Value oldAlpha = alpha; Value oldAlpha = alpha;
@ -1272,8 +1272,8 @@ split_point_start: // At split points actual search starts from here
// Decide whether or not to include checks, this fixes also the type of // Decide whether or not to include checks, this fixes also the type of
// TT entry depth that we are going to use. Note that in qsearch we use // TT entry depth that we are going to use. Note that in qsearch we use
// only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS. // only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS.
isCheck = pos.is_check(); inCheck = pos.in_check();
ttDepth = (isCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS); ttDepth = (inCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS);
// Transposition table lookup. At PV nodes, we don't use the TT for // Transposition table lookup. At PV nodes, we don't use the TT for
// pruning, but only for move ordering. // pruning, but only for move ordering.
@ -1287,7 +1287,7 @@ split_point_start: // At split points actual search starts from here
} }
// Evaluate the position statically // Evaluate the position statically
if (isCheck) if (inCheck)
{ {
bestValue = futilityBase = -VALUE_INFINITE; bestValue = futilityBase = -VALUE_INFINITE;
ss->eval = evalMargin = VALUE_NONE; ss->eval = evalMargin = VALUE_NONE;
@ -1337,12 +1337,12 @@ split_point_start: // At split points actual search starts from here
{ {
assert(move_is_ok(move)); assert(move_is_ok(move));
moveIsCheck = pos.move_is_check(move, ci); givesCheck = pos.move_gives_check(move, ci);
// Futility pruning // Futility pruning
if ( !PvNode if ( !PvNode
&& !isCheck && !inCheck
&& !moveIsCheck && !givesCheck
&& move != ttMove && move != ttMove
&& enoughMaterial && enoughMaterial
&& !move_is_promotion(move) && !move_is_promotion(move)
@ -1367,14 +1367,14 @@ split_point_start: // At split points actual search starts from here
} }
// Detect non-capture evasions that are candidate to be pruned // Detect non-capture evasions that are candidate to be pruned
evasionPrunable = isCheck evasionPrunable = inCheck
&& bestValue > VALUE_MATED_IN_PLY_MAX && bestValue > VALUE_MATED_IN_PLY_MAX
&& !pos.move_is_capture(move) && !pos.move_is_capture(move)
&& !pos.can_castle(pos.side_to_move()); && !pos.can_castle(pos.side_to_move());
// Don't search moves with negative SEE values // Don't search moves with negative SEE values
if ( !PvNode if ( !PvNode
&& (!isCheck || evasionPrunable) && (!inCheck || evasionPrunable)
&& move != ttMove && move != ttMove
&& !move_is_promotion(move) && !move_is_promotion(move)
&& pos.see_sign(move) < 0) && pos.see_sign(move) < 0)
@ -1382,8 +1382,8 @@ split_point_start: // At split points actual search starts from here
// Don't search useless checks // Don't search useless checks
if ( !PvNode if ( !PvNode
&& !isCheck && !inCheck
&& moveIsCheck && givesCheck
&& move != ttMove && move != ttMove
&& !pos.move_is_capture_or_promotion(move) && !pos.move_is_capture_or_promotion(move)
&& ss->eval + PawnValueMidgame / 4 < beta && ss->eval + PawnValueMidgame / 4 < beta
@ -1399,7 +1399,7 @@ split_point_start: // At split points actual search starts from here
ss->currentMove = move; ss->currentMove = move;
// Make and search the move // Make and search the move
pos.do_move(move, st, ci, moveIsCheck); pos.do_move(move, st, ci, givesCheck);
value = -qsearch<PvNode>(pos, ss+1, -beta, -alpha, depth-ONE_PLY); value = -qsearch<PvNode>(pos, ss+1, -beta, -alpha, depth-ONE_PLY);
pos.undo_move(move); pos.undo_move(move);
@ -1419,7 +1419,7 @@ split_point_start: // At split points actual search starts from here
// All legal moves have been searched. A special case: If we're in check // All legal moves have been searched. A special case: If we're in check
// and no legal moves were found, it is checkmate. // and no legal moves were found, it is checkmate.
if (isCheck && bestValue == -VALUE_INFINITE) if (inCheck && bestValue == -VALUE_INFINITE)
return value_mated_in(ss->ply); return value_mated_in(ss->ply);
// Update transposition table // Update transposition table
@ -1627,7 +1627,7 @@ split_point_start: // At split points actual search starts from here
assert(move_is_ok(m)); assert(move_is_ok(m));
assert(threat && move_is_ok(threat)); assert(threat && move_is_ok(threat));
assert(!pos.move_is_check(m)); assert(!pos.move_gives_check(m));
assert(!pos.move_is_capture_or_promotion(m)); assert(!pos.move_is_capture_or_promotion(m));
assert(!pos.move_is_passed_pawn_push(m)); assert(!pos.move_is_passed_pawn_push(m));
@ -2022,7 +2022,7 @@ split_point_start: // At split points actual search starts from here
// Don't overwrite existing correct entries // Don't overwrite existing correct entries
if (!tte || tte->move() != pv[ply]) if (!tte || tte->move() != pv[ply])
{ {
v = (pos.is_check() ? VALUE_NONE : evaluate(pos, m)); v = (pos.in_check() ? VALUE_NONE : evaluate(pos, m));
TT.store(k, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, pv[ply], v, m); TT.store(k, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, pv[ply], v, m);
} }
pos.do_move(pv[ply], *st++); pos.do_move(pv[ply], *st++);