X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=ec4fa14e8692fc5cddcd0dc026358625f7821d7d;hb=ad0fdf0da6d9fdc38a5ceb96eeed0d79c8e38dc9;hp=9f9069cdf67c318264353bb73e5f9d0d317c6627;hpb=321320b0814d5994640977cf96e015eba8ce22d5;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index 9f9069cd..ec4fa14e 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; @@ -1490,12 +1490,6 @@ void Position::undo_null_move() { /// move, and one which takes a 'from' and a 'to' square. The function does /// not yet understand promotions captures. -int Position::see(Move m) const { - - assert(move_is_ok(m)); - return see(move_from(m), move_to(m)); -} - int Position::see_sign(Move m) const { assert(move_is_ok(m)); @@ -1509,19 +1503,21 @@ int Position::see_sign(Move m) const { if (midgame_value_of_piece_on(to) >= midgame_value_of_piece_on(from)) return 1; - return see(from, to); + return see(m); } -int Position::see(Square from, Square to) const { +int Position::see(Move m) const { + Square from, to; Bitboard occupied, attackers, stmAttackers, b; int swapList[32], slIndex = 1; PieceType capturedType, pt; Color stm; - assert(square_is_ok(from)); - assert(square_is_ok(to)); + assert(move_is_ok(m)); + from = move_from(m); + to = move_to(m); capturedType = type_of_piece_on(to); // King cannot be recaptured @@ -1798,7 +1794,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; }