From 4dc7ba16191bd1ded7c8257afd2a3b9194cebca8 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Fri, 29 Apr 2011 16:26:48 +0200 Subject: [PATCH] Rename check related functions No functional change. Signed-off-by: Marco Costalba --- src/book.h | 1 - src/evaluate.cpp | 2 +- src/move.cpp | 4 ++-- src/movegen.cpp | 8 +++---- src/movepick.cpp | 6 ++--- src/position.cpp | 20 ++++++++--------- src/position.h | 8 +++---- src/search.cpp | 58 ++++++++++++++++++++++++------------------------ 8 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/book.h b/src/book.h index 55d212a8..ed68210f 100644 --- a/src/book.h +++ b/src/book.h @@ -68,5 +68,4 @@ private: template inline uint64_t Book::get_int() { return 256 * get_int() + bookFile.get(); } template<> inline uint64_t Book::get_int<1>() { return bookFile.get(); } - #endif // !defined(BOOK_H_INCLUDED) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 649842dc..c86af780 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -292,7 +292,7 @@ Value do_evaluate(const Position& pos, Value& margin) { assert(pos.is_ok()); 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 // in the position object (material + piece square tables). diff --git a/src/move.cpp b/src/move.cpp index ff0adbe5..da9e977d 100644 --- a/src/move.cpp +++ b/src/move.cpp @@ -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. StateInfo st; pos.do_move(m, st); - if (pos.is_check()) + if (pos.in_check()) san += pos.is_mate() ? "#" : "+"; pos.undo_move(m); diff --git a/src/movegen.cpp b/src/movegen.cpp index 64c6ac50..f38d4226 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -151,7 +151,7 @@ template MoveStack* generate(const Position& pos, MoveStack* mlist) { assert(pos.is_ok()); - assert(!pos.is_check()); + assert(!pos.in_check()); Color us = pos.side_to_move(); Bitboard target; @@ -202,7 +202,7 @@ template<> MoveStack* generate(const Position& pos, MoveStack* mlist) { assert(pos.is_ok()); - assert(!pos.is_check()); + assert(!pos.in_check()); Bitboard b, dc; Square from; @@ -243,7 +243,7 @@ template<> MoveStack* generate(const Position& pos, MoveStack* mlist) { assert(pos.is_ok()); - assert(pos.is_check()); + assert(pos.in_check()); Bitboard b, target; Square from, checksq; @@ -311,7 +311,7 @@ MoveStack* generate(const Position& pos, MoveStack* mlist) { assert(pos.is_ok()); - return pos.is_check() ? generate(pos, mlist) + return pos.in_check() ? generate(pos, mlist) : generate(pos, mlist); } diff --git a/src/movepick.cpp b/src/movepick.cpp index 8872e39f..d8c9fbbb 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -65,7 +65,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, 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; 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()); - if (p.is_check()) + if (p.in_check()) phasePtr = EvasionTable; else if (d >= DEPTH_QS_CHECKS) phasePtr = QsearchWithChecksTable; @@ -157,7 +157,7 @@ void MovePicker::go_next_phase() { return; case PH_EVASIONS: - assert(pos.is_check()); + assert(pos.in_check()); lastMove = generate(pos, moves); score_evasions(); return; diff --git a/src/position.cpp b/src/position.cpp index 9f9069cd..e71499ce 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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 { - assert(is_check()); + assert(in_check()); Color us = side_to_move(); Square from = move_from(m); @@ -750,18 +750,18 @@ bool Position::move_is_legal(const Move m, Bitboard pinned) const { return false; // 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(move_is_ok(m)); @@ -883,7 +883,7 @@ void Position::do_setup_move(Move m) { void Position::do_move(Move m, StateInfo& newSt) { 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) { @@ -1430,7 +1430,7 @@ void Position::undo_castle_move(Move m) { void Position::do_null_move(StateInfo& backupSt) { assert(is_ok()); - assert(!is_check()); + assert(!in_check()); // Back up the information necessary to undo the null move to the supplied // StateInfo object. @@ -1467,7 +1467,7 @@ void Position::do_null_move(StateInfo& backupSt) { void Position::undo_null_move() { assert(is_ok()); - assert(!is_check()); + assert(!in_check()); // Restore information from the our backup StateInfo object StateInfo* backupSt = st->previous; @@ -1798,7 +1798,7 @@ bool Position::is_draw() const { bool Position::is_mate() const { MoveStack moves[MAX_MOVES]; - return is_check() && generate(*this, moves) == moves; + return in_check() && generate(*this, moves) == moves; } diff --git a/src/position.h b/src/position.h index b811e8c6..de2afbfd 100644 --- a/src/position.h +++ b/src/position.h @@ -168,7 +168,7 @@ public: // Checking pieces and under check information Bitboard checkers() const; - bool is_check() const; + bool in_check() const; // Piece lists 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 move_is_legal(const Move m) const; bool move_is_legal(const Move m, Bitboard pinned) const; - bool move_is_check(Move m) const; - bool move_is_check(Move m, const CheckInfo& ci) const; + bool move_gives_check(Move m) const; + bool move_gives_check(Move m, const CheckInfo& ci) const; bool move_is_capture(Move m) const; bool move_is_capture_or_promotion(Move m) const; bool move_is_passed_pawn_push(Move m) const; @@ -454,7 +454,7 @@ inline Bitboard Position::checkers() const { return st->checkersBB; } -inline bool Position::is_check() const { +inline bool Position::in_check() const { return st->checkersBB != EmptyBoardBB; } diff --git a/src/search.cpp b/src/search.cpp index 1ae6b892..9cfd09e2 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -341,7 +341,7 @@ int64_t perft(Position& pos, Depth depth) { for (MoveStack* cur = mlist; cur != last; cur++) { 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); pos.undo_move(m); } @@ -512,7 +512,7 @@ namespace { if (Rml.size() == 0) { 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; return MOVE_NONE; @@ -681,14 +681,14 @@ namespace { ValueType vt; Value bestValue, value, oldAlpha; 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 threadID = pos.thread(); SplitPoint* sp = NULL; refinedValue = bestValue = value = -VALUE_INFINITE; oldAlpha = alpha; - isCheck = pos.is_check(); + inCheck = pos.in_check(); ss->ply = (ss-1)->ply + 1; // Used to send selDepth info to GUI @@ -753,7 +753,7 @@ namespace { } // Step 5. Evaluate the position statically and update parent's gain statistics - if (isCheck) + if (inCheck) ss->eval = ss->evalMargin = VALUE_NONE; else if (tte) { @@ -775,7 +775,7 @@ namespace { // Step 6. Razoring (is omitted in PV nodes) if ( !PvNode && depth < RazorDepth - && !isCheck + && !inCheck && refinedValue + razor_margin(depth) < beta && ttMove == MOVE_NONE && abs(beta) < VALUE_MATE_IN_PLY_MAX @@ -795,7 +795,7 @@ namespace { if ( !PvNode && !ss->skipNullMove && depth < RazorDepth - && !isCheck + && !inCheck && refinedValue - futility_margin(depth, 0) >= beta && abs(beta) < VALUE_MATE_IN_PLY_MAX && pos.non_pawn_material(pos.side_to_move())) @@ -805,7 +805,7 @@ namespace { if ( !PvNode && !ss->skipNullMove && depth > ONE_PLY - && !isCheck + && !inCheck && refinedValue >= beta && abs(beta) < VALUE_MATE_IN_PLY_MAX && pos.non_pawn_material(pos.side_to_move())) @@ -863,7 +863,7 @@ namespace { // Step 9. Internal iterative deepening if ( depth >= IIDDepth[PvNode] && ttMove == MOVE_NONE - && (PvNode || (!isCheck && ss->eval + IIDMargin >= beta))) + && (PvNode || (!inCheck && ss->eval + IIDMargin >= beta))) { 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 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); // Step 11. Decide the new search depth - ext = extension(pos, move, captureOrPromotion, moveIsCheck, &dangerous); + ext = extension(pos, move, captureOrPromotion, givesCheck, &dangerous); // 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 @@ -975,7 +975,7 @@ split_point_start: // At split points actual search starts from here // Step 12. Futility pruning (is omitted in PV nodes) if ( !PvNode && !captureOrPromotion - && !isCheck + && !inCheck && !dangerous && move != ttMove && !move_is_castle(move)) @@ -1035,7 +1035,7 @@ split_point_start: // At split points actual search starts from here && pos.see_sign(move) < 0; // Step 13. Make the move - pos.do_move(move, st, ci, moveIsCheck); + pos.do_move(move, st, ci, givesCheck); if (!SpNode && !captureOrPromotion) 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. // If one move was excluded return fail low score. 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 // 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; Move ttMove, move; Value bestValue, value, evalMargin, futilityValue, futilityBase; - bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable; + bool inCheck, enoughMaterial, givesCheck, evasionPrunable; const TTEntry* tte; Depth ttDepth; 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 // 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. - isCheck = pos.is_check(); - ttDepth = (isCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS); + inCheck = pos.in_check(); + 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 // 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 - if (isCheck) + if (inCheck) { bestValue = futilityBase = -VALUE_INFINITE; 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)); - moveIsCheck = pos.move_is_check(move, ci); + givesCheck = pos.move_gives_check(move, ci); // Futility pruning if ( !PvNode - && !isCheck - && !moveIsCheck + && !inCheck + && !givesCheck && move != ttMove && enoughMaterial && !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 - evasionPrunable = isCheck + evasionPrunable = inCheck && bestValue > VALUE_MATED_IN_PLY_MAX && !pos.move_is_capture(move) && !pos.can_castle(pos.side_to_move()); // Don't search moves with negative SEE values if ( !PvNode - && (!isCheck || evasionPrunable) + && (!inCheck || evasionPrunable) && move != ttMove && !move_is_promotion(move) && 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 if ( !PvNode - && !isCheck - && moveIsCheck + && !inCheck + && givesCheck && move != ttMove && !pos.move_is_capture_or_promotion(move) && ss->eval + PawnValueMidgame / 4 < beta @@ -1399,7 +1399,7 @@ split_point_start: // At split points actual search starts from here ss->currentMove = move; // Make and search the move - pos.do_move(move, st, ci, moveIsCheck); + pos.do_move(move, st, ci, givesCheck); value = -qsearch(pos, ss+1, -beta, -alpha, depth-ONE_PLY); 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 // 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); // Update transposition table @@ -1627,7 +1627,7 @@ split_point_start: // At split points actual search starts from here assert(move_is_ok(m)); 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_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 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); } pos.do_move(pv[ply], *st++); -- 2.39.2