X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmovegen.cpp;h=eb65e7b9f18977dc1bcb9f730aab1e175ced4d61;hb=6cf28d4aa733447373430708fd2c35dee4469b10;hp=079918e96279ddaab10a35ac4e533c87e0180cf1;hpb=3849beb979ee17f027d83bbc15d1da85175b9798;p=stockfish diff --git a/src/movegen.cpp b/src/movegen.cpp index 079918e9..eb65e7b9 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -567,6 +567,29 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) { } +/// Another version of move_is_legal(), which takes only a position and a move +/// as input. This function does not require that the side to move is not in +/// check. It is not optimized for speed, and is only used for verifying move +/// legality when building a PV from the transposition table. + +bool move_is_legal(const Position& pos, const Move m) { + + Bitboard pinned = pos.pinned_pieces(pos.side_to_move()); + if (!pos.is_check()) + return move_is_legal(pos, m, pinned); + else + { + Position p(pos); + MoveStack moves[64]; + int n = generate_evasions(p, moves, pinned); + for (int i = 0; i < n; i++) + if (moves[i].move == m) + return true; + return false; + } +} + + namespace { template