Enforcing rules for pieces' movement
Before we get these chess pieces to move on click of mouse, we need to know how many squares a given piece can move. We need to enforce rules for each of the chess pieces.
Prepare for Lift Off
Before we start coding the rules, let's quickly recap the rules of chess:
- King can move only one square in any direction: up, down, to the sides, and diagonally.
- Queen can move in any one straight direction: forward, backward, sideways, or diagonally; as far as possible as long as she does not move through any of her own pieces.
- Rook can move as far as it wants, but only forward, backward, and to the sides
- Bishop can move as far as it wants, but only diagonally.
- Knights are different from others. They must move two squares in ...