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.