Castling

Castling is a defensive move in the game of chess whereby the king retreats to one or the side of the board by switching sides with one of its rooks.

The following must all be true in order to permit the move of castling:

* neither the king or the corresponding rook have ever moved
* the king is not currently in check
* the king does not cross over or land on any square which would put it in check
* neither the king nor the rook cross over any other pieces

The goal of castling is to fortify one's defenses, while also opening up attack possibilities for the rook involved. Castling early in a chess game is a standard move to improve one's long-term position in the match.