22 September 2026
Give Away Two Boxes to Win: The Hidden Theory of Dots and Boxes
Dots and boxes is the game people play when they are supposed to be listening. A grid of dots, take turns drawing one line, complete a square and you claim it and go again. It is the sort of thing you assume has no more depth than noughts and crosses, and most people play it as a doodle rather than as a game.
It has enough depth that Elwyn Berlekamp, a Berkeley mathematician and one of the founders of combinatorial game theory, wrote an entire book about it. The subtitle he chose was Sophisticated Child’s Play, which is about right.
Anyone who has played a few rounds knows the shape of it. For the first half nothing happens. Both players draw lines in empty space, carefully avoiding any move that would give a box away, and the board fills up with harmless singles. Then the harmless moves run out. Every remaining line hands something to your opponent, and the game turns over in a single move.
That turning point is the whole game, and it has a name: you are forced to sacrifice. What matters is what the board has quietly become while nobody was paying attention. By this stage the empty squares have organised themselves into chains — runs of boxes linked together, where opening one end lets your opponent run the whole thing.
Here is where almost everyone goes wrong, and it is a natural mistake. Your opponent opens a chain of five. You take all five, because they are free and they are yours. Then it is still your turn, there are no safe moves left, and you have to open the next chain. You took five boxes and handed over the rest of the board.
The correct move is to take three of the five and stop. You draw the line that would ordinarily split the last two boxes, and instead you draw the one that leaves them joined as a domino — two boxes, yours for the taking, deliberately not taken. Your opponent now faces a board where the only move is to accept those two free boxes, and having taken them, they must open the next chain for you.
That is the double-cross, and it is the central idea of the game. You give up two boxes to buy the right to keep making your opponent go first. If the next chain is longer than two boxes, you have made a profit, and you can repeat the trick at the end of every chain for the rest of the game. One player takes every chain but two boxes; the other takes two boxes per chain and nothing else.
Once you see that, the earlier part of the game stops looking like aimless line-drawing. Both players are quietly trying to arrange who will be forced to open the first long chain, because that player loses the endgame. Berlekamp’s analysis connects the number of dots on the board to the number of long chains that end up forming, and gives a rule for which parity each player should be steering toward. The practical version is simpler: count the chains as they take shape, and ask whether the sequence of forced openings ends with you or with your opponent.
It is worth being precise about how unsolved this all is, because the answer is not what you would expect from a game this small. Small boards can be worked out completely, and we did: on a two-by-two board of boxes the first player wins 3–1 with perfect play. On three-by-two the second player wins 4–2. On three-by-three — nine boxes, sixteen dots — the second player wins 6–3.
That last result is the interesting one. The first player does not simply win by moving first, the way they do in Connect Four. On the nine-box board the advantage belongs to the player who moves second, and by a clear margin. Moving first in this game is closer to a liability than a head start, because the player who runs out of safe moves first is the one who has to open.
The board on this site is four by four — sixteen boxes, twenty-five dots, forty lines. That is 2 to the power of 40 possible line configurations, about 1.1 trillion, which puts it comfortably beyond the exhaustive method that settles the smaller grids. It is nothing next to the 500 billion billion positions in checkers, but it is the same story in miniature: add two rows and the counting stops working.
Which brings us to the computer opponent here, and this one has a weakness you can use directly. It follows three rules in order. If it can complete a box, it does. If not, it plays a line at random from those that give nothing away. If every remaining move gives something away, it picks the one that opens the fewest boxes.
Look at the first rule again. It completes every box it can, always, without exception. That means it can never play the double-cross — the double-cross requires declining two boxes that are sitting right there, and this opponent is incapable of declining anything. So when a chain opens for it, it takes the lot, and then has to open the next chain for you. Chains strictly alternate.
That gives you a plan. Count the chains before the sacrifice phase begins, and work out whether the longest one will land on your turn or its turn. Because the alternation is guaranteed, you can arrange it in advance. And since the second rule picks a safe move at random, the machine has no plan of its own while the chains are forming — it is not shaping the board against you, it is only avoiding immediate loss, so the structure of the endgame is very nearly yours to decide.
The history is older than it looks. The game is generally credited to Édouard Lucas, the French mathematician, who published it in 1889 under the name la pipopipette. Lucas is better known for two other things: the Tower of Hanoi puzzle, which he invented and sold as a toy, and the Lucas numbers, which are the sequence you get by running the Fibonacci rule from different starting values. A man with a good eye for what makes a rule worth playing with.
The reason a game this simple is worth ten minutes is the double-cross itself. It is the cleanest example anywhere of giving something up now in order to control what happens later, and it is the same idea as the two-for-one shot we described at cerdikcerdik.com/blog/checkers-solved-chinook — the move that looks like a mistake right up until it is the reason you won. Play a few rounds at cerdikcerdik.com/games/dots-and-boxes, and the next time a chain opens, try taking all of it but two.
Continue learning →