X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=8d4b9f4f3c53de66f382dee30529aa46986ae91e;hp=c0c26f038d5c5b4de7caa59d0a9e2f6a4041ce2c;hb=47a076810291cb7e9b9333e106f2aa9cd4c30c58;hpb=60c121f3b1ee7d5ced3435cc1718e4e6e6fd8383 diff --git a/src/position.cpp b/src/position.cpp index c0c26f03..8d4b9f4f 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -47,7 +47,7 @@ namespace Zobrist { Key exclusion; } -Key Position::exclusion_key() const { return st->key ^ Zobrist::exclusion;} +Key Position::exclusion_key() const { return st->key ^ Zobrist::exclusion; } namespace { @@ -1060,8 +1060,8 @@ Value Position::see(Move m) const { stm = color_of(piece_on(from)); occupied = pieces() ^ from; - // Castling moves are implemented as king capturing the rook so cannot be - // handled correctly. Simply return 0 that is always the correct value + // Castling moves are implemented as king capturing the rook so cannot + // be handled correctly. Simply return VALUE_ZERO that is always correct // unless in the rare case the rook ends up under attack. if (type_of(m) == CASTLING) return VALUE_ZERO; @@ -1098,21 +1098,11 @@ Value Position::see(Move m) const { // Locate and remove the next least valuable attacker captured = min_attacker(byTypeBB, to, stmAttackers, occupied, attackers); - - // Stop before processing a king capture - if (captured == KING) - { - if (stmAttackers == attackers) - ++slIndex; - - break; - } - stm = ~stm; stmAttackers = attackers & pieces(stm); ++slIndex; - } while (stmAttackers); + } while (stmAttackers && (captured != KING || (--slIndex, false))); // Stop before a king capture // Having built the swap list, we negamax through it to find the best // achievable score from the point of view of the side to move.