Example 6 On an $n \times n(n \geqslant 2)$ chessboard, there is a chess piece in one of the small squares, which can only move one step to the right, up, or to the left-down in each step. For which positive integers $n$ can this chess piece start from the bottom-left square $A$ and visit each small square of the chessboard exactly once?

---

The translation maintains the original text's formatting and structure, including the example number, the problem statement, and the specific conditions provided.
As shown in Figure $5-2$, when $n=3k$ or $3k+1\left(k \in \mathbf{N}_{+}\right)$, the chess piece can start from the lower-left corner square $A$ of the chessboard and visit each square exactly once (the figure only shows the case for $k=3$, other cases are similar).

When $n=3k+2$, the rows of the chessboard are numbered from bottom to top as $0,1, \cdots, 3k+1$, and the columns are numbered from left to right as $0,1, \cdots, 3k+1$. Each small square is filled with a number equal to the sum of the row number and the column number of the square. If the chess piece can start from the lower-left corner square and visit each square exactly once, except for the initial square, the numbers in the remaining $(3k+2)^2-1$ small squares, arranged in the order the chess piece reaches them, form a sequence $a_1, a_2, \cdots, a_{(3k+2)^2-1}$. According to the rules of the chess piece's movement, we have
$$
a_{i+1}=\left\{\begin{array}{l}
a_{i}+1 \text { (the chess piece moves one step to the right or up), } \\
a_{i}-2 \text { (the chess piece moves one step to the left or down). }
\end{array}\right.
$$

That is, $a_{i+1} \equiv a_{i}+1(\bmod 3)$ (invariant), so for any $i\left(1 \leqslant i \leqslant(3k+2)^2-3\right)$, the three numbers $a_i, a_{i+1}, a_{i+2}$ include exactly one number divisible by 3, thus $a_1, a_2, \cdots, a_{(3k+2)^2-1}$ contain exactly $\frac{1}{3}\left[(3k+2)^2-1\right]=3k^2+4k+1$ terms divisible by 3. On the other hand, the number of small squares (excluding the initial square) filled with numbers divisible by 3 is equal to
$$
\begin{aligned}
& 4+7+10+\cdots+(3k+1)+3k+3(k-1)+\cdots+6+3 \\
= & \frac{1}{2} \cdot k(3k+5)+\frac{1}{2} \cdot k(3k+3)=k(3k+4)<3k^2+4k+1,
\end{aligned}
$$

which is a contradiction. Therefore, when $n=3k+2$, the chess piece cannot visit each square exactly once.
In summary, the required positive integers $n$ are $3k$ and $3k+1\left(k \in \mathbf{N}_{+}\right)$.