In my chess engine, I'm attempting to create a strictly legal move generator, instead of generating pseduo-legal moves, then discarding them later in the search and evaluation phase.
So far, here is my planned approach:
- Remove pinned pieces from the board
- If the king is in check
- Generate possible moves from the check evasion function
- Generate possible moves for pinned pieces
- Generate possible moves for non-pinned pieces
The only part of this algorithm that I don't quite understand how to implement is the check evasion move generator. As I understand it, there are three ways of evading a check:
- Capture the checking piece
- Block the checking piece
- Move the king
Now although I understand these three cases, I'm having a hard time trying to think of a way to implement them concretely and efficiently. What strategies are usually taken in creating a check evasion function? Also note, I'm working with bitboards.