TITLE: What is the period of Langton's ant on a torus?
QUESTION [38 upvotes]: Langton's ant runs on an infinite white grid. At every white square, it turns right, flips the color of the square, and moves forward one square. At every black square, it turns left, flips the color of the square, and moves forward one square. After many interations, you get complex emergent behavior, such as "recurrent highways" starting at step ~10,000.
Let's suppose that Langton's ant awakens instead on a torus of size $n \times n$. It follows its two rules, thus changing the coloring of the torus. At some point, however, it encounters a colouration it has seen before, while being in the same spot as before, and finds itself in a cycle. How do we find the length of a cycle for a size $n$ torus, and is this result known? We can get a stupid upper bound by observing that there are at most $2^{n^2}$ colorings, $n^2$ positions, and $4$ orientations, so a cycle cannot be longer than $2^{n^2+2}n^2$. Is there a closed form for this, or at least some tighter bounds?

EDIT 1
I ran some quick calculations just to get a feel for the magnitudes of the numbers1. Here's an animation of Langton's ant on a $3 \times 3$ torus, where the cycle takes 22 steps: 
Some more results I got are:
$$\begin{matrix}
\text{Size} & \text{Steps} & \text{Factorization}\\
\hline
1 & 2 & 2\\
2 & 8 & 2^3\\ 
3 & 66 & 2 \cdot 3 \cdot 11\\ 
4 & 96 & 2^5 \cdot 3\\ 
5 & 11,710 & 2 \cdot 5 \cdot 1171\\ 
6 & 4,592 & 2^4 \cdot 7 \cdot 41\\ 
7 & 64,165,598 & 2 \cdot 7^2 \cdot 31 \cdot 21121\\ 
8 & 11,502,464 & 2^7 \cdot 73 \cdot 1231\\ 
9 & 919,057,222,998 & 2 \cdot 3^2 \cdot 51058734611 \\
10 & 150,192,928,160 & 2^{5}\cdot5\cdot11\cdot85336891 \\
11 & >5.7 \cdot 10^{11} & \\
12 & >5.6 \cdot 10^{11} & \\
\end{matrix}$$
The values for $n=9$ and $10$ are due to Connor Harris.
This does not, to my knowledge, match any sequence in OEIS.

EDIT 2
The only real pattern I've found thus far is in the prime factorizations—for odd-sized tori, there is (so far) exactly one factor of 2 in the factorization. However, in even-sized tori, the factors of 2 have multiplicities 3, 5, 4, and 7, which seems interesting. Is there any reason to believe this pattern holds for all even/odd-sized periods?

Footnotes
1: as per Connor Harris's comment, I only checked until the initial state reappeared (i.e., the torus became blank).
2: using Connor Harris's definition of a quasi-cycle as the amount of time it takes to get back to a blank (or full) grid.

REPLY [3 votes]: I've figured out some lower bounds for the number of factors of 2 in the period. This applies to any configuration, not just the all-white one.
It's more convenient if we say that at each time step, the ant is located at the middle of an edge, facing the center of one cell or the other.
Every step flips the color of one cell, so each cell is visited an even number of times, which means the period has to be divisible by 2.
Now consider a torus with an even number of columns. Separate the cells into two sets according to their horizontal coordinate modulo 2. Assume that the ant is pointing horizontally towards a cell in column $i$. In the next two steps, there are four possibilities for its path, but all of them visit two cells in column $i$, and afterwards the ant is horizontal again and pointing towards column $i-1$ or $i+1$. So every path visits two even cells, followed by two odd cells, then two even, two odd, and so on. That means that the period is divisible by 4.
Now let's examine a torus that is even in both directions. Put the cells into four equivalence classes by their coordinates modulo 2. The ant always travels through all four classes in a repeating cycle, either $(0,0), (0,1), (1,1), (1,0)$ or the reverse. To return to the same state, each class must be visited an even number of times, and each class is visited the same number of times, so the period is divisible by 8.
2019-08-23: There's a conservation law we can use. Choose any row. Add up the number of black squares modulo $2$. If the ant is located inside the row, pointed left or right towards one cell in the row, add another $1$ to the total. This value will always stay the same. (Consider three cases: the ant enters the row, the ant leaves the row, and the ant visits a cell not in the row.) This also works for columns.
If you add the values for all rows and columns, each black cell gets counted twice, and the ant is counted exactly once, so you always get $1$. That means that once you know the values for all lines but one, you know the value for the last one. We can use this fact to divide the states for an $m$ by $n$ torus into $2^{m+n-1}$ classes of equal size. This gives a loose upper bound of $m n 2^{(m-1)(n-1)+2}$ for the period. If both $m$ and $n$ are even, then the ant can never visit the same location pointed in opposite directions. In this case, each class can be divided in half, and the period upper bound is also halved.
In the original state, all columns have value $0$, except for the column with the ant. The same is true for a quasi-recurrence, so the ant has to be in its initial column. This explains Connor Harris's observation.