- MoveStack moves[MOVES_MAX];
- return is_check() && (generate_moves(*this, moves) == moves);
-}
-
-
-/// Position::has_mate_threat() tests whether the side to move is under
-/// a threat of being mated in one from the current position.
-
-bool Position::has_mate_threat() {
-
- MoveStack mlist[MOVES_MAX], *last, *cur;
- StateInfo st1, st2;
- bool mateFound = false;
-
- // If we are under check it's up to evasions to do the job
- if (is_check())
- return false;
-
- // First pass the move to our opponent doing a null move
- do_null_move(st1);
-
- // Then generate pseudo-legal moves that give check
- last = generate_non_capture_checks(*this, mlist);
- last = generate_captures(*this, last);
-
- // Loop through the moves, and see if one of them gives mate
- Bitboard pinned = pinned_pieces(sideToMove);
- CheckInfo ci(*this);
- for (cur = mlist; cur != last && !mateFound; cur++)
- {
- Move move = cur->move;
- if ( !pl_move_is_legal(move, pinned)
- || !move_is_check(move, ci))
- continue;
-
- do_move(move, st2, ci, true);
-
- if (is_mate())
- mateFound = true;
-
- undo_move(move);
- }
-
- undo_null_move();
- return mateFound;