X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=15ccb4835dbea166a6ae267d30e27056893734ac;hp=bc04d306815657a7944b4ad39b8efb133f9a32a8;hb=27efc5ac996ffc679395317c8bbb16aca996296c;hpb=0af24a14455bbcde181fff7632722ce55419991e diff --git a/src/position.cpp b/src/position.cpp index bc04d306..15ccb483 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -684,13 +684,7 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const { /// to a StateInfo object. The move is assumed to be legal. Pseudo-legal /// moves should be filtered out before this function is called. -void Position::do_move(Move m, StateInfo& newSt) { - - CheckInfo ci(*this); - do_move(m, newSt, ci, gives_check(m, ci)); -} - -void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool givesCheck) { +void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { assert(is_ok(m)); assert(&newSt != st); @@ -848,32 +842,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool gives // Update the key with the final value st->key = k; - // Update checkers bitboard: piece must be already moved due to attacks_from() - st->checkersBB = 0; - - if (givesCheck) - { - if (type_of(m) != NORMAL) - st->checkersBB = attackers_to(king_square(them)) & pieces(us); - else - { - // Direct checks - if (ci.checkSq[pt] & to) - st->checkersBB |= to; - - // Discovered checks - if (ci.dcCandidates && (ci.dcCandidates & from)) - { - assert(pt != QUEEN); - - if (pt != ROOK) - st->checkersBB |= attacks_from(king_square(them)) & pieces(us, QUEEN, ROOK); - - if (pt != BISHOP) - st->checkersBB |= attacks_from(king_square(them)) & pieces(us, QUEEN, BISHOP); - } - } - } + // Calculate checkers bitboard (if move gives check) + st->checkersBB = givesCheck ? attackers_to(king_square(them)) & pieces(us) : 0; sideToMove = ~sideToMove; @@ -1108,8 +1078,8 @@ Value Position::see(Move m) const { } -/// Position::is_draw() tests whether the position is drawn by material, 50 moves -/// rule or repetition. It does not detect stalemates. +/// Position::is_draw() tests whether the position is drawn by 50-move rule +/// or by repetition. It does not detect stalemates. bool Position::is_draw() const {