Under what conditions does the n-dimensional, infinite, unit-square-grid graph contain a Hamiltonian ray?
It is indeed possible to make such a path. For that you use the following theorem (you can prove it by induction).
In any $d_1\times d_2\times ... \times d_n$-grid ($n\geq 3$) where every $d_i$ is even (let's call such a graph an even block), there is a hamiltonian path between any corners of different color, in the $2$-coloring of the grid (like a chessboard). (Actually it is true for any pair of vertices of different colors and with only one single even dimension).
In particular, it is possible, starting from any corner, to finish at a corner in any face (but not at any corner).
There are $2n$ directions : $e_1$, $-e_1$,..., $e_n$,$-e_n$.
Now, you construct your path in this way :
- start with a hamiltonian path of the $2\times 2 \times.... 2$-grid. This path necessarily ends in a corner.
assume that you have a hamiltonian path of the $d_1\times d_2.... \times d_n$-grid ending in a corner.
extend your path by adding a block of even width in one of the n free directions of your corner and finishing in a corner. Let's call the chosen direction $e_k$. Let $e_\ell\neq -e_k$ be a direction. By choosing the right face for the extension, you will be able to extend in direction $e_\ell$ for the next step.
repeating the extension order : $e_1$, $e_2$,...,$e_n$, $-e_1$,....,$-e_n$, you will obtain your path.