The rook moves forward or back on the files through any number of squares without other pieces on them , and sideways on the ranks . This is shown in the diagram below .
The rook moves horizontally or vertically , forward or back , through any number of unoccupied squares , as shown in the diagram .