Move your king two squares toward the rook
Move the rook to the square the king crossed over
Make sure neither the king nor the chosen rook has moved before
Make sure there are no pieces between the king and the rook
Make sure the king is not in check
Make sure the king does not move through a square that is under attack
Make sure the king does not end up on a square that is under attack
Kingside castling uses the rook on the h-file
Queenside castling uses the rook on the a-file
