KOJP

Dots and Boxes Online Game

Draw one line at a time between the dots, close the fourth side of a box and it is yours. Three computer levels or two players, 3×3 to 7×7

3×3 · 5×5 · 7×7 boxes · Easy, Normal, Hard computer · Two players

Whoever draws the fourth side of a box takes it and draws again. When every line is in, the side with more boxes wins. The Hard computer counts chains and uses the double-cross. Your board size and win record are saved in this browser.

Controls

Tap between two dots: draw a line
Hover with the mouse to see the gap as a dotted line
Arrow keys: pick a gap · Enter or Space: draw
M or Esc: menu · Two players take turns on one screen

What is Dots and Boxes?

Dots and Boxes is a pencil game on a grid of dots where two players take turns joining two neighbouring dots with a line, and whoever completes the fourth side of a box claims it. Claiming a box earns another turn, and when every line is drawn the player with more boxes wins.

It began as a game played in the corner of a school notebook and is also known as the dot game, boxes, squares or pigs in a pen. The French mathematician Édouard Lucas published it in 1889, and it has been a classic ever since. The rules fit in two lines, but the endgame hides a deep theory of chains and double-crosses that mathematicians have written an entire book about.

What exactly are the rules?

There are three. One line per turn, closing the fourth side makes the box yours, and claiming a box means you move again. If one line closes the boxes on both of its sides, you take both.

SituationWhat happens
You draw a line and no box closesThe turn passes to the other player
You draw the fourth side of a boxYour stamp goes in the box and you draw again
One line closes the box on each sideBoth boxes are yours, and you still draw again
You claimed a box but every line left is badYou must still draw one. There is no passing
Every line is drawnMore boxes wins, equal boxes is a draw

The 3×3 board has 16 dots and 24 lines, 5×5 has 36 dots and 60 lines, and 7×7 has 64 dots and 112 lines. All three have an odd number of boxes, so a draw is impossible.

Why should I never draw the third side?

Because once a box has three sides, the opponent draws the fourth, takes the box and moves again. That is why the opening is spent drawing only safe lines, where nobody gives a box away.

A safe line is one that does not bring any box to three sides. As the board fills up, safe lines run out, and eventually somebody has to draw a third side and hand over boxes. That moment is where the real game begins. The Normal computer knows this rule; the Easy computer sometimes forgets.

What is a chain?

A chain is a run of boxes that each have exactly two sides drawn, linked together. Draw one line at the end of a chain and the opponent can take every box in it, one after another, in a single turn.

ShapeCharacterIf you open it
Short chain (1 or 2 boxes)A small lossThe opponent takes 1 or 2 boxes and must open the next chain
Long chain (3 or more)The heart of the endgameThe opponent takes it all, or leaves 2 boxes and keeps control
Loop (boxes joined in a ring)No endsThe opponent takes it all, or leaves 4 boxes and keeps control

When the safe lines are gone, the remaining boxes split into a few chains and loops. The winner is the player who gives away the short chains and makes the opponent open the long ones. Whether the number of long chains is odd or even decides who has to open first, which is why strong players start counting long chains in the middle of the game.

What is the double-cross?

The double-cross is declining the last two boxes of a long chain the opponent opened for you, and drawing a different line instead so that the opponent takes those two boxes with one line and then has to open the next chain. You give up two boxes to win every long chain that remains.

The opponent opens a 5 box chainYou getAnd then
Take all 5+5You must open the next chain and the opponent eats it whole
Take 3, leave 2 (double-cross)+3, opponent +2The opponent must open the next chain and you eat it whole

If only one long chain is left, take everything. If two or more remain, the double-cross is almost always right. The Hard computer counts every remaining chain and loop, scores both paths and picks the better one. When you have to give away a 2 box chain, draw its middle line, not the end: the opponent then cannot double-cross and simply has to take both and open the next.

How do the three computer levels differ?

Easy draws any safe line, Normal always closes a box it can and avoids third sides, and Hard counts chains and loops and plays the double-cross.

LevelOpeningEndgame
EasyRandom safe linesSometimes misses a box and opens long chains without a care
NormalRandom safe linesTakes every box it can and opens the smallest group when forced
HardReads to the end once fewer than 12 safe lines remainSearches the chain and loop structure, double-crosses and uses the hard-hearted handout

In test matches the Hard computer beat the Normal computer in 98 of 100 games on the 5×5 board. To beat it you will have to count chains too.

Any tips for winning?

  1. Never draw a third side. Almost every early mistake is this one. Hover to see the gap, count the sides of the boxes on both sides, then draw.
  2. Count the safe lines left. If an odd number remain, the player to move draws the last safe line and the opponent has to open first.
  3. Fix the number of long chains. Split or join chains in the middle game so that the opponent is the one fated to open a long chain.
  4. Open short chains in the middle. The middle line of a 2 box chain denies the double-cross; the opponent just takes both.
  5. Leave two when you receive a long chain. If more long chains remain, the double-cross almost always pays.

Controls

Board size, last mode, sound setting and your wins against each computer level are stored in this browser only and never sent to a server.

Frequently asked questions

Is Dots and Boxes free?

Yes. It is free with no sign up, works on computers, phones and tablets, and there is nothing to install.

How many lines do I draw per turn?

One. But when you draw the fourth side of a box you take it and immediately draw again, and again if that closes another box, until a line closes nothing.

What if one line closes two boxes at once?

Both boxes on either side are yours and you still draw again. This happens when the opponent leaves two boxes with a double-cross in the endgame.

How do I choose the board size?

Press 3×3, 5×5 or 7×7 on the title screen, then pick a mode. The number is how many boxes there are per side; there is one more dot than boxes in each row. Your choice is remembered next time.

Can the game end in a draw?

Not on these boards. 3×3, 5×5 and 7×7 have 9, 25 and 49 boxes, an odd number, so the two sides can never tie.

How do I beat the Hard computer?

Never draw a third side, and count the long chains before the safe lines run out. Make the computer open the long chains first, and when it hands you one, leave the last two boxes as a double-cross to keep control.

How does two player mode work?

Choose Two players on the title screen and Blue and Red alternate on one screen. A yellow highlighter marks whose turn it is, so just put one phone between you.

Is anything saved?

Board size, last mode, sound setting and your wins against the Easy, Normal and Hard computer are saved in this browser. Nothing is sent to a server.