What this game is
A game out of a school exercise book with real mathematics hidden inside it. The rules take twenty seconds to explain, and you start winning the moment you learn one single trick.
The first two thirds of a game look pointless: both players just draw lines and try not to give anything away. Then the safe moves run out, somebody has to open the first chain — and boxes start changing hands in batches of five and eight.
The whole struggle is about who that somebody will be. Not about boxes — about the right not to be the first to step into the void.
Rules
- The field is 6×6 dots, which makes 5×5 = 25 boxes and 60 possible lines. You play blue and move first.
- A move is one line between two neighbouring dots, horizontally or vertically. Click the gap between the dots. Diagonals are not allowed.
- If your line closes the fourth side of a box, that box is yours: it is filled with your colour and you move again.
- A single line can close two boxes at once — you take both and still move again.
- You keep the turn for as long as you keep closing boxes. It passes to your opponent only after a line that closes nothing.
- Passing is not allowed: when it is your turn you must draw a line, even if every one of them hands your opponent half the board.
- The game ends when all 60 lines are drawn. Whoever owns more boxes wins. There are 25 boxes, an odd number, so a draw is impossible here.
How to play better
- Call a move safe when it leaves no box with three sides. While safe moves exist, play only those, and never draw a third side without a reason.
- A third side does not hand over one box — it hands over the whole chain that box belongs to. Five boxes in a row are closed with five moves, and all five are your opponent's.
- When the safe moves are gone and you must sacrifice, open the shortest chain. You give away the least, and it will be your opponent who has to open the next one.
- The key trick of the game is the double-cross. When you are handed a chain, do not eat all of it: stop at the last two boxes and draw the line that gives both of them away at once. You lose two boxes, but the turn stays with your opponent — and opening the next chain is his problem again.
- There is one exception: eat the last chain of the game whole. There is nothing left to open afterwards, so there is nothing to pay for.
- From the middle of the game on, do not look at the score — look at how many chains are still untouched and whose turn it is to break into them. That number, not the current 6:4, tells you who is winning.
A bit of history
The game was published in 1889 by the French mathematician Édouard Lucas — the man the Lucas numbers are named after, and the one whose Tower of Hanoi still sits in every puzzle shop. He called it la pipopipette and dedicated it to the students of the École Polytechnique.
Lucas presented it as a scientific game of combinations, and he was not overselling it. The rigorous theory of chains and loops came much later: a whole chapter went to it in "Winning Ways for Your Mathematical Plays" (1982), and Elwyn Berlekamp wrote an entire book about it, "The Dots and Boxes Game". The double-cross you use to give away two boxes and keep the turn comes from there.
This version follows the Dots and Boxes applet that ran on this site from 2005: the same 5×5 field, the same cyan panel and the same old-fashioned menu bar.
About the levels
Easy plays the most obvious way there is: if a box is available it takes it, otherwise it makes a random safe move, and once no safe move is left it plays completely at random. Which means it sacrifices without thinking and will happily crack open the longest chain on the board. It has never heard of the double-cross: it eats every last box and hands the turn straight back to you every single time.
Hard differs in exactly one respect: it chooses its forced sacrifice sensibly. It tries every remaining line, checks how many boxes the opponent would harvest after each, and opens the cheapest chain. It still eats everything it can, though, so it gives up control of the game just as reliably as Easy does.
Expert is two different machines. While more than fourteen lines remain it plays strategically: it eats long chains, it picks safe moves so as to bring boxes up to two sides as late as possible, and when a chain of exactly two boxes is on offer it compares the alternatives — eat them and open the next chain itself, or play the double-cross and leave the turn to you. Once fourteen or fewer lines are left it switches to an exhaustive search of every remaining option, with positions memoised, and calculates the endgame exactly. From that point on it can no longer make a mistake.
It does have weak spots. Its middlegame is a set of rules, not a calculation. It only considers the double-cross for a two-box chain. It does not distinguish closed loops, which cost four boxes to give away rather than two, from ordinary chains. And if the exact endgame search does not fit into the third of a second it is given, it quietly falls back to those same general rules.