Given a $ n \times n$ grid board . How many ways can an $X$ and an $O$ be placed  in such a way that they are not in adjacent squares?
1. **Total number of ways to place X and O on the grid:**
   - There are \( n^2 \) squares on an \( n \times n \) grid.
   - We can place X in any of the \( n^2 \) squares.
   - After placing X, there are \( n^2 - 1 \) remaining squares where we can place O.
   - Therefore, the total number of ways to place X and O on the grid is:
     \[
     n^2 \times (n^2 - 1)
     \]

2. **Number of ways to place X and O such that they are adjacent:**
   - We need to count the number of pairs of adjacent squares on the grid.
   - Each square has up to 4 adjacent squares (left, right, above, below), except for edge and corner squares.
   - For an \( n \times n \) grid:
     - Corner squares (4 corners) each have 2 adjacent squares.
     - Edge squares (excluding corners) each have 3 adjacent squares. There are \( 4(n-2) \) such squares.
     - Interior squares each have 4 adjacent squares. There are \( (n-2)^2 \) such squares.
   - Therefore, the total number of adjacent pairs is:
     \[
     4 \times 2 + 4(n-2) \times 3 + (n-2)^2 \times 4
     \]
     Simplifying this expression:
     \[
     8 + 12(n-2) + 4(n-2)^2
     \]
     \[
     8 + 12n - 24 + 4n^2 - 16n + 16
     \]
     \[
     4n^2 - 4n
     \]
   - Each pair is counted twice (once for each square in the pair), so we divide by 2:
     \[
     \frac{4n^2 - 4n}{2} = 2n^2 - 2n
     \]

3. **Number of ways to place X and O such that they are not adjacent:**
   - Subtract the number of adjacent placements from the total number of placements:
     \[
     n^2 \times (n^2 - 1) - (2n^2 - 2n)
     \]
     Simplifying this expression:
     \[
     n^4 - n^2 - 2n^2 + 2n
     \]
     \[
     n^4 - 3n^2 + 2n
     \]

The final answer is \(\boxed{n^4 - 3n^2 + 2n}\)