Before we allow chess pieces to move, we must have a record of all the possible movement options on the chessboard. At every move, we also need to check whether it is a legitimate turn for a given player and the proposed move should not cause check on the current player's king.
Now, check may occur on the king not only from a chess piece that was moved, but from any other chess piece on the chessboard as a consequence of such a movement. Thus, after every move, we need to calculate the possible moves for all the chess pieces of the opponent.
Accordingly, we will need two methods to do the following:
- Keep a track of all the available moves for a player
- Check whether there is check on the king
Let's add ...