Dots and Boxes

4×4 boxes · Medium computer

You0
Left16
Computer0

Your move: draw a line.

Tap or click between two dots to draw a line; the nearest free line is drawn. With a keyboard, the arrow keys move between lines and Enter or Space draws one. U undoes, H gives a hint and N starts a new game.

Options

Grid size (boxes)

A 4×4 grid of boxes has 5×5 dots. Changing the size starts a new game.

Who moves first

Your record against the computer

LevelWonTiedLostBest

Best is your biggest winning margin in boxes. Kept in this browser only; restarted games aren't counted.

Play Dots and Boxes online, free

Dots and Boxes is the pencil-and-paper game where two players take turns joining dots with lines, and whoever completes a box claims it and moves again. This free online version plays in your browser against the computer at three levels, from an Easy opponent that hands out boxes to a Hard one that plays the chain endgame like an expert, or against a friend on the same phone, tablet or computer. Choose a grid from 3×3 to 8×8 boxes, take moves back, ask for a hint and keep a record of your games. There is nothing to install and no account, and everything runs on your device.

How to play Dots and Boxes

  1. Pick an opponent. Choose vs Computer and a level, or 2 Players to share the screen. The grid size is in Options.
  2. Draw a line. Tap or click between two neighbouring dots, across or down. You don't have to hit the line exactly: the nearest free line is drawn. A tap right on a dot or in the middle of an open box, where two lines are about as near, asks you to aim again instead of guessing.
  3. Close a box, move again. Draw the fourth side of a box and it's yours, shaded in your colour, and you draw another line. One line can close two boxes at once.
  4. Avoid the third side. A line that leaves a box with three sides drawn hands it to your opponent.
  5. Count the boxes. When every line is drawn, the player with more boxes wins. Even-sized grids can end in a tie.

You draw in blue; the computer, or your friend, draws in orange, and each claimed box shows its owner's initial as well as the colour. The newest line is highlighted so you can see what just happened. Undo takes back your last line together with the computer's reply, and Hint suggests a line and says why. With a keyboard, Tab to the board, move between lines with the arrow keys and press Enter or Space to draw; U undoes, H asks for a hint and N starts a new game.

The three computer levels

LevelWhat to expect
EasyTakes a box it can see most of the time, but draws almost anywhere otherwise, often handing you boxes.
MediumTakes every box on offer and never gives one away while a safe line is left. When the safe lines run out it opens the smallest chain, but it knows nothing about control.
HardPlays the chain endgame exactly: it declines the last two boxes of a chain to keep control, sacrifices a box or two when that wins the chain fight, and searches the last safe moves.

Hard works out the endgame the way expert players do. Once no safe line is left, it splits the open boxes into chains and loops and calculates exactly what each choice is worth: which one to open, whether to take every box on offer or decline the last two (four in a loop) to keep control, and when a small sacrifice changes who has to open the long chains. Tangled regions that are neither a chain nor a loop are played out line by line. In the last part of the safe phase it searches every remaining safe line to win the fight over parity. It runs in a background thread on your device and answers in a second or two at most.

Dots and Boxes strategy

Don't draw the third side

Early on, every line is either safe, leaving no box with three sides, or a gift. Play safe lines for as long as you can and take any box your opponent hands you. Beginners lose most of their boxes by drawing third sides out of impatience.

Chains decide the game

Sooner or later the safe lines run out, and the open boxes form chains: rows of boxes where taking one exposes the next. A chain of three or more is a long chain. Whoever is forced to open the first long chain usually loses, because the other player can take it and keep control for the rest of the game. Short chains of one or two boxes are the small change you give away while you wait.

The double-cross: keep control by giving two boxes

When your opponent opens a long chain, take every box except the last two, then draw the line at the far end instead of taking them. That leaves a two-box domino your opponent takes with a single line, called a double-cross, and then they have to move again and open the next chain for you. Giving up two boxes to win a five-box chain next is a bargain. In a loop the same trick costs four boxes, so loops are cheaper to open.

A worked example

Say the safe lines are gone and the board holds two chains: one of 3 boxes and one of 5. You have to open one. Open the 3-chain and your opponent can take all three and then has to open the 5-chain, which gives you 5: you net 2. A good opponent instead takes one box and hands you the last two with a double-cross; now you must open the 5-chain, and they take all of it. You end with 2 boxes to their 6. That is why the long chain rule is about who has to move when the safe lines run out.

Count the parity

Elwyn Berlekamp's long chain rule says the first player wants the number of dots plus the number of long chains to be even, and the second player wants it odd. On the default 4×4 grid (25 dots) that means the first player wants an odd number of long chains. Players steer it by joining or cutting chains during the safe phase, and by sacrificing a box or two to change who makes the last safe move.

Common mistakes

  • Taking every box of the last-but-one chain and then having to open the biggest one.
  • Opening a two-box chain at the end, which lets your opponent double-cross it. Draw the middle line instead: two single boxes can't be declined.
  • Opening a long chain while a short one is still available.
  • Forgetting that one line can close two boxes, and that it still earns only one extra move.

History and names

The French mathematician Édouard Lucas, remembered for the Tower of Hanoi, published Dots and Boxes in the 19th century as la pipopipette. It has also gone by boxes, squares, the dot game, dot to dot grid and pigs in a pen, and generations of children have played it in the margins of school notebooks. Its mathematics was worked out in depth by Elwyn Berlekamp, who wrote a whole book about it, The Dots and Boxes Game: Sophisticated Child's Play (2000). In 2012 Joseph Barker and Richard Korf used a computer search to show that a 4×5 grid of boxes is a tie with perfect play.

More games like Dots and Boxes

For another pencil-and-paper classic, play tic-tac-toe or line up five in Gomoku. If you like counting and planning ahead, try Mancala, where landing in your own store earns another turn, or Connect Four, Reversi and checkers against the computer.

Frequently Asked Questions

How do you play Dots and Boxes?

Start with a grid of dots. Players take turns drawing one line between two neighbouring dots, across or down. Whoever draws the fourth side of a box claims it and must draw another line straight away. When every line has been drawn, the player with the most boxes wins.

Do you get another turn when you complete a box?

Yes. Completing a box earns it and gives you another move, and you keep going for as long as you keep closing boxes. One line can close two boxes at once and still counts as a single extra move. The turn passes only when you draw a line that closes nothing.

Do you have to complete a box if you can?

No. Taking a box is optional, and declining one is the key expert move: by leaving the last two boxes of a chain for your opponent, you force them to move afterwards and open the next chain for you. In casual play most people take every box they can, which is exactly what a good player exploits.

What is the trick to winning Dots and Boxes?

Avoid drawing the third side of a box early on, since that hands your opponent a free box. When there are no safe lines left, the board breaks into chains and loops, and the player who is forced to open the first long chain usually loses. Count the long chains and try to be the player who isn't left to move when the safe lines run out.

What is the long chain rule?

A rule from Elwyn Berlekamp's analysis of the game. A chain of three or more boxes counts as long, and the first player wants the number of dots plus the number of long chains to be even; the second player wants it odd. So on a 4×4 grid of boxes (25 dots) the first player wants an odd number of long chains, and on a 5×5 grid (36 dots) an even number. Whoever gets their parity usually forces the other to open the first long chain. Loops don't count as chains.

What is a double-cross in Dots and Boxes?

A double-cross is a single line that completes two boxes at once. It appears when a player declines the last two boxes of a chain by drawing the line at the far end instead of taking them, leaving a two-box domino. The opponent takes both with one line but then has to move again, which usually means opening the next chain. Declining like that is called double-dealing.

Who invented Dots and Boxes?

The French mathematician Édouard Lucas, best known for the Tower of Hanoi puzzle, published it in the 19th century under the name la pipopipette. It is also known as boxes, squares, the dot game, dot to dot grid and pigs in a pen.

What size grid is best for Dots and Boxes?

A 3×3 grid of boxes (16 dots) makes a quick game and is good for learning. A 4×4 or 5×5 grid gives room for real chain fights and is a good everyday size. Larger grids of 6×6 to 8×8 make long games with many chains. Sizes here count boxes; a 5×5 grid of boxes has 6×6 dots.

Is Dots and Boxes a solved game?

Only on small boards. In 2012 Joseph Barker and Richard Korf showed that a 4×5 grid of boxes ends in a tie with perfect play from both sides. Larger boards haven't been solved, and finding the best move in a general position has been shown to be PSPACE-complete, a class of very hard problems.

Can you beat the computer at Dots and Boxes?

Easy hands out boxes and is beatable from the first game. Medium never gives a box away while it has a safe line but doesn't understand chains, so you can beat it by winning the chain fight. Hard plays the chain endgame exactly, with double-crosses and sacrifices, and searches the last safe moves, so beating it takes real chain counting.

Are my games and record saved?

Yes, in this browser only. Your settings, the game in progress and your record against each level are kept in local storage on your device, so a reload or a visit to another page doesn't lose them. Nothing is uploaded, and Reset record in Options clears the statistics.

More games to play

Free, browser-based, and instant — no installs or accounts.

More strategy & party games

Popular games