There are 2 types of castles.
- Castling King side: To Castle on the King side, there has to be no pieces obstructing the lane to the right, besides the rook on the king side corner. The King and Rook both have to be in an unmoved state, in meaning if either of the pieces are moved, you can not castle on that side. If the lane is unobstructed, the king can move 2 squares to the right, and move the Rook to the left of the king, and with the pawns in front of the king, it acts as a “Castle”.
An example is shown below:


2. Castling Queen side: Just as Castling on the King side, the Queen side is no different besides the distance. If the left side of the Kings lane is unobstructed, and both the King and the Queen side Rook haven’t moved, then a Castle can be executed: Similar steps to King side Castling, move 2 squares to the left, and put the Queen side Rook on the right side of the King.
An example is show below:


Rules on Castling:
- You cannot Castle when the King is in Check.
- You cannot Castle if it involved the King going through a Check.
- You cannot Castle King side if the King side Rook has moved, You cannot Castle Queen side if the Queen side Rook has moved, and you cannot castle either side if the King has moved.
- You cannot castle if there is a piece obstructing either side of the King.