Impartial games

Naming a game with a number

An octal code is a rule table compressed into an integer. It turns "which game" into something that can be counted through, which is how the family was swept — and how the games nobody can solve were found.

Assumes: Grundy sequences, and where they stop being predictable · Every impartial game is a Nim heap

A subtraction game is specified by a set: from a heap of any size, remove one of these amounts. That is enough to produce Grundy sequences with periods nobody would guess, and it is also a very small corner of what a heap game can be.

Widen it slightly. Allow a move to split what is left into two heaps as well as leaving one, and allow the rule to depend on how much was taken. The result is a family large enough that its members need names, and small enough that the names can be integers.

The octal game ·137, read out. An octal code is a rule table. The kth digit says what a player may do after taking k tokens from one heap: end that heap, leave one heap, or split the rest into two. Three bits, one digit, and the whole family of take-away games becomes something that can be listed and swept.
Fig. 1 The rule table of one game, written as three digits. Each digit answers, for one number of tokens taken, three yes-or-no questions: may the heap be finished off, may the rest be left as one heap, may the rest be split in two. Filled circles are the moves the code allows.

The code

A move in a take-and-break game does two things: it removes some tokens from one heap, and it leaves behind either nothing, or one heap, or two.

Number the possibilities. Taking exactly kk tokens and leaving nothing is possible only when the heap had exactly kk in it; call that option 1. Taking kk and leaving the remainder as a single heap is option 2. Taking kk and cutting the remainder into two non-empty heaps is option 4. Any combination of the three is a legal rule, and the sum of the ones allowed is a digit between 0 and 7.

Write one digit for each kk, in order, and the whole game is a numeral: d1d2d3d_1 d_2 d_3 \ldots, conventionally with a point after the first digit, so the game is ·137 or ·6 or ·007.

The point is not decoration and the digits are not a number in any arithmetic sense. They are a table, laid out so that the table can be indexed by an integer.

Nim, in this notation, is 333\cdot 333\ldots — every digit a 3, because from a heap of nn any kk may be taken, finishing the heap when k=nk = n and leaving one heap when k<nk < n.

Grundy values for octal game ·3333333333333333333333333333. The Grundy value of every heap size for a take-away game, computed by the mex rule. A period, if the figure marks one, was found by searching the computed sequence rather than assumed — and where no period is marked, none was found in the range drawn, which is not the same as there being none.
Fig. 2 Nim written as an octal game and evaluated by the mex rule with no knowledge that it is Nim. A heap of n comes out worth ∗n, which is the whole theory of Nim arriving as a special case of a rule table.

Two things about that strip are worth noticing before anything else. The first is that the value of a heap of nn is nn, which is the Sprague–Grundy theorem’s simplest instance and the reason Nim is the yardstick. The second is that the code had to be written out to twenty-eight digits to say so.

A code is a finite string, so the game it names always has a largest legal take. Nim proper is the limit of an infinite code, and every finite prefix of it is a bounded Nim — take at most twenty-eight — which is a different game with a different, periodic answer. Where a figure on this page shows Nim as an octal game, the code is long enough for the heaps drawn and no longer.

What the notation is for

The obvious objection to any naming scheme is that it does not do anything. This one does, and the reason is that an integer can be counted through.

The rules of a take-and-break game are exactly a digit string, so every such game with takes up to three is one of 83=5128^3 = 512 possibilities, and every one with takes up to four is one of 4,0964{,}096. A person can write a program that solves all of them, look at the results together, and notice which ones behave differently from the rest. That is not available for a family whose members are described in prose.

Richard Guy and Cedric Smith introduced the notation in 1956 for exactly this reason, and what came out of the sweep is the shape of the whole subject: nearly every code produces a Grundy sequence that eventually repeats, and a handful do not — or at least, have not yet.

What the sweep runs on each code is the mex rule and nothing else: a heap is worth the smallest non-negative integer that is not the value of one of its options. The code decides what the options are, and in a take-and-break game they include the nim-sums of split pairs as well as the smaller heaps. The rule is the same for every member of the family, which is what makes an enumeration meaningful rather than a list of unrelated calculations.

Most of what the sweep returns is familiar. The two-digit code 33\cdot 33 lets a token be taken singly or in pairs and never permits a split, so it is the subtraction game “take one or two” wearing a different name.

Grundy values for octal game ·33. The Grundy value of every heap size for a take-away game, computed by the mex rule. A period, if the figure marks one, was found by searching the computed sequence rather than assumed — and where no period is marked, none was found in the range drawn, which is not the same as there being none.
Fig. 3 The code ·33, evaluated by the same loop as everything else on this page and with no knowledge that it is a subtraction game. The values are the heap size modulo three, the period is three from the very first heap, and it holds through all 2,001 values computed. A quarter of the two-digit codes have no splitting bit anywhere in them and behave in this general way.

Splitting is what makes the family interesting rather than a relabelling of subtraction games. When a move cuts a heap into two, the position becomes a sum, and the value of the sum is the nim-sum of the parts. So the mex is taken over a set that includes exclusive-ors of earlier values, and those propagate irregularly in a way that plain subtraction never does.

A sequence that repeats

Dawson’s chess is the standard example, and it arrives from an unlikely direction.

Thomas Rayner Dawson published a chess problem in 1934: pawns on the third and fifth ranks, capturing compulsory, the player unable to move loses. Reduced to its combinatorial skeleton it becomes a heap game with code 137\cdot 137 — take one and end the heap, take two and leave one heap or nothing, take three and do anything at all.

The octal game ·007, read out. An octal code is a rule table. The kth digit says what a player may do after taking k tokens from one heap: end that heap, leave one heap, or split the rest into two. Three bits, one digit, and the whole family of take-away games becomes something that can be listed and swept.
Fig. 4 A different rule table. The first two digits are zero, so taking one or two tokens is not a move at all; only taking three is — and the three filled circles on that row say the digit permits everything, so the remainder may be finished off, left as one heap, or cut in two. The whole game is that one line.
Grundy values for octal game ·137. The Grundy value of every heap size for a take-away game, computed by the mex rule. A period, if the figure marks one, was found by searching the computed sequence rather than assumed — and where no period is marked, none was found in the range drawn, which is not the same as there being none.
Fig. 5 Dawson’s chess, evaluated. The values look disorderly for the first fifty heaps and then repeat with period 34 for as far as the computation was taken — two thousand values here, and the period was found by searching them rather than by being told where to look.

The sequence settles into a period of 34 starting from a heap of 52, and stays there through every value computed. That is worth being precise about, because a strip that shows twenty-six values and announces a period of 34 has not shown anything: the period was searched for in two thousand values, not in the two dozen drawn.

Searching only the visible range is a specific and easy mistake. A short window of any sequence has periods in it that are artefacts of where the window stopped. The search here is run over a sequence long enough that a coincidence would have to persist for sixty repetitions, and the figure prints how many values it looked at.

The sweep turns up something else about 137\cdot 137, and it is a fact about the names rather than about the game. The code 07\cdot 07 forbids taking one at all; its only move is to take two, and then end the heap, leave one heap, or split the rest in two. That is a different rule table by every reading of the digits. Its Grundy sequence is Dawson’s chess’s, moved one place to the right.

Grundy values for octal game ·07. The Grundy value of every heap size for a take-away game, computed by the mex rule. A period, if the figure marks one, was found by searching the computed sequence rather than assumed — and where no period is marked, none was found in the range drawn, which is not the same as there being none.
Fig. 6 The code ·07, drawn on the same scale as ·137 above. Every value here is the one ·137 gives for a heap one smaller, on all two thousand computed and with no exception — so the period is the same 34 and begins one heap later, at 53. Two rule tables that agree in no position at all — 0 against 1, then 7 against 3, and ·137 has a third digit ·07 does not — and one sequence between them.

That is worth more than a curiosity, because it is the first thing the notation costs. An integer names a rule table, not a game, and nothing in the numeral says whether two tables produce the same answers. A sweep of the 512 three-digit codes is a sweep of 512 names; how many distinct games sit underneath them is a further question, and the notation gives no way of asking it.

One bit of the code decides which family a game is in

The notation’s real payoff is not that games can be counted through. It is that the thing making them hard is a single bit, and the code puts it where a reader can see it.

Each digit is three bits: 1 for finishing the heap, 2 for leaving one heap, 4 for splitting into two. Only the third does anything to the theory.

A code with no digit of 4 or more is a subtraction game. Without the splitting bit no move ever produces two heaps, so a heap’s value depends on a fixed window of the values below it, the pigeonhole applies, and eventual periodicity is a theorem.

A code with a 4 bit anywhere is a conjecture. Splitting makes the option set include nim-sums of pairs drawn from anywhere below, so there is no window of fixed width to pigeonhole and no bound on how large the values can get.

That is the whole boundary between what is proved and what has been computed for seventy years, and it is one bit per digit.

Which says how much of the family is settled

Counting that is immediate and the numbers are worth having, because they say something the prose version does not.

A digit is one of eight values, and four of them — 0,1,2,30, 1, 2, 3 — have the splitting bit clear. So among the 83=5128^3 = 512 codes of three digits, exactly 43=644^3 = 64 are subtraction games and settled by theorem. One code in eight.

And the share is not constant. For codes of nn digits it is 4n/8n=2n4^n / 8^n = 2^{-n}: half of the one-digit codes, a quarter of the two-digit ones, an eighth at three digits, a sixteenth at four. The proved fraction halves with every digit added, because each new digit is another chance for the splitting bit to be set.

So the honest summary of the family is not that a handful of awkward codes resist. It is that the theorem covers a share of the family that goes to nothing as the codes lengthen, and everything else is evidence — nearly every computed sequence repeats, and nobody has an argument that covers even one code with a 4 in it.

And the notation is what makes that sayable. A family described in prose has no denominator: “some take-and-break games are settled” is a sentence with no count in it. A family whose members are digit strings has 8n8^n of them, a proved subset of 4n4^n, and a ratio that can be written down and watched shrink. That is the naming scheme earning its place — not by making the games countable, but by making the boundary between the proved and the open into an arithmetic property of the name.

Where the difficulty enters

The contrast is sharpest when two codes differ by a single bit, and the sweep supplies the pair. Take 33\cdot 33 from earlier in this essay — take one or two, never split — and set the splitting bit on its second digit. The code becomes 37\cdot 37, and the only rule that has changed is that a take of two may now cut the remainder in two instead of leaving it whole.

Grundy values for octal game ·37. The Grundy value of every heap size for a take-away game, computed by the mex rule. A period, if the figure marks one, was found by searching the computed sequence rather than assumed — and where no period is marked, none was found in the range drawn, which is not the same as there being none.
Fig. 7 The code ·37: ·33 with one bit added. The first twenty-five values look nearly as orderly as ·33’s, and the annotation underneath is the whole of the figure — no period anywhere in the 2,001 values computed. Over that range these values reach 64, where ·33 never exceeds 2, and the losing heaps thin from one in three to thirteen in two thousand.

A subtraction game’s value at nn depends on a fixed window of earlier values and nothing else. That is a strong structural constraint and it is the whole of what the pigeonhole proof consumes. 33\cdot 33 has it and 37\cdot 37 does not, and the difference between them is one bit in one digit.

The growth is the part worth staring at. 33\cdot 33’s alphabet is three symbols and stays three symbols for ever. 37\cdot 37’s largest value is 8 by heap 100, 17 by heap 500, 32 by heap 1,000 and 64 by heap 2,000 — doubling as the range doubles, in a game whose rule fits in a line. Nothing in the code separates the two beyond the bit, and nothing in the two dozen values a strip can hold separates them either.

Add the splitting bit and the window argument collapses. The value at nn now depends on exclusive-ors of pairs drawn from everything below it, and no bounded amount of recent history determines what comes next. Every difficulty in this essay traces to that one digit.

The conjecture, and the games that resist it

Every subtraction game is eventually periodic, and that is a theorem rather than an observation: with a largest take of ss, the value of a heap is determined by the previous ss values, there are finitely many possible windows, and so a window must eventually recur and the sequence repeat from there.

The same argument does not work once splitting is allowed. A split makes the value of a heap depend on nim-sums of pairs of earlier values, and no bounded window determines what comes next. The pigeonhole argument has nothing to be applied to.

What replaces it is a conjecture — Guy’s — that every finite octal game is eventually periodic anyway. It has been checked against thousands of codes and holds in every case where anybody has been able to run the computation far enough, and it has never been proved.

Grundy values for octal game ·007. The Grundy value of every heap size for a take-away game, computed by the mex rule. A period, if the figure marks one, was found by searching the computed sequence rather than assumed — and where no period is marked, none was found in the range drawn, which is not the same as there being none.
Fig. 8 The same machinery on the code ·007. No period appears in the two thousand values computed here, which does not mean there is none — it means that if there is one, it starts further out or runs longer than this computation reached.

The code 007\cdot 007 is the best-known of the resistant cases. Taking one or two is illegal, and the only take is three — after which the remainder may be finished, left whole, or cut in two, since the digit is a 7 and carries all three bits. It is about as simple as a rule can get, and its Grundy sequence has been computed to a length that makes the figures on this page look like a rounding error, by people who made a project of it — and no period has appeared.

What the figure above claims is therefore carefully small. It does not say 007\cdot 007 is aperiodic; nobody knows that, and the conjecture says it is not. It says no period exists in the first two thousand values, which is a fact about a computation this page ran.

What the solver computed, and how

Every strip on this page comes out of one loop, and it is worth writing down because its shape explains why the family is hard.

For a heap of nn, the set of option values is assembled by running over each legal take kk and reading the digit dkd_k. Bit 1 contributes the value 00, but only when k=nk = n. Bit 2 contributes g(nk)g(n-k), the value already computed for the smaller heap. Bit 4 contributes g(a)g(nka)g(a) \oplus g(n-k-a) for every way of splitting the remainder into aa and nkan-k-a. The value g(n)g(n) is the mex of everything collected.

The splits are the expensive part and the irregular part. Each one reaches back into two earlier values at once and combines them with exclusive-or, so a single unusual value early in the sequence propagates forward into arbitrarily distant sums rather than washing out.

The period search is separate and deliberately dumb: for each starting index and each candidate length, check whether the sequence agrees with itself shifted by that length, all the way to the end of what was computed. It returns the first pair that survives, and nothing else. It has no model of what a period ought to look like and cannot be talked into one.

Both halves are given something they must refuse. The period search is handed a sequence that repeats by construction and has to find the period; it is separately handed 007\cdot 007 and has to come back empty. A search that only ever said yes would make every strip on this page worthless.

Where the model stops

A code is not a game with unbounded takes. Every claim here is about a finite digit string. Nim is not an octal game; each of its finite approximations is, and they are periodic for reasons Nim is not.

Eventual periodicity is not periodicity. Dawson’s chess is irregular for fifty-two heaps before it settles. A game can be arbitrarily badly behaved for arbitrarily long and still fall into a period afterwards, so a strip that looks disorderly proves nothing about what follows it.

The theory here is normal play only. Every value on this page is a Grundy value, and Grundy values describe misère play not at all. The same code under the misère convention needs a completely different apparatus, and that apparatus is not a sequence of integers.

Splitting is where the family gets its difficulty, and its usefulness. A game whose codes are all 1s and 2s is a subtraction game with extra steps. The moment a 4 appears the position stops being a single heap and becomes a sum, and that is both why the values are interesting and why nobody can prove anything about them.

The generalisation, and its price

Octal codes extend. Hexadecimal codes allow a move to leave three heaps; “all-but” codes allow a move to take from every heap at once. Each extension names a wider family with a longer string, and each makes the sequences harder rather than easier.

There is a general lesson in the failure, and it is not about games. A naming scheme that turns a family into an enumeration is enormously productive — it produced the whole catalogue of small games and it found the exceptions — and it produces no proofs. Knowing that 007\cdot 007 has no period in the first billion values is knowing something about a billion integers. It is not knowing anything about the billion-and-first.

The subject has learned to live with that. The tables of octal games in Winning Ways mark the periodic ones with their periods and the resistant ones with a question mark, and the question marks have been there since 1982.

There is a second lesson, which is about what a hard case looks like. Nothing distinguishes 007\cdot 007 from its neighbours by inspection. It is not longer, not stranger, not built from any unusual ingredient — it is three digits, two of which are zero. Difficulty in this family is not visible in the description of a game, only in what happens when the rule is run, which is the same reason an exact evaluator runs out of room so quickly on positions that look small.

Who found it, and when

Guy and Smith’s paper of 1956 introduced both the notation and the periodicity question, and it is a striking piece of work: it is essentially a survey of a family that did not exist as a family until the paper named it.

Dawson’s problem is from 1934 and the connection to the heap game was not made for two decades. That gap is typical of the subject. The games came first, as puzzles and problems, and the framework that showed them to be the same object came much later.

The large computations on the resistant codes are recent and are a different kind of work: hundreds of processor-years spent producing evidence for a conjecture that a single proof would settle permanently.

The ladder from here

This anchor started with a Grundy sequence and a period, which is the first time a heap game does something a player would not have predicted. This rung generalises the game so far that the periodicity stops being provable, and finds that it seems to happen anyway.

Later rungs: the sparse-space games, where the values are mostly zero and the exceptions are what matter. Hexadecimal games and what a third heap costs, where a sequence can repeat with a constant added rather than repeat. The reduction of a real board game to a code, which is where Dawson’s chess came from and where several others have since. And the misère side of the same codes, which is a different subject with the same rules.

The thing to carry forward is the shape of the evidence. Every figure on this page is a computation with its range printed on it, because the difference between “no period in two thousand values” and “no period” is the entire content of the open question.

Part 3 of 2

One argument about Grundy sequences. The parts either side of it:

What links here

Essays that reach for this one mid-argument — the half of a link its own author cannot write down, the 8 sharing most with it of 25.

What this makes readable

Essays that declare this one a prerequisite.

The objects named here

The third axis, after the field and the series: the games, values and theorems themselves, and every essay that touches each one.

Eventual periodicityMexMisère playNimOctal codePeriodicityRule tableSubtraction gameTake-and-breakUnsolved game