A list of shapes is an endgame table
Assumes: Cram is played in pieces, and the pieces are small · A catalogue that knows what it will meet
Cram is played in pieces split every position reachable on a Cram board into the regions no domino can cross, and found that the board’s value is the exclusive-or of the regions’ values on every one of the 58,830 positions of a 4 × 5 board. That makes the object a solver needs a catalogue of shapes rather than a table of boards: 2,304 shapes on 4 × 5, 16,457 on 5 × 5, each a small Nim heap, two in five worth nothing.
A complete catalogue is exact and large. The question left was how much of it is needed to be usually right — the measurement a catalogue that knows what it will meet made for Domineering, where eight shapes ordered by how often they occur answer half the regions a played board produces and 2,018 answer nine tenths. Cram has two things Domineering lacks: a quarter-turn symmetry that merges shapes, and values that are single small integers with a large share of zeros. Both suggest it should concentrate harder.
By piece, it does, dramatically. By whole position, it does not, and the reason turns the catalogue into something with a familiar name. A short list of shapes is not a cheap solver for Cram. It is an endgame table, and the game is solved by searching forward until the list can take over.
Two shapes are half of everything
Order the shapes of a board by how often they occur among the pieces of its reachable positions, and count how much of the total the first K cover.
The first entry is the lone square, a third of all pieces on both boards. It is the dead space every Cram position accumulates: a free square no domino can reach, worth nothing, and recognised as such without looking anything up, since a solver can see that it has no neighbour. The second is the two-square slot, worth , which is the last move of countless games in waiting. Together they are 56 per cent of all pieces on 4 × 5 and 55 per cent on 5 × 5. Two entries answer half of everything — against eight for Domineering.
Past the first two the curve bends and keeps bending. Ten entries reach three quarters; 94 reach nine tenths on 4 × 5 and 184 on 5 × 5; ninety-nine per cent needs most of the catalogue, 1,867 entries on 4 × 5 and 11,936 on 5 × 5. The two boards’ curves lie almost on top of each other through the head, which says the head is not a fact about one board: the same small shapes come up in the same proportions wherever a Cram board is cut by dominoes.
Against Domineering’s sweep, the contrast at nine tenths is large. There, 2,018 of 3,554 shapes are needed — 57 per cent of every shape seen. Here, 94 of 2,304 on 4 × 5 is 4 per cent of the catalogue, and 184 of 16,457 on 5 × 5 is about 1 per cent. The two counts were made over different boards and different samples of play, so the comparison is a matter of orders of magnitude rather than exact ratios, but the orders are not close. An impartial catalogue concentrates by piece far harder than a partizan one. Some of that is the quarter turn, which merges every shape with its rotation; more is that Cram players share the dominoes, so the board is filled further and cut into the same small pieces over and over before anyone runs out of moves.
A position is only as answered as its rarest piece
The pieces are not what a solver is asked about. It is asked about positions, and a position is answered by the list only if every one of its pieces is in it. One rare piece and the position must be searched. That changes the arithmetic completely.
Leave the lone squares out of both readings, since a solver needs no entry for them. Then half the pieces of 5 × 5 positions take four entries — the slot, the two three-square shapes, and an L of four squares worth — and half the whole positions take 33. Nine tenths of pieces take 664 entries; nine tenths of positions take 3,786, almost a quarter of the whole catalogue.
The reason is the shape of a typical position. A position a few moves into a 5 × 5 game has several pieces, and most of them are small and common, but one of them is usually large — the part of the board the dominoes have not yet reached. Large pieces are individually rare, because there are so many ways for a large region to be shaped, and each position’s large piece is often one of a kind. The list has to hold that piece for the position to count, so the position curve is dragged out by its rarest member while the piece curve is pulled in by its commonest.
The table gives the same reading on five boards. The piece prices are tiny everywhere: two entries for half, 44 to 184 for nine tenths. The position prices are not: 112 entries for nine tenths on the 4 × 4 board, 782 on 4 × 5, 3,056 on 4 × 6, 3,786 on 5 × 5. As a share of the catalogue, though, they fall — 57 per cent of the 4 × 4 catalogue, 41 of the 3 × 6, 34 of the 4 × 5, 23 of the 5 × 5 and 19 of the 4 × 6. A larger board needs a longer list and a smaller fraction of its catalogue. The tail of rare shapes grows faster than the set of shapes that positions actually need, which is the first hint that a list could be useful on a board too large to enumerate.
The list answers the end of the game
Sort the positions by how many dominoes are already on the board, and the reason for both readings comes into view at once.
Each list length draws an S. This is the board falling apart measured from the solver’s side. Late in the game — eight dominoes and beyond on 5 × 5, where the 25 squares are mostly covered — nearly every position is answered by any list of more than a few dozen entries, because the pieces left are small and every small shape is in the head of the list. Early in the game nearly nothing is answered, by any list a solver would call short, because the uncovered part of the board is still one or two large regions that the list has never been long enough to hold. A list of 184 entries, which answers nine pieces in ten, answers 94 per cent of positions eight dominoes in and 6 per cent four dominoes in. A list of 3,786, which answers nine positions in ten overall, answers 15 per cent of the positions three dominoes in.
That is the profile of an endgame table. A chess endgame table answers every position with few enough pieces on the board and nothing with more, so a chess program searches forward from the position in front of it until the search reaches positions the table holds, and reads the answer off. A table that knows every won position is exact where it applies and silent everywhere else, and it is built the way every such table is built, by working backwards from the end: the positions with fewest pieces first, each one’s answer read off answers already in the table. The shape catalogue fills itself in exactly that order — a shape’s value is a mex over exclusive-ors of smaller shapes — so the resemblance is not only in what the two answer but in how both are made. A list of Cram shapes is the same instrument, with the board’s remaining area playing the part of the piece count: it is exact on any position whose regions are all small and common, and silent on the rest.
And the two halves of a Cram solver fit each other in a way that a table of rectangles never could. A rectangle table answers exactly one position a game — the empty board — and nothing after the first domino. A short list of shapes answers the end and nothing at the start. The opening is where search is cheap, because there are few positions there: one empty 5 × 5 board, 40 after one domino, 670 after two, 6,152 after three. The middle game, around seven dominoes, holds 336,784 positions and is where the list starts to take over. Search where positions are few, look up where pieces are small, and the crossover is a matter of choosing the list’s length.
Each domino earlier costs a list six times as long
The S-curves move left as the list grows, and how fast they move is the price of extending the table backwards.
On 5 × 5 a list of sixteen entries answers half the positions seven and a half dominoes in. Doubling it eight times, to 4,096, moves that point only to 4.4 dominoes: three dominoes earlier for a list 256 times as long. Each domino earlier costs a list about six times as long. The 4 × 6 board, with nearly the same catalogue, runs parallel to it and half a domino earlier; 4 × 5 runs a domino and a half earlier still, since its board is five squares smaller.
The lines are nearly straight on a logarithmic scale of list length, which is the useful part. It says the cost of the table grows exponentially with how far back into the game it reaches, at a rate set by how fast the variety of large regions grows — and so the solver’s designer has a single knob. A longer list moves the frontier back and costs memory; a shorter one moves it forward and costs search. On 5 × 5 a list of a few hundred entries puts the frontier at six dominoes, where a forward search from the empty board has to visit at most 254,846 positions of that depth; a list of a few thousand puts it at four or five.
This is also where the comparison with Domineering stops being in Cram’s favour. The piece curve concentrated more than ten times harder, but the frontier is about positions, and a position is as rare as its largest region. Large regions in Cram are no more repetitive than in Domineering: the quarter turn halves their number at most, and there are tens of thousands of them. The cheap head of the list buys the endgame; the opening is paid for in the same currency in both games.
Random games put the weight in different places
Every count so far treats every reachable position once. No player meets positions that way. Real play visits the early positions in every game and the late ones only in some, and it reaches some positions far more often than others.
The play-weighted measure was made with 20,000 games in which each move places a domino uniformly at random among the legal ones, until none fits. On 4 × 5 a game lasts nine dominoes on average and on 5 × 5 a little over eleven. Every position a game passes through is counted once per visit, so the empty board is counted 20,000 times and a late position perhaps once or not at all. The shapes the games met were 2,269 of the 2,304 on 4 × 5 and 11,621 of the 16,457 on 5 × 5 — about three in ten of the larger board’s shapes never turned up in 20,000 games.
The two readings move in opposite directions. By piece, play makes the list dearer: nine tenths of pieces need 191 entries rather than 94 on 4 × 5, and 528 rather than 184 on 5 × 5, because play spends a large share of its visits in the opening, where pieces are big and varied, and the big pieces are rare. By position, play makes it cheaper: nine tenths of positions need 532 entries rather than 782, and 2,381 rather than 3,786. The positions that make the reachable count expensive are the crowded middle-game positions with one awkward large piece, and random play passes through relatively few of them — it moves through the middle game in two or three dominoes and spends the rest of its time either before it, where nothing is answered by any short list anyway, or after it.
Neither weighting is the right one, and the table is there to show that the answer depends on it by a factor of two. A solver playing well does not move at random, and the positions it visits are the ones its search chooses. What survives both weightings is the shape of the result: two entries for half the pieces, hundreds for nine tenths, thousands for nine tenths of positions, and a list that answers the end of the game.
How the counts were made
Positions are every set of covered squares that some sequence of legal dominoes reaches from the empty board, whoever is to move — Cram is impartial, so a position is its covered squares and nothing more. Pieces are the edge-connected sets of free squares, since a domino covers two squares that share a side; two squares touching at a corner are in different pieces. Shapes are pieces up to translation and all eight symmetries of the square, which Cram allows because its rules treat the two orientations of a domino alike.
A list is the first K shapes in order of how many pieces they account for over all reachable positions of the board, ties broken by a fixed ordering of the shapes. A position is answered when every piece in it, other than lone squares, is in the list; the lone square is excluded because a solver can recognise a square with no free neighbour without an entry, and it is worth nothing. The values of the shapes are never consulted — only whether a shape is present — so the measure would be the same for any catalogue keyed on these shapes, whatever its entries held. The exclusive-or rule that makes the catalogue a solver is the Sprague–Grundy theorem under normal play; it is the one convention the whole approach depends on, and under the other one the pieces do not add and no list of numbers would answer anything.
Random play is 20,000 games from the empty board with a fixed seed, each domino chosen uniformly from the legal ones. The frontier for a list is the first number of dominoes at which the share of positions answered reaches one half, interpolated linearly between whole numbers of dominoes; past 512 entries on 4 × 5 and 4,096 on the larger boards the list starts answering more of the positions one or two dominoes in than of those three or four in — the second domino’s few positions happen to fall into common shapes — and the frontier is not drawn there.
What the counts leave unsettled
Whether the head is universal. The first two entries are half the pieces on all five boards measured, and the first dozen nearly the same shares. That is suggestive of a fact about Cram rather than about a board, but five rectangles of up to 25 squares are not every board, and a long thin board might put its weight on a different head. The extreme case is the strip one square wide, where Cram is Dawson’s Kayles — every piece is a straight run, the catalogue is one shape per length, and a list of the first K lengths answers a position exactly when its longest run is shorter than K. On a strip the list and the frontier are the same number, and the exponential above collapses to a straight line; the rectangles here sit somewhere between that and the full variety of polyominoes, and where a given board sits is not measured.
What a good player meets. Both weightings here are artificial: one counts each position once, the other moves at random. A solver searching for the best move visits positions in an order set by its own search, and the frontier it needs is wherever its search can afford to stop. The price list is a statement about the positions there are, not the ones a strong player reaches.
Whether the exponential holds further out. The frontier figure has three boards and eleven list lengths, and its lines are straight over a range of a thousand. On a 6 × 6 board — whose reachable positions number in the hundreds of millions, out of reach of the enumeration used here — they might bend either way. A frontier that slowed would mean the large regions repeat after all; one that sped up would mean a short list is worth less on large boards than on small.
Still open: the list a board too large to count would need
Everything here was measured by enumerating every reachable position, which stops at about 25 squares. The finding that matters for larger boards is that a list’s value is concentrated in the late game, where pieces are small — and small shapes are exactly the ones that can be counted without the board, as the polyomino census of the earlier essay did to eleven squares. That suggests building the list not from a board’s positions but from shapes by size, weighted by an estimate of how often each size of piece occurs late in a game, and testing it against the exact lists here. If a list built without seeing the board answers the endgame of 5 × 5 as well as the board’s own list does, then the same construction can be trusted on 6 × 6 and 7 × 7, where the board’s own list cannot be made, and the remaining question becomes only how deep a forward search from the empty board can reach to meet it.
Part 4 of 4
One argument about Cram. The parts either side of it:
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.
ComponentCramDecompositionDomineeringEndgameExhaustive searchGrundy valueImpartialNim-sumSprague–Grundy
- A coin with three strings is worth something component, decomposition, endgame, exhaustive search, grundy value, impartial, sprague–grundy
- The parts are worth nothing and the sum is not component, decomposition, endgame, exhaustive search, impartial, nim-sum, sprague–grundy
- What a component has to carry component, decomposition, exhaustive search, grundy value, impartial, nim-sum, sprague–grundy
- The chains decide it before the boxes do component, decomposition, endgame, exhaustive search, impartial, sprague–grundy
- What restores the theorem component, decomposition, exhaustive search, grundy value, impartial, sprague–grundy
- A move that must be answered component, exhaustive search, grundy value, impartial, nim-sum