Mathematics and brainvita

In this post, I will analyse the single player game brainvita (also known as peg solitaire). The game is described by having a board with holes having the pattern:

Initially all holes except the central one are filled with pegs. The player may jump a peg horizontally or vertically over another peg into an empty hole. The jumped peg is then removed by the player. The objective is to finish the game with just one peg left.

The aim of this post is to show that there are (at most) $5$ ending board positions in brainvita. In other words, assuming the player wins, his last peg left on the board can be only among $5$ fixed board positions.

The proof uses abstract algebra. Suppose that the pegs correspond to coordinates in the plane in the natural fashion described below: The central peg is at $(0,0)$, and all others have integer coordinates as well. For convenience adjacent pegs may be taken a unit distance apart. Some coordinates are described below:

Now consider all possible ways of placing pegs on the board. There are $2^{33}$ of them. Many of these ways are impossible to reach in a valid game. Regardless of this fact, let $W$ be the set of all possible ways and for a given $w\in W$, let $C_w$ denote the set of all the coordinates where there is a peg in $w$. Now define a function $f:W\to \frac{\mathbb{Z}_2[x]}{(x^2+x+1)}$ by $f(w)=\sum_{(m,n)\in C_w}x^{m+n}$ where $\frac{\mathbb{Z}_2[x]}{(x^2+x+1)}$ is the finite field on $4$ elements. (If there are no pegs on the board we define $f$ to be $0$.)

The function $f$ has the property that for any given way $w$ of placing pegs on the board, if a legal move is performed to yield another way $w'$ then $f(w)=f(w')$. To see this, suppose that in the way $w$ there were pegs at $(m,n)$ and $(m+1,n)$ positions and the hole at the $(m+2,n)$ position was empty. A legal move may be performed by jumping the $(m,n)$ peg over the $(m+1,n)$ peg to yield a way $w'$ where the holes at $(m,n)$ and $(m+1,n)$ are empty and there is a peg at $(m+2,n)$. Clearly the only change between $f(w)$ and $f(w')$ occurs on account of these three coordinates and $f(w)-f(w')=x^{m+n}+x^{m+1+n}-x^{m+2+n}$. But as $x^{m+n}+x^{m+1+n}-x^{m+2+n}=x^{m+n}(1+x-x^2)=x^{m+n}.0=0$ in $\frac{\mathbb{Z}_2[x]}{(x^2+x+1)}$ so $f(w)-f(w')=0$ following which $f(w)=f(w')$. The same holds if instead of moving a peg to the right we had moved it above, below or to the left. Moreover all this is regardless of the fact whether the way $w$ can actually be reached by a valid sequence of moves in the game.

Now we define another function $g:W\to \frac{\mathbb{Z}_2[x]}{(x^2+x+1)}$ by $g(w)=\sum_{(m,n)\in C_w}x^{m-n}$ (the no pegs way means $g$ is $0$) and by a similar piece of reasoning conclude that $g$ also has the same property enjoyed by $f$. It is also easy to observe that both $f$ and $g$ are onto functions and so $f(W)\times g(W)$ has $16$ elements.

Next we partition the set $W$ as follows. Any $w\in W$ corresponds with a pair $(f(w),g(w))$ and so with exactly one among the $16$ elements of $f(W)\times g(W)$. In this way all the $2^{33}$ elements of $W$ are partitioned in $16$ parts. Further each part has the curious property that for any $w$ in that part, any sequence of legal moves will never change the value of $(f(w),g(w))$ and so the resultant $w'$ will also be in the same part. It is now obvious that among these $16$ parts one and only part consists of all the $w's$ which can actually occur in a game of brainvita. All other $w's$ correspond to ways which can never occur in a legal game.

What is the value of $(f(w),g(w))$ that this one special part corresponds to? The initial board (assuming it corresponds with $i\in W$) is set up so that $f(i)=g(i)=1$. So any way $w$ that arises during the game also has $f(w)=g(w)=1$. Assume now that the game has been successfully finished with a single peg at $(m,n)$, and that this corresponds to the way $w^*$. We therefore have $f(w^*)=g(w^*)=1$. But by definition $f(w^*)=x^{m+n}$ and $g(w^*)=x^{m-n}$. So we must have $x^{m+n}=1$. Since the multiplicative group $\{1,x,x^2\}$ is cyclic of order $3$ so as a consequence of Lagrange’s theorem we must have $3|(m+n)$. Similarly we have $3|(m-n)$. Combining these facts together we have $3$ dividing both $m$ and $n$. The only five coordinates which satisfy this condition are $(-3,0),(0,-3),(3,0),(0,3)$ and $(0,0)$. So the player has to end up at one among these $5$ positions. This completes the proof.

It should be noted that we have only found an upper bound on the number of positions the final peg can end up at. However by explicitly giving a sequence of moves for each of these $5$ coordinates it is possible to show that all these endings are indeed possible.

1 Comment

Filed under Algebra, Game Theory

One response to “Mathematics and brainvita”

1. This analysis is far more complicated than necessary. The same result can be obtained more quickly with no reference to group theory, field theory, or Lagrange’s theorem! See Beasley’s book or the web site:

http://home.comcast.net/~gibell/pegsolitaire/index.html#pre