Closed Starlight-30036225 closed 9 months ago
My first thought for a solution was to save the piece or pieces that are putting the king in check, then check back only on them after a move is simulated. However, it is not that simple.
In the diagram above, the white king is in check by the black bishop. If the player were to move the pawn to block the check, it would open up the king to attack from the rook.
This is not a simple problem.
The smaller problem described above could be fixed if I fix another oversight. Ill open a new issue.
This problem is completely sorted here:
This is likely to be the most complicated issue I am going to come across throughout this whole development.
Moving while in check is a difficult problem as the possible moves are greatly limited. A player in check is only allowed to make moves that will result in them no longer being in check. If this is not possible, then its a checkmate. But this is going to require simulating every possible move, then check if the king is still in check.