Out in the world

Remembering where it has been

The best rule of thumb nine clauses could make for king and rook against king walks past a mate in two for ever, because it cannot tell a second visit from the first. Give it a memory of the game and let the memory overrule it whenever its move would return somewhere already reached, and every one of 400 games is mated. But a memory of the last 64 positions mates only 247 of them, the whole game has to be kept, and against a black that knows the rule's loops the median mate takes 134 moves where the table needs at most sixteen.
19 min read 6 figures It has to endWhat a search costs

Assumes: Nine clauses, and the rook still circles · A rule of thumb has to stand still

Nine clauses, and the rook still circles built rules of thumb for king and rook against king one clause at a time — shrink the black king’s room, bring the kings together, keep the rook safe, shrink the box — and after each clause recomputed the positions from which black can keep the game going round a loop for ever. The best rule found, nine clauses long, is still held from 69.3 per cent of the won positions, and from every position thirteen or more moves from mate. Its shortest loop is two moves long and runs through a mate in two: the rule sees the mating king move, prefers a different king move by one clause, and when black steps back the same position is on the board again.

The diagnosis was that the rule reads only the squares. A white who remembered standing on c2 a move ago would try something else, and a rule with that memory is no longer a function of the position, so the argument that put a floor under every rule of thumb — a number that falls at every move needs sixteen values — no longer applies to it. The question was whether memory is enough, and what it costs.

Memory is enough. Used the right way, it mates every one of 400 games against every black tried. Used the wrong way it changes nothing at all, a memory of the last few dozen positions is barely better than none, and the games it wins can take more than three hundred moves in an ending no position of which is more than sixteen from mate.

Two ways to use a memory

The memory here is the simplest one a game can have: the set of positions reached so far in this game, recorded after each of white’s moves with black to move. Nothing else about the history is kept — not the order, not how often, not what black did. And there are two natural ways to let it act.

As a tie-break. Among the moves the rule rates best, prefer one that leads somewhere not yet reached; if every best move repeats, play one anyway. This is memory as a player uses a hunch, consulted only when the principles have nothing more to say.

As an override. Walk down all of white’s won-keeping moves in the rule’s own order and play the first that leads somewhere new. Only if every one of them has been used does the rule fall back on its own best. Here memory outranks every clause: the rule is a ranking, and memory decides how far down it to go.

Four hundred games with a memory. King and rook against king, 400 games from positions ten or more moves from mate. Two rules, two black strategies and three uses of memory: none, as a tie-break, and allowed to overrule the rule. Only the last mates every game, and against a loop-seeking black it takes a median of 134 moves.
Fig. 1 The same 400 games, from positions ten or more moves from mate, under two rules, two kinds of black and three uses of memory. A tie-break changes nothing for the nine-clause rule, which has no ties left to break. An override mates every game against both blacks — in a median of 18 moves against a black resisting by the table, and 134 against one that keeps to the rule’s loops.

The two blacks need a word. The first resists as the table says to: from each position it plays the reply that leaves white furthest from mate, the defence the earlier play-outs used. The second is built against the rule. Among its replies it prefers one that lands in the rule’s own held set — the positions from which a loop exists — and resists by the table among those. It is a black that has read the rule’s weaknesses and walks towards them — the defender loopy games are about, for whom a line that never ends is an outcome worth steering for. Against the nine-clause rule with no memory it is much the stronger defender: the rule mates 205 of 400 games against the first black and only 69 against the second.

As a tie-break, memory does nothing to the nine-clause rule. The play-outs are the same 205 and 69. That was predictable from what the earlier sweep found about ties. By six clauses only 664 of the 173,656 positions without a mate in one leave white a choice between equally rated moves, so a memory that only speaks when there is a choice almost never speaks. On kings-then-box, which leaves ties in most positions, the tie-break helps — 241 games mated becomes 270 — because there it gets a hearing. A memory that defers to the rule is only as useful as the rule’s indecision.

As an override, memory turns every row of the table to 400. Kings-then-box, the nine-clause rule, either black: every game is mated. The rule that a resisting black could hold in a loop from more than two thirds of the board no longer has a single loop it can be held in. And the median length against a resisting black, 18 moves, is only three more than the rule took in the games it already won.

Why the override must end every game

That the override mates is not an empirical accident; it is a counting argument, and the same one that ends any game under a rule against repetition.

Every move white plays under the override leads to a position — black to move, rook and kings placed — that has not been reached before in this game, unless white has been cornered with every won-keeping move used up. There are 201,436 such positions in the ending reachable by a won-keeping move. So a game in which white is never cornered lasts at most 201,436 white moves, because each one consumes a position that cannot be consumed again, and a game that cannot go on must have stopped at a mate: white’s moves all keep the win, so the only way out is a mate. It is the plainest kind of termination proof there is — a natural number that falls, here the count of positions not yet used — and it says nothing about when.

The cornering never happened. In all 400 games against each black, white always had a fresh won-keeping move. That is unsurprising once it is put as a count. A position has a dozen or two won-keeping moves, and black would have to have steered white through every one of the positions they lead to before returning; the longest game reached 368 positions out of 201,436.

This is what counting positions buys, seen from the other side of the board. There, a rule barring the L-th arrival at any of n positions ends every game within (L − 1)n − 1 moves with no proof beyond arithmetic, and it is imposed on both players as a rule of the game. Here it is a self-imposed habit of one player, and the same arithmetic gives the same kind of guarantee. The floor that no rule of thumb could get under was a statement about numbers on positions. Memory does not get under the floor; it changes the question so that the floor no longer applies. A strategy that remembers is a function of the game so far, and a function of the game so far can mate from a loop it has seen before simply by refusing to go round it again.

That is the surprising connection the result makes. Chess already has a repetition rule, and it exists for black’s sake — the defender claims a draw when a position comes a third time. Turned round and adopted by the attacker as a discipline, the same idea does the work a progress measure does. A player who never repeats a position must eventually reach one where repetition is impossible because the game is over.

What memory does at the mate in two

The two-move cycle that the earlier essay found makes the mechanism visible. With the white king on c2, the black king on e1 and the rook on f7, white mates in two with the king to d3. The nine-clause rule plays the king to c1 instead, because both moves leave the black king one square and c1 is one step nearer to it on the walk clause. Black steps to e2, the position is thirteen moves from mate, the rule brings the king back to c2, and black returns to e1.

The order memory works down. At white king c2, black king e1, rook f7 — mate in two — the won-keeping moves sorted by the nine-clause rule, with their first four clause scores and the distance to mate after each. The mating king move to d3 comes fifth, so a rule that skips repeated positions reaches it on the fifth visit.
Fig. 2 At white king c2, black king e1, rook f7 — a mate in two — white’s won-keeping moves in the nine-clause rule’s order. The first four clause scores and the distance to mate after each move are shown. An override plays the first move not yet used, so each time black walks back into the cycle white goes one row further down, and the mating king move to d3 is played on the fifth visit.

With memory the second visit is different. The king to c1 leads to a position already reached, so white goes down to the next row, the rook to f4, which keeps the win but leaves mate nine moves away. If black walks back into the cycle again, the third visit takes the rook to f5, the fourth to f6, and on the fifth the first row not yet used is the king to d3. The mate in two that the rule walked past for ever is played the fifth time it is offered.

The table shows why it takes five visits and not two. Every one of the first five rows scores the same on room, the first clause — the black king keeps one square — and the three rook moves and the mating king move tie with it on the next three clauses as well; the king to c1 comes first only because the walk clause counts it a step nearer. What separates them is further down the list of clauses, in measures that have nothing to do with mate. The rule ranks the mating move fifth not because it is a bad move but because the clauses do not see what is good about it, and memory has no idea either. It does not find the mate; it exhausts the alternatives the rule prefers until the mate is the only fresh move left at the top.

That is the right way to read the override. Memory is not knowledge. It cannot tell a move that mates from one that wanders; it can only tell a move it has used from one it has not. Its value is that the supply of unused moves is finite, and a rule that must keep finding new ones is forced, eventually, to find the one that ends the game.

One game, a hundred and thirteen moves long

Black does not have to walk back into the cycle, and a resisting black does not. Played from the same mate in two, with black choosing by the table, the game goes somewhere else entirely.

A game the memory rule wins slowly. The distance to mate before each white move in one game of king and rook against king, starting from the mate in two at white king c2, black king e1, rook f7. The nine-clause rule with memory mates on move 113, after hovering at eleven to fourteen moves from mate for about a hundred moves.
Fig. 3 One game from the mate in two at white king c2, black king e1, rook f7: the distance to mate before each of white’s moves, the nine-clause rule with memory, black resisting by the table. A tick on the axis marks a move where memory overruled the rule. The game wanders between eleven and fourteen moves from mate for about a hundred moves before the net closes on move 113.

White’s first move is the king to c1, as always. Black, resisting, does not step back to e1 but up to e3, and the position is fourteen moves from mate. From there the rule walks its king up the c-file behind the black king, the rook swings across the board, and the distance to mate hovers between eleven and fourteen for move after move. Memory overrules the rule 46 times in the game, and on most of those moves the alternative it plays is as good as the rule’s choice by the table’s measure — a step that keeps the distance roughly where it was. Then, around move 100, the black king is caught against the edge, the distance falls by one at every move, and white mates on move 113.

The line in the figure is what a win is not a way of winning found for a white who reads only whether a move keeps the win: a game that stays won at every move and does not converge. The difference is that this one does converge, eventually, and for a reason that can be stated. Memory sweeps the region of the board where the rule likes to be until there is no fresh position left in it, and then the only fresh positions are nearer mate. The long flat stretch is the sweep.

The game also shows how badly a single position can mislead. A mate in two became a mate in 113 — not because of anything about the position, which is as near to mate as the ending allows short of mate in one, but because the rule’s first move from it walks away and the memory has nothing yet to say. Memory pays off only on a return, and a black who never returns can make the rule pay its full price for every region it has to clear.

A memory of the last few moves is not a memory

The override worked by remembering the whole game. A player does not, and a natural question is how much of the game is needed: the last two positions would kill a two-move cycle, the last eight any loop of eight.

How much memory the rule needs. Games mated out of 400 by the nine-clause rule with memory of the last 1 to 256 positions, and of the whole game, against two black strategies. Short windows barely help; against a loop-keeping black 64 positions mate 247 and 128 mate 334; full memory mates every game.
Fig. 4 Games mated, of 400, when the nine-clause rule is overruled only on a return to one of the last n positions, against both blacks. Windows of 2 to 32 positions barely move the count against either. Against a loop-keeping black, 64 positions mate 247 games and 128 mate 334; a window of 256 is the first to mate all 400 here, and the whole game always does.

The answer is that a short memory buys almost nothing. Against the resisting black, a window of two positions takes the count from 205 to 215, and it stays between 201 and 216 through every window up to sixteen. Against the loop-keeping black it rises from 69 to between 112 and 128 and then stalls through 32. Only at 64 does it start to climb, and 128 positions still leave 66 of 400 games unmated.

The reason is that loops are not short. A two-move cycle exists, but the held set is a large connected region, and a black who is turned away from one loop has others of every length available. A window of n positions forbids loops of length up to n and nothing else, so black simply plays a loop of length n + 1, or rather — since it does not plan — finds its way into one. The count does not step up at each doubling of the window because the loops black has available do not come in a sequence of lengths that a window can exhaust one at a time; it rises only when the window becomes comparable to the size of the region the loops live in.

So the honest statement is narrower than the rule needs memory. The rule needs a memory as large as the territory it can be lost in. For the nine-clause rule against a black that knows its loops, that is a few hundred positions, and no window of a size a player would carry — the last few moves, the last dozen — gets near it. Chess’s own repetition rule looks at the whole game rather than the last few moves, and on this evidence it has to: a rule that forgot after a dozen moves would be a rule a patient defender could walk round.

The price is length

The guarantee is a count of positions, and it is a terrible bound: 201,436 white moves to mate where the table never needs more than sixteen. The play-outs say what the real price is.

The table's mates and the memory rule's. Lengths of 400 king-and-rook games: best play needs at most 16 moves from every start; the nine-clause rule with full memory, against a loop-keeping black, takes a median of 134 and at most 368, far inside the guarantee of 201,436 that counting positions gives.
Fig. 5 How long the 400 games last. Upper bars: the distance to mate with best play from each starting position, never more than sixteen. Lower bars: the moves the nine-clause rule with full memory took against a black that keeps to its loops. The median is 134 moves and the longest 368, far inside the counting guarantee and far outside the table’s.

Every starting position is between ten and sixteen moves from mate. Against the loop-keeping black, 72 of the 400 games are still mated within sixteen moves — the rule’s own clauses suffice there, and memory never has to speak. The rest spread out over two orders of magnitude, with the bulk between 129 and 256 moves and 38 games longer still. The median is 134.

Against a black that simply resists by the table the picture is much kinder: a median of 18 and a longest game of 177. The loop-keeping black is the honest adversary for this question, because it is the one that tests what memory adds rather than what the clauses already did. It is not the strongest possible black. A black that planned against the memory itself — choosing which of white’s fresh positions to force it into, so as to make each region as costly to clear as possible — might make the games longer still, and the exact worst case for a strategy that depends on history is a search over histories rather than over positions, which nothing here attempted.

The median of 134 is also the clearest statement of what the clauses were doing all along. Without memory, a rule’s quality was measured in how much of the board black could hold it from. With memory, nothing is held and the measure becomes speed.

The clauses buy speed

With the override in place, every rule mates — so the question becomes what a better rule buys.

Memory supplies the guarantee, the clauses the speed. Five rules of thumb for king and rook against king, each given a memory of the game that overrules a repeated position: the box alone, kings then box, and the best rules of four, six and nine clauses. Every rule mates all or nearly all of 400 games; the box alone takes a median of 150 moves and the nine-clause rule 18.
Fig. 6 Five rules, each with a memory that overrules a repeated position, in 400 games against both blacks. ‘Held, no memory’ is the share of won positions black could hold the rule from without memory. Every rule mates all or nearly all of its games; the box alone takes a median of 150 moves and the longest game 1,708, the clause rules a median near twenty against a resisting black.

The box alone — the coarsest rule, held from 98.8 per cent of won positions without memory — mates 399 of 400 games with it. One game runs past the cap of 2,000 moves. The median is 150 moves and the longest mated game 1,708. Kings-then-box mates every game at a median of 21. The best rule of four clauses, room then kings then walk then box, mates every game at a median of 18, and so does the nine-clause rule.

That is a clean division of labour, and it explains in hindsight why the clauses could not finish the job alone. Memory supplies the guarantee and the clauses supply the speed. Without memory the clauses were being asked to do both, and the first of those is a termination proof, which on the earlier floor argument needs sixteen values that fall at every move — something no set of features of the board supplies short of the table itself. With memory the termination proof comes free from the count, and the clauses are left with the job a rule of thumb is actually good at: making the next move a reasonable one.

The figure also contains a warning about the loop-keeping black. It is defined from each rule’s own held set, so against kings-then-box, whose held set is nearly every position, it has no information to use and plays exactly like the resisting black — both give a median of 21. Against the four-clause rule it lifts the median only from 18 to 24, and against the six- and nine-clause rules, whose held sets are small enough to steer by, from 18 or 19 to over 130. The comparison across rules in the right-hand columns is therefore not like for like: it shows how much a black can gain by knowing a rule’s loops, and that gain is largest for the rules whose loops are fewest and best defined. A rule that is held almost everywhere has no loops worth studying; a sharp rule has a map of its weaknesses that a defender can learn.

The model, the memory and the defenders

The ending is solved by backward labelling with no fifty-move rule and no repetition rule — the convention every result here rests on, since a chess game under its real rules would be drawn long before move 134. White keeps the win at every move and takes a mate in one whenever there is one.

The rules are the clause lists of the earlier essay, read lexicographically on the position after white’s move. The nine-clause rule is the best found of all nine clauses — room, walk, safe, kings, guard, box, between, edge, opposition — and the four-clause rule is the best of all 3,024 orderings of four.

The memory is the set of black-to-move positions reached after white’s moves in the current game. A tie-break memory chooses at random among the rule’s best moves that lead to an unreached position, or among all its best moves if none does. An override memory plays a random one of the rule’s best moves that leads somewhere unreached if there is one, and otherwise the first won-keeping move in the rule’s order that does; only if every won-keeping move repeats does it play a best move anyway. A window of n forgets a position n white moves after reaching it.

The defenders. The resisting black plays the reply with the greatest distance to mate in the table. The loop-keeping black plays a reply inside the rule’s memoryless held set if there is one, and the greatest distance to mate among those. Both are deterministic given the position.

The games start from the same 400 positions the earlier play-outs used — drawn with a fixed seed from those at least ten moves from mate — and stop at mate or at 2,000 white moves. Run with memory switched off, the computation reproduces the earlier essay’s 205 mated games for the nine-clause rule, which is the check that the two agree.

Where the result stops

The worst black. The loop-keeping black knows the rule but not the memory. A black that knew both could try to drive white into a position where every won-keeping move has been used, which would corner it, or simply into regions where clearing takes longest. The counting argument says such a black cannot make the game infinite as long as white is never cornered, but it says nothing useful about how long it can make it, and the 368 here is a measured length against one defender, not a bound.

A memory a person carries. Remembering every position of a game of a hundred moves is easy for a program and not for a player, and the window figure says that the shorter memories a person might actually keep do little. What a player does instead — remembering not positions but plans, noticing that the rook has been to the f-file before — is a compressed memory of a kind no window measures.

Any ending but this one. King and rook against king has a won position at almost every placement and a short maximum mate, and both facts shape the result: the first makes loops plentiful, the second makes the table’s sixteen moves a sharp contrast. An ending with long mates and few won positions, such as the pawn endings broken into files, would test whether the price of memory is set by the size of the won region or by the depth of the mate.

Still open: what memory has to keep

The memory used here is wasteful in an obvious way: it records every position, and most of what it records is never consulted again. The mate in two needed four earlier visits to be remembered and nothing else. A memory that kept only the positions where the rule’s choice was overruled, or only the positions in the held set of the memoryless rule, would be far smaller and might mate exactly as often, because those are the only places where a return can do harm. Measuring that — how small a memory can be and still guarantee the mate, against the loop-keeping black — would say whether the few hundred positions the window needed are the size of the rule’s weakness or only the size of the territory it wanders through, and whether a repetition rule a player could actually apply, such as one that counts arrivals at a single critical position, could do what the whole game’s memory does. And the fifty-move rule supplies a direct test: run the same games under it, and count how many of the memory rule’s wins arrive too late to count.

Part 8 of 9

One argument about Chess. 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.

ChessDistance to mateEndgameExhaustive searchHeuristicLoopyPosition graphTermination