X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=c0c26f038d5c5b4de7caa59d0a9e2f6a4041ce2c;hp=0a6c240cedc8eb010db1191ff0fcf07efafb379d;hb=20d6a8e57f55e586f5ab8b3bcb60bfe17c5f2708;hpb=42b48b08e81b55e385e55b3074b7c59d81809a45 diff --git a/src/position.cpp b/src/position.cpp index 0a6c240c..c0c26f03 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -641,7 +641,7 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const { return true; // Is there a discovered check? - if ( unlikely(ci.dcCandidates) + if ( ci.dcCandidates && (ci.dcCandidates & from) && !aligned(from, to, ci.ksq)) return true; @@ -870,7 +870,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI st->checkersBB |= to; // Discovered checks - if (unlikely(ci.dcCandidates) && (ci.dcCandidates & from)) + if (ci.dcCandidates && (ci.dcCandidates & from)) { if (pt != ROOK) st->checkersBB |= attacks_from(king_square(them)) & pieces(us, QUEEN, ROOK); @@ -1147,10 +1147,6 @@ bool Position::is_draw() const { /// Position::flip() flips position with the white and black sides reversed. This /// is only useful for debugging e.g. for finding evaluation symmetry bugs. -static char toggle_case(char c) { - return char(islower(c) ? toupper(c) : tolower(c)); -} - void Position::flip() { string f, token; @@ -1168,7 +1164,8 @@ void Position::flip() { ss >> token; // Castling availability f += token + " "; - std::transform(f.begin(), f.end(), f.begin(), toggle_case); + std::transform(f.begin(), f.end(), f.begin(), + [](char c) { return char(islower(c) ? toupper(c) : tolower(c)); }); ss >> token; // En passant square f += (token == "-" ? token : token.replace(1, 1, token[1] == '3' ? "6" : "3"));