2. Let
$$
X=\left\{\left(x_{1}, x_{2}, \cdots, x_{n}\right) \mid x_{1}, x_{2}, \cdots, x_{n} \in \mathbf{Z}\right\}
$$

be the set of all lattice points in $n$-dimensional space. For any two lattice points $A\left(x_{1}, x_{2}, \cdots, x_{n}\right)$ and $B\left(y_{1}, y_{2}, \cdots, y_{n}\right)$ in $X$, define their distance as
$$
|A-B|=\left|x_{1}-y_{1}\right|+\left|x_{2}-y_{2}\right|+\cdots+\left|x_{n}-y_{n}\right| .
$$

Find the minimum value of $r$ such that the points in $X$ can be $r$-colored, satisfying the following conditions:
(1) Any two points of the same color $A$ and $B$ satisfy
$$
|A-B| \geqslant 2 \text {; }
$$
(2) Any two points of the same color $A$ and $B$ satisfy
$$
|A-B| \geqslant 3 \text {. }
$$
(1) First, adjacent points must be of different colors, so $r \geqslant 2$.
Second, when $r=2$, for a grid point $A\left(x_{1}, x_{2}, \cdots, x_{n}\right)$, we call $f(A)=f\left(x_{1}, x_{2}, \cdots, x_{n}\right)=x_{1}+x_{2}+\cdots+x_{n}$ the characteristic value of $A$. The characteristic values of adjacent points have different parities. By coloring points with odd characteristic values red and the rest blue, the coloring requirement is met. Therefore, the minimum value of $r$ is 2.
(2) For $A \in X$, we call the set
$$
\Gamma(A)=\{P \in X|| P-A \mid \leqslant 1\}
$$
a cluster centered at $A$.
Consider a cluster centered at $A_{0}\left(x_{1}, x_{2}, \cdots, x_{n}\right)$, the other $2 n$ points are $A_{i}\left(x_{1}, x_{2}, \cdots, x_{i-1}, x_{i}+1, x_{i+1}, \cdots, x_{n}\right)$, $A_{n+i}\left(x_{1}, x_{2}, \cdots, x_{i-1}, x_{i}-1, x_{i+1}, \cdots, x_{n}\right) (1 \leqslant i \leqslant n)$. If the coloring meets the requirement, then these $2 n+1$ points are all of different colors. Hence, $r \geqslant 2 n+1$.

When $r=2 n+1$, for a grid point $A\left(x_{1}, x_{2}, \cdots, x_{n}\right)$, we call $f(A)=f\left(x_{1}, x_{2}, \cdots, x_{n}\right)=x_{1}+2 x_{2}+\cdots+n x_{n}$ the characteristic value of $A$. The characteristic values of the points in the cluster centered at $A$ are $f(A), f(A) \pm 1, f(A) \pm 2, \cdots, f(A) \pm n$, forming a complete residue system modulo $2 n+1$. By coloring points with characteristic values that have a remainder of $i (1 \leqslant i \leqslant 2 n+1)$ modulo $2 n+1$ the $i$-th color, no two points in any cluster will be the same color. Therefore, the minimum value of $r$ is $2 n+1$.