28

The knight's tour problem is a famous problem in chess and computer science which asks the following question: can we move the knight on an $n \ \times \ n$ chessboard such that it visits every square exactly once? The answer is yes iff $n\geq5$. Additionally, there are algorithms which can solve it in $O(n^2)$ time.

I have two variations of it discussed below.

Fix an $n \ \times \ n$ chessboard. In this variant, instead of one knight we have $m$ knights. These knights take turns moving (ie., one knight moves, after that another one, once all of them have moved, the first one moves again and the cycle repeats itself).

What is the largest $m$ such that for some initial starting position, each knight can tour the board (as described in the first paragraph) without threatening any other knight? In other words, there is no "instance" of the chessboard in which one knight may capture another knight (e.g., knight $A$ cannot be, for example, two cells right and one cell up from another knight $B$ when it is his turn). Note that there is obviously an upper bound on $m$ (e.g., $n^2$).

In essence, I'm looking for a function $f:\mathbb{N}_{\geq 5} \to \mathbb{N}$ which assigns to each $n$ the largest possible $m$.

My second variation is exactly the same, except now there are no restrictions on the turns. After one knight moves, any knight can move, including the one that has moved prior. I do not know how these variations relate to each other; perhaps they are equivalent.

Also, as a function of $n$ what would the time complexity of an optimal algorithm be? Can either of these variants be solved in polynomial time?

2 Answers2

1

Sad to see so much 'interest' and so much strife...

For 'warm up', I suggest further relaxing the rules and allowing to declare the game over, when 'collectively' all places of the chessboard have been touched at least once from one knight. Put differently, we do not require a Hamiltonian path to exist.

Let's play with a few small cases $n<5$ (!) to get going.

n=1 is easy: $1\times (n,m,L)=(1,1,1)$
In only see one solution. Put one knight, done, i.e. m=1 and tour length L=n/m=1.

n=2 is easy: $24\times (n,m,L)=(2,4,1)$
Put four knights, done, i.e. m=4 and L=1, e.g.,
$\begin{array} {|r|r|}\hline A1 & B1 \\ \hline C1 & D1 \\ \hline \end{array} $
You can put A on 4 positions, then B on 3, etc, resulting in a total of 24 positions - suggest notation "$24\times$" for that.

n=3: $32\times (3, 2, 8)_2$, $??\times (3,4,3)_2$, $??\times (3,3,4)_2$
One solution is in the second variation (suggest notation "subscript 2" for that) with 2 knights and a tour of 8 steps $(3,2,8)_2$: One knight, A, at the center (can't move), the other one tours around with 8 steps, e.g.,
$\begin{array} {|r|r|}\hline B 1 & B 4 & B 7 \\ \hline B 6 & A 1-8 & B 2 \\ \hline B 3 & B 8 & B 5 \\ \hline \end{array}$.
It's a bit of a question on symmetry counting: varying starting positions and direction, I count 16 options for the second knight to start and move (left or right); allowing knight A and B to switch position gives another factor of 2.

Another solutions in the second variation exists with 4 knights (A, B, C and D); A at the center, a tour above split between 3 knights (total of 4) with maximally 3 steps $(3,4,3)_2$: B moves from B1 to B2, then C from C1 to C2, D from D1 to D2, then B from B2 to B3, C from C2 to C3; thus, L=3 and
$\begin{array} {|r|r|}\hline B 1 & C 1 & D 1 \\ \hline C 3 & A 1-8 & B 2 \\ \hline B 3 & D 2 & C 2 \\ \hline \end{array}$.
Again, there are a few options but that is a bit of a counting/ case nightmare... any volunteers?

Then, there is a $(3,3,4)_2$, e.g.,
$\begin{array} {|r|r|}\hline B 1 & B4 & C 3 \\ \hline C 2 & A 1-8 & B 2 \\ \hline B 3 & C 4 & C 1 \\ \hline \end{array}$.

Did I miss any other solutions?

n=4: $(4,2,8)$, $(4,4,4)$, $(4,8,2)$
There is no solution with one knight only; still, there is no Hamiltonian path.

There is an 8-step tour with 2 knights $(4,2,8)$, e.g.,
$\begin{array} {|r|r|}\hline A1 & & A7 & \\ \hline A8 & & A4 & \\ \hline & A2 & & A6 \\ \hline & A5 & & A3 \\ \hline \end{array}$
which can be run in parallel without threathening
$\begin{array} {|r|r|}\hline A1 & B5 & A7 & B3 \\ \hline A8 & B2 & A4 & B6 \\ \hline B8 & A2 & B4 & A6 \\ \hline B1 & A5 & B7 & A3 \\ \hline \end{array}$

The question is whether we can allow more knights do dance around each other...

This one should provide a $(4,4,4)$
$\begin{array} {|r|r|}\hline A1 & C2 & A3 & C4 \\ \hline B1 & D2 & B3 & D4 \\ \hline C1 & A2 & C3 & A4 \\ \hline D1 & B2 & D3 & B4 \\ \hline \end{array}$

There is $(4,8,2)$, if the sequence of the knights moving can be fixed and a threat is ok, as long as the threatened knight can still move away before being captured, e.g., A2 threatens E1 but E1 moves to E2 before A2 has another move
$\begin{array} {|r|r|}\hline A1 & C2 & E1 & G2 \\ \hline B1 & D2 & F1 & H2 \\ \hline C1 & A2 & G1 & E2 \\ \hline D1 & B2 & H1 & F2 \\ \hline \end{array}$

I'm quite sure there are more solutions. However

is there a (4,x>8,L)?


Now for n=5 and the original question on a maximal m requiring a full Hamiltonian path: $(5,3,9)_H$, ...

The 'standard' solution in the paper quoted above is
$\begin{array} {|r|r|}\hline A1 & A18 & A13 & A22 & A7 \\ \hline A12 & A23 & A8 & A19 & A14 \\ \hline A17 & A2 & A21 & A6 & A9 \\ \hline A24 & A11 & A4 & A15 & A20 \\ \hline A3 & A16 & A25 & A10 & A5 \\ \hline \end{array}$

This can be split into 3 segments (A1-8, B1-8, C1-9): $(5,3,9)_H$, if we extend the notation to this case with a "subscript H".
Splitting into 4 and 5 will not (!) work.

Does anybody have a solution in 4 segments? Or a different Hamiltonian path that allow 4 or 5 segments?

References

Michael T
  • 1,742
-2

For even $n$, $n \ge 6$, the answer is $m = n^2 - 1$ for both questions and the time is $O(n^2)$.

Obviously $m \le n^2 - 1$ is an upper bound, because at least one cell should be initially free. Let us see why it is reachable.

It is possible to construct a closed (cyclic) tour for one knight in the time of $O(n^2)$. The tour has additional property of symmetry, and the algo has property of good parallelization (i. e. it takes $O(1)$ on $n^2$ processors).

Let $C = v_1 v_2 \ldots v_n v_1$ be sequence of cells in such closed tour. Then we place the first knight into $v_n,$ the second one into $v_{n - 1}$, and so on, placing the last one, $m$th knight, into $v_2$. At the first turn the first knight moves to $v_1$, the second one moves to $v_n$, and so on, the last one moves to $v_3$. Then the first one moves to $v_2$ and so on and so on. Every knight walks through the entire tour.

For odd $n$ there is also a more tight upper bound: $m \le \frac{n^2 + 1}{2}$. It follows from a note that our graph is bipartite and has an odd order, so we should start every tour in the bigger part of graph (of $\frac{n^2 + 1}{2}$ cells). For the first question the upper bound is even less by $1$, because after the first turn all knights should be in the smaller part of graph (of $\frac{n^2 - 1}{2}$ cells).

May be some time later I'll investigate odd case more precisely.

Smylic
  • 8,098
  • 3
    This is clearly wrong. If $m=n^2 - 1$, each square except one will always be occupied by a knight. Some knights will obviously threaten each other. I think you misunderstood the problem. – MathematicsStudent1122 Dec 31 '16 at 14:18
  • 2
    @MathematicsStudent1122 to be honest, Symlic answered the question in the exact way I interpreted it. You might want to reword your question a bit. I took "threaten each other" to mean that, if we label all of the knights $K_1, K_2, K_3,\dots ,K_n$ then we start by moving $K_1$, which is "threatening" the other knights if it has no square to move to that doesn't attack another knight. Once we move $K_1$ we then focus on $K_2$, then $K_3$, and so forth, looping back to $K_1$ after $K_n$ until a full tour is made by all Knights. Symlic's answers suffices under this interpretation. – Brevan Ellefsen Jan 03 '17 at 02:27
  • @BrevanEllefsen Threatening doesn't mean that each square a knight can move to is occupied. Only one.

    In other words, if we enumerate each position on the board $x_1, x_2, x_3..x_n$ there is no position such that two knights are in cells in which one can capture the other (e.g., a knight $K_j$ cannot be in a cell two to the right and one up from some other knight $K_i$).

    No, I won't reword it because $13$ other people aren't confused. Your interpretation is just wrong. I think this is straightforward.

    – MathematicsStudent1122 Jan 03 '17 at 02:46
  • 1
    @MathematicsStudent1122 OK. You can do what you want. Let it be noted however, that the only answer you have interpreted the question the way I did. Moreover, clarity is never a bad thing. Moreover, upvotes are not equivalent to mutual understanding of all parts of a question - they simply show an interest in seeing answers to said question (I have often seen posts upvoted with 10+ votes that did not deserve a single vote). That being said, my comment wasn't meant to attack you in any way... I meant it to help you get an answer. The more clear a question, the more likely an answer. – Brevan Ellefsen Jan 03 '17 at 02:50
  • 2
    Plus, editing a question puts it in the recent question feed and you would have an excuse to do that were you to add the details you put in your comment. I repeat what my point is though - (potential) redundancy for the purpose of clarity ought to be encouraged – Brevan Ellefsen Jan 03 '17 at 02:52