Skip to the game
Tic Tac Toe

Dots and Boxes

Draw lines between dots, close a box to claim it, and go again in Dots and Boxes, against a three-level computer or a friend on one screen.

Play Dots and Boxes

You
00 wins
Computer
00 wins

Draws: 0

Setting out the dots…

Tap between two dots to draw a line. Draw the fourth side of a box to claim it, then go again. When every line is drawn, the most boxes wins. With a keyboard, move between lines with the arrow keys and press Enter; H gives a hint, U undoes, and N starts a new game.

Game settings
Changing a setting starts a new game. Each opponent keeps its own score.
Opponent
Difficulty
First move
Board

How it works

How to play Dots and Boxes

Take turns joining two neighboring dots, claim every box you close and draw again, and try never to draw the third side of a box.

  1. Step 01

    Draw a line

    Tap or click the gap between two neighboring dots, across or down. Your lines take your color.
  2. Step 02

    Close a box

    Draw the fourth side of a box to claim it, then draw another line. One line can close two boxes at once.
  3. Step 03

    Claim the most boxes

    When every line is drawn, the player with more boxes wins. On the 4×4 board, an 8–8 split is a draw.

Features

Dots and Boxes with a computer that knows the endgame

  • Easy, Medium, and a Hard level that plays chains

    Easy often misses boxes it could take, Medium never hands one over while a safe line is left, and Hard plays the chain endgame.

  • Player 1 in blue, Player 2 in red

    Play a friend on the same phone, tablet, or computer. Player 1 draws first.

  • 3×3, 4×4, or 5×5 boxes

    9, 16, or 25 boxes to claim, from a quick game to a long, tense one.

  • A hint that explains its line, and undo

    A hint lights up the line Hard would draw. Undo takes back your last line and the computer's reply.

  • Arrow keys between lines, every box announced

    Move between lines with the arrow keys and press Enter to draw. Lines and boxes are labeled, and every turn is announced.

  • A scoreboard for every opponent

    Wins and draws are kept for each opponent, and a game in progress waits for you in this browser.

Strategy

Dots and Boxes strategy: chains and the double-cross

Early lines hardly matter. Games are won when the safe lines run out and the board splits into chains.

  • Don't draw a third side

    A box with three sides is a gift to the other player. While a safe line is left anywhere on the board, draw that instead.

  • Give away the shortest chain

    When every line gives something away, open the shortest chain first. Open a 2-box chain with the line in its middle, so your opponent can't decline it.

  • Learn the double-cross

    Taking a long chain with more chains to come? Stop two boxes short and draw the line at the far end. Your opponent takes the pair and has to open the next chain.

  • Loops cost four

    In a closed loop, the same trick means leaving four boxes, not two. It only pays when enough boxes are still to come.

  • Count the long chains

    By the long chain rule, the first player wants an even number of chains of 3 or more boxes on 3×3 and 5×5, and an odd number on 4×4.

  • Fight for control early

    Whoever has to open the first long chain usually loses. Experts give up a box or two before then to change the count.

About the game

Dots and Boxes: the pencil-and-paper game of lines and chains

The rules, the boards, the computer levels, chains and the double-cross, controls, scores, and where the game came from.

Dots and Boxes is the pencil-and-paper game where two players take turns joining dots and claim every box they close. It looks like a game of grabbing boxes, but strong players win it by counting chains. Here you play a computer with three levels or a friend on the same screen.

The rules of Dots and Boxes

The board starts as a grid of dots with no lines. On your turn, draw one line between two dots that sit next to each other, across or down. If your line finishes the fourth side of a box, the box is yours: it fills with your color and initial, and you must draw another line. A line between two boxes that both have three sides claims both at once.

Your turn ends only when you draw a line that closes nothing. The game is over when every line is drawn, and the player who claimed more boxes wins. On the 4×4 board, with 16 boxes, an 8–8 split is a draw. The 3×3 and 5×5 boards have an odd number of boxes, so one player always wins.

Three boards, counted in boxes

Board sizes count boxes, not dots. Pick one under Board in Game settings:

  • 3×3: 9 boxes, 16 dots, and 24 lines. The quickest game, and a good one for learning how chains form.
  • 4×4: 16 boxes, 25 dots, and 40 lines. This is the board a first visit starts on.
  • 5×5: 25 boxes, 36 dots, and 60 lines. Elwyn Berlekamp, who wrote a book on the game, called this size challenging yet short enough to finish.

Changing the board, the opponent, the difficulty, or who moves first starts a new game.

How Easy, Medium, and Hard draw their lines

The computer has three levels, and each keeps its own scoreboard of wins, draws, and losses:

  • Easy takes a box on offer about 7 times in 10. Otherwise it picks a safe line 6 times in 10 and any line at all the rest of the time, so it often hands boxes over. A good level for children and first games.
  • Medium takes every box it can and never gives one away while a safe line is left. When the safe lines run out, it draws the line that gives away the fewest boxes.
  • Hard plays like Medium until the safe lines are gone. Then it works out the chains and loops left on the board, opens the one that costs it least, and declines the last two boxes of a chain whenever that wins more in the end.

Under First move, choose whether you or the computer draws the first line. The computer draws its lines one at a time, and the status line tells you how many boxes it took.

Blue against red on one screen

Choose 2 players to play a friend on the same phone, tablet, or computer. Player 1 always draws first, in blue, and Player 2 plays in red. The scoreboard counts boxes in the current game and keeps wins and draws for all your two-player games. Swap seats between games so each of you gets to start. Both players share the one device: there's no play over the internet.

Chains, loops, and the double-cross in Dots and Boxes

For most of a game, players draw safe lines, the ones that don't give any box its third side. Sooner or later the safe lines run out. By then the undrawn lines have split the board into chains, rows of boxes that fall one after another once the first is taken, and loops, chains that join back on themselves. From that point, every move opens something for the other player.

The obvious play is to take every box on offer and then open the shortest chain. Strong players often take all of a long chain except the last two boxes and draw the line at the far end instead. Berlekamp calls this a double-dealing move. The opponent takes both boxes with one line, the double-cross, and then has to open the next chain.

Here's how it pays. Say two chains of 3 are left and your opponent opens the first. Take all three and you must open the second, so those boxes split 3–3. Take one, give away two, and your opponent has to open the second chain: you finish 4–2. In a loop, the same trick leaves four boxes.

The long chain rule

Because whoever opens the first long chain usually loses, the real fight comes earlier, over who will have to do it. Berlekamp's book gives a rule of thumb for it, the long chain rule, where a long chain means 3 boxes or more. Add the number of dots to the number of long chains at the end of the game. The first player wants that total to be even, and the second player wants it odd. On the boards here, that works out to:

  • 3×3 (16 dots) and 5×5 (36 dots): the first player wants an even number of long chains.
  • 4×4 (25 dots): the first player wants an odd number of long chains.

Loops and sacrifices complicate the count, so treat it as a guide. When the count is heading the wrong way, experts give up a box or two early to split or join chains.

Drawing lines by touch, mouse, or keyboard

Every gap between two dots is a button, so there are three ways to draw a line:

  • Mouse or touch: click or tap the gap between two dots to draw a line. The last line drawn is marked, so you can see what just changed.
  • Keyboard: Tab to the board, move between lines with the arrow keys, and press Enter or Space to draw. H shows a hint, U undoes, and N starts a new game.
  • Screen readers: every line has a label with its place on the board and who drew it, claimed boxes say who owns them, and the status line announces each turn and every box taken.

Escape closes the result card at the end of a game, and N or New game deals a fresh board with the same settings.

Habits that stop you giving boxes away

A few habits that help against Easy and Medium:

  • Before every line, check the boxes on each side of it. If either would get its third side, look for another line.
  • Use the Hint button when you're stuck. It says whether the glowing line claims a box, gives nothing away, or simply costs the least.
  • When you must give something away, count the boxes in each chain and open the smallest.
  • Try the double-cross on Medium first. It doesn't use the trick, so you'll see clearly how much it gains.

If you enjoy games with a hidden mathematical trick, try Nim, where binary numbers point to every winning move, or Chomp.

From Lucas's pipopipette to Winning Ways

The French mathematician Édouard Lucas described the game in 1889 under the name la pipopipette, and it appeared again in his book L'arithmétique amusante in 1895. It has gone by many names since, including boxes, dots and dashes, and pigs in a pen.

Elwyn Berlekamp, John Conway, and Richard Guy gave it a chapter of Winning Ways for Your Mathematical Plays in 1982, and Berlekamp wrote a whole book on it, The Dots-and-Boxes Game: Sophisticated Child's Play, in 2000. In 2021, Kevin Buchin and three colleagues proved that playing it perfectly is PSPACE-complete, a class of problems that computer scientists believe have no fast general solution.

A board that waits for you

No account is needed. The page needs a connection to load, and after that each hint and computer reply is worked out in your browser. Your lines and scores aren't sent to a server. Your opponent, difficulty, first move, and board size, a scoreboard of wins, draws, and losses for each opponent, and the board you're partway through are kept in this browser's local storage. Come back to a 5×5 game left mid-chain and the status line says Game restored. Reset scores clears the scoreboards, and the privacy policy lists everything kept.

FAQ

Dots and Boxes questions

Quick answers about playing Dots and Boxes online: extra turns, draws, board sizes, the computer, and saving.

How do you play Dots and Boxes?

Take turns drawing a line between two neighboring dots. Draw the fourth side of a box to claim it and draw again. When every line is drawn, the player with more boxes wins.

Do you get another turn after closing a box?

Yes. Each time your line claims a box, or two boxes at once, you draw another line. Your turn ends when you draw a line that closes nothing.

Can Dots and Boxes end in a draw?

Only on the 4×4 board, where the 16 boxes can split 8–8. The 3×3 and 5×5 boards have 9 and 25 boxes, so someone always wins.

What board sizes can I play?

3×3, 4×4, or 5×5 boxes, which means 16, 25, or 36 dots. The game starts on 4×4, and changing the board starts a new game.

How hard is the computer?

Easy often gives boxes away. Medium takes every box on offer and never hands one over while a safe line is left. Hard also plays the chain endgame, including declining the last two boxes of a chain.

Who moves first?

Against the computer, you choose under First move: you or the computer. In 2 players mode, Player 1 always draws first.

What is the double-cross in Dots and Boxes?

When you're taking a long chain and more chains are left, take all but two boxes and draw the far line. Your opponent takes the pair with one line, the double-cross, and then has to open the next chain. See the strategy tips.

Can I play Dots and Boxes with a friend?

Yes, sitting together at one device. Pick 2 players under Opponent: Player 1 draws in blue and Player 2 in red. There's no online play.

Will a half-finished board still be here later?

Yes, if you come back in the same browser. Your settings, a scoreboard for each opponent, and the game in progress are kept in its local storage. Reset scores clears the scoreboards.