Dots and Boxes

Public domain classic

Close the boxes. Steal the chain.

Dots and Boxes

At a glance

Board
6 by 6 dots, which make 25 boxes and 60 lines
Players
You (lime) against the computer (pink). You draw first
Levels
Hard, set when the page opens, and Easy
Controls
Tap or click on or near a line between two dots. Esc pauses. There is no keyboard play
Score
The number of boxes you took
Saves
Your best score, in this browser only
Cost
Free, no account

How this Dots and Boxes plays

  • On your turn you draw one line. A tap picks the nearest undrawn line as long as it is within 22 pixels or about a quarter of a box, whichever is larger. A tap in the middle of a box draws nothing.
  • Drawing the fourth side of a box claims it, marked Y for you or C for the computer, and you draw again. One line can close two boxes at once.
  • A line that closes nothing passes the turn. The computer waits half a second before each of its lines.
  • The game ends when all 25 boxes are claimed. With an odd number of boxes there is never a tie.

How the computer plays

Both levels follow the same three steps:

  1. If a box has three sides, it draws the fourth. It repeats this while boxes are ready, so it takes a whole chain, and after that it still has to draw one more line.
  2. Otherwise it draws a random line that gives no box its third side.
  3. When no such line is left, Hard counts how many boxes each possible line would hand you, following the chain, and draws the one that gives away fewest. Easy draws any free line at random.

So the levels only part ways near the end. In the rule test, given the same random numbers, they drew the same line in all 50 positions where a safe line was left. In 60 positions with no safe line, they chose differently in 59, and Hard's lines gave away 84 boxes in total against 359 for Easy's. Both levels won all 50 test games against random lines.

Tips that follow from its rules

  • It never turns a box down. Hand it a chain and it takes every box, then has to draw again, and if no safe line is left that line gives boxes back to you.
  • Watch the safe lines run out. Until they do, both levels draw harmlessly at random. Once they are gone, every line gives a box its third side.
  • Hard looks only at the line it is about to draw. Its count stops at the boxes that one line gives away.

For a game where you line up discs instead of closing boxes, try Four in a Row.

Known limits

  • No undo.
  • No keyboard play: use a mouse or touch screen.
  • The level menu only appears before a game. Press New to change it.
  • On a 390 by 844 screen each box is 64 pixels across.
  • In a 1280 by 720 window the 570-pixel board sits inside an 848-pixel game area, and its lower rows run past the window until you scroll.
  • Leaving the tab pauses play.
  • With storage blocked your best score is not kept.

How it was built and checked

AI tool
Codex
First committed
2026-10-14, in a batch of 10 classic games
Size
One HTML file of 162 lines, no game libraries
Rounds of changes
1, from the build record
Checked at build
The build check let the computer play a whole game against itself until all 25 boxes were taken, and drew the screen against a stand-in page at three sizes. It names real browser rendering, physical touch input and full human playthroughs as not verified
Checked since
2026-11-11: a new rule test (12,618 checks covering the board, scoring and extra turns, the end, the computer's three steps, 60 end positions where the levels differ, 100 games against random lines, and taps through the real pointer code), and an automated browser check of the local build at 1280 by 720 and 390 by 844. Each time it pressed Play, on Hard at desktop size and on Easy at phone size, tapped lines until all 25 boxes were taken, and pressed Play Again
Played on a phone
2026-11-11, a full game on a real phone before this page went live

Embed Dots and Boxes on your site

Free to embed. Please keep the credit link.

<div style="position:relative;padding-top:75%;max-width:640px"><iframe src="https://aivibecodedgames.com/games/dots-and-boxes/" title="Dots and Boxes (free browser game)" style="position:absolute;inset:0;width:100%;height:100%;border:0" loading="lazy" allow="fullscreen" allowfullscreen></iframe></div>
<p><a href="https://aivibecodedgames.com/play/dots-and-boxes/">Play Dots and Boxes free</a> on AI Vibe Coded Games</p>

How it was vibe coded

ToolCodex
Rounds of changes: 1
First committed2026-10-14

The opening prompt

Make Dots and Boxes on a 5x5 box grid (6x6 dots), you versus the computer. Completing a box scores and gives another turn. Computer: take any box that is available, otherwise avoid giving a third side, otherwise give away the shortest chain. Easy mode is random-safe. Show scores and colour boxes by owner. Large tap areas on mobile.

Game controls

  • Tap or click between two dots to draw a line

The game brief includes touch controls for phones.

Open the game on its own

More games