Dots and Boxes
Dots and Boxes is played on a grid of dots. Players take turns drawing one line between two dots that sit next to each other, across or down. Draw the fourth side of a box and it is yours — and you must draw another line straight away. When every line is drawn, the player with more boxes wins. The skill is in the endgame: making your opponent open the long chains.
New game starts an empty board. Tap or click anywhere between two dots to draw that line — the whole diamond between them is the target, and hovering shows the line before you commit. Draw the fourth side of a box and it is yours, in your colour, and you draw again. The three-dot menu holds the board size, the computer’s level and who draws first; with a keyboard, the arrows walk the lines and Enter draws.
Your statistics · 4 × 4 · Medium
- Played
- 0
- Won
- 0
- Win rate
- 0%
- Streak
- 0
- Best streak
- 0
- Best time
- —
This level
Never draws a third side while a safe line is left, then gives away the smallest chain. It always takes every box, so it never keeps control.
Keyboard
- Arrows
- Move along the lines
- Enter / Space
- Draw the highlighted line
- N
- New game
- F
- Full screen
- Board
- 3 × 3 to 6 × 6 boxes
- Lines
- 24 to 84
- Players
- 2 (you vs. the computer)
- Levels
- Easy, Medium, Hard
How do you play dots and boxes?
The board starts as a square grid of dots with nothing drawn. On your turn you draw one line joining two dots that sit next to each other, across or down — never diagonally, and never over a line that is already there. The boards on this page run from 4 × 4 dots (3 × 3 boxes and 24 possible lines) up to 7 × 7 dots (6 × 6 boxes and 84 lines).
Drawing the fourth side of a box claims it, and here it fills with your colour. Claiming a box also obliges you to draw again at once: your turn only ends with a line that closes nothing. One line can close two boxes when it is the shared side of two three-sided boxes, and then both are yours. When the last line goes in — and the last line always closes a box — the player with more boxes wins.
Why is drawing the third side of a box a mistake?
Because that box is then one line from finished, and it is your opponent who draws next. Most of the opening is about avoiding exactly this. A safe line leaves every box it touches with at most two sides drawn, so it gives nothing away, and for the first part of the game both players draw safe lines while the board fills with two-sided boxes.
Those two-sided boxes join up into corridors. A run of them with both ends open is a chain, and a run that closes back on itself is a loop. Once the safe lines are gone, every line left on the board opens one of them, and whoever opens a chain hands all of it to the other player, who can take it box by box.
What is the long chain rule?
Chains of three boxes or more are long chains, and the endgame is fought over how many of them there are. Count the lines on a finished board two ways and a fixed identity falls out: the number of turns in a game equals the number of dots plus the number of double-crosses — single lines that close two boxes at once. The test suite checks that identity in every game it plays, and it turns the question of who must open the first long chain into a question of odd and even.
| Board | Dots | The first player wants |
|---|---|---|
| 3 × 3 boxes | 16 | An even number of long chains |
| 4 × 4 boxes | 25 | An odd number of long chains |
| 5 × 5 boxes | 36 | An even number of long chains |
| 6 × 6 boxes | 49 | An odd number of long chains |
So the fight happens while safe lines remain: lengthening a chain, splitting one in two or joining two into one changes the count, and the player who gets the parity right will be the one taking the long chains at the end. Loops do not count. Keeping control of a loop costs two double-crosses, which leaves the parity where it was.
How do you keep control once the chains are opened?
By refusing the last two boxes. When your opponent opens a long chain, take every box but the last two, then draw the line at the far end instead of taking them. Your opponent takes the pair with one line and must then open the next chain for you. This all-but-two trick is called double-dealing, and it is how control is kept. In a loop the same trick costs four boxes, because the last four are handed back as two pairs.
Worked through on a 4 × 4 board split into four chains of four: the player in control takes 2 and hands back 2 on each of the first three chains, then takes all 4 of the last one, and wins 10–6. Grab all four boxes of the first chain instead and control changes hands; against good play the game then ends 8–8. The Hard computer on this page makes exactly that choice — the test suite builds this board, opens a chain and checks that Hard takes two boxes and then draws the line at the far end.
How does the computer play dots and boxes?
| Level | Boxes on offer | While safe lines remain | Once they are gone |
|---|---|---|---|
| Easy | Takes any it can | Draws anywhere, third sides included | Draws anywhere |
| Medium | Takes every one, always | Never draws a third side | Gives away the smallest chain, and never keeps control |
| Hard | Takes them unless declining keeps control | Searches the last 18 safe lines for the chain count it wants | Double-deals chains and loops, and solves the last 16 lines exactly |
The gap between the levels is measured, not asserted. In 40 seeded games in the test suite — ten on each board, with each side drawing first in half of them — Hard beat Medium in all 40, and Medium beat Easy in 38. None of the levels throws a die: when two lines are equally good the choice is drawn from the game's own number, so a game replays line for line from that number.
Where does dots and boxes come from?
The French mathematician Édouard Lucas published it in 1889 as La Pipopipette, and it has been played in the margins of exercise books ever since. Its theory came much later: Elwyn Berlekamp, a co-author of Winning Ways for Your Mathematical Plays, gave the game a book of its own in 2000, The Dots and Boxes Game: Sophisticated Child's Play, and the long chain rule and double-dealing described above are his terms.
Computers have since solved small boards outright. In 2012 Joseph Barker and Richard Korf solved the 4 × 5 board and showed that with perfect play it ends in a tie. For a simpler game of lines on a grid, try tic tac toe; for another game decided by what you leave your opponent, try Four in a Row.
How do you get better at dots and boxes?
- Never draw a third side while a safe line existsA box with three sides drawn is a gift to whoever draws next. Until the safe lines run out, every line you draw should leave each box it touches with at most two sides.
- Count the long chains before the safe lines run outChains of three or more decide the endgame, and the long chain rule says which count you want. Split, lengthen or join chains in the last safe moves so that your opponent is the one who has to open the first long chain.
- Take all but two, then decideWhen a long chain is opened for you, take every box except the last two. Then either take those two and open something yourself, or draw the far end line and make your opponent open the next chain — whichever wins more boxes over the rest of the board.
- Give away short chains first, and a pair by its middle lineWhen you must give something away, sacrifice single boxes and pairs before long chains. Open a pair by the line between its two boxes: your opponent then cannot hand it back, so they cannot use it to keep control.
- Remember that a loop costs fourKeeping control after a loop is opened means handing back four boxes as two pairs, not two. A short loop is often better simply taken, and a board full of loops favours the player who has to give things away.
Dots and Boxes questions people ask
- Do you have to take a box in dots and boxes?
- No. You may leave a box for your opponent, and leaving the last two boxes of a chain on purpose is the key endgame move. What you cannot do is stop after closing one: a box you close earns you another line, and you must draw it.
- What happens when one line closes two boxes?
- You claim both boxes, and you draw again once, exactly as for a single box. That line is called a double-cross, and it most often happens when a player takes a pair of boxes that the other player handed back deliberately.
- Can dots and boxes end in a tie?
- Only on a board with an even number of boxes. Here that is 4 × 4, with 16 boxes, and 6 × 6, with 36; the 3 × 3 and 5 × 5 boards have an odd number of boxes, so one player always finishes ahead.
- Is it better to go first in dots and boxes?
- Not in itself. What decides the game is who is forced to open the first long chain, which the long chain rule ties to the number of dots and the number of long chains. The menu lets you choose who draws first, so you can play both sides of that fight.
- Why did the computer leave two boxes for me?
- Because taking them would have left it drawing next into another long chain. By handing you two boxes it makes you open the next chain instead, and it usually wins more boxes from that chain than it gave away.
The rules in six lines
- 1Start with a grid of dotsChoose a board of 3 × 3 to 6 × 6 boxes, and who draws first. No lines are drawn and no boxes belong to anyone.
- 2Draw one line on your turnJoin two dots that sit next to each other, across or down. No diagonals, and a line can only be drawn once.
- 3Close a box to claim itDrawing the fourth side of a box makes it yours. A line that is the shared side of two three-sided boxes claims both.
- 4Closing a box means drawing againAfter claiming a box you must draw another line at once. The turn passes only when a line closes nothing.
- 5Play until every line is drawnThe last line always closes at least one box, so the game ends at the same moment every box has an owner.
- 6Most boxes winsCount the boxes each player claimed. The higher count wins, and a board with an even number of boxes can finish level.
The long version, with worked examples and the questions beginners actually ask, is on how to play dots and boxes.
Put Dots and Boxes on your own site
The board runs in an iframe with no tracking, no cookies and no sign-up. Paste this wherever you want it. See all the embeddable games for the rest.
<iframe src="https://www.cardgamenook.com/embed/dots-and-boxes" width="100%" height="620" style="border:0;border-radius:10px;max-width:900px" title="Dots and Boxes — free online" loading="lazy"></iframe>
<p style="font:14px system-ui;margin:6px 0 0"><a href="https://www.cardgamenook.com/dots-and-boxes">Play Dots and Boxes</a> at Card Game Nook</p>