## Nim Automaton

I mentor three PRIMES projects. One of them, with Joshua Xiong from Acton-Boxborough Regional High School, is devoted to impartial combinatorial games. We recently found a connection between these games and cellular automata. But first I need to remind you of the rules of Nim.

In the game of Nim there are several piles with counters. Two players take turns choosing a pile and removing several counters from it. A player loses when he or she who doesn’t have a turn. Nim is the most famous impartial combinatorial game and its strategy is well known. To win, you need to finish your move in a so called P-position. Nim P-positions are easy to calculate: Bitwise XOR the number of counters in all the piles, and if the result is zero then it’s a P-position.

The total number of counters in a P-position is even. So we calculated the sequence *a*(*n*): the number of P-positions in the game of Nim with three piles with the total number of counters equal to 2*n*. As soon as we got the sequence we plugged it into the OEIS, and voilà it was there: The sequence A130665 described the growth of the three branches of the Ulam-Warburton cellular automaton.

The first picture shows the automaton after 6 generations. The automaton consists of cells that never die and it grows like this: start with a square on a square grid. In the next generation the squares that share exactly one side with the living squares are born. At the end remove the Southern branch.

Everything fell into place. We immediately realized that the language of the automata gives us the right words to describe what we know about the game of Nim.

Now we want to describe the automaton related to any impartial combinatorial game. Again, the cells never die and the initial cells correspond to terminal P-positions. People who write programs for calculating P-positions will find a notion of the next generation very natural. Indeed, the program usually starts with the terminal P-positions: they are generation 0. Then we can proceed by induction. Suppose we have found P-positions up to generation *i*. Denote the positions that are one move away from generation *i* and earlier as *N _{i}*. Then the P-positions that do not belong to generation

*i*and earlier and from which all moves belong to

*N*are the P-positions from generation

_{i}*i*+ 1.

This description explains the generations, but it doesn’t explain who is the parent of a particular P-position. The parent-child relations are depicted as edges on the cellular automaton graph. The parent of position *P*_{1} from generation *i* + 1 is a P-position *P*_{2} in generation *i* that can be reached from *P*_{1} in the game.

The parent-child relationship in the game of Nim is especially easy to explain. A P-position *P*_{1} is a parent of a P-position *P*_{2} if *P*_{1} differs from *P*_{2} in exactly two piles and it has one fewer counter in each of these piles. For example, a P-position (1,3,5,7) has six parents, one of them is (1,3,4,6). In the game with thee piles a P-position always has exactly one parent.

A position in the game of Nim with three piles is naturally depicted as a triple of numbers, that is as a point in 3D. The picture below shows the Nim automaton in 3D at generation 6.

Our paper, *Nim Fractals*, about sequences enumerating P-positions and describing the automaton connection in more detail is posted at the arXiv:1405.5942. We give a different, but equivalent definition of a parent-child relationship there. A P-position *P*_{1} is a parent of *P*_{2} if there exists an optimal game such that *P*_{1} is achieved from *P*_{2} in exactly two moves in a game which takes the longest number of possible moves.

## Ron Fischman:

Dear Tanya:

I noticed that this game is highly theoretical, escaping completely a level of math that seems to trouble urban students. In my experience, in applied math, urban students got stuck on automatic issues like math facts and one-step algebra problems.

While I’ve been blogging for http://www.mathnook.com, I have been looking at the brain science behind automaticity of practice. In my latest post, I point out the role of the parietal sulcus in ridding the prefrontal cortex of the obligationto solve 7×8 every time: http://www.mathnook.com/blog/2014/07/23/prefrontal-cortex-should-not-be-bothered/. If you like this post, would you please link to it?

Thanks,

Ron Fischman

23 July 2014, 8:37 amcantorron@aol.com