PlayNook

Tic-Tac-Toe on Bigger Boards: 4x4, 5x5 and Up

strategymaths

Title graphic reading Tic-tac-toe on bigger boards, showing a three by three grid beside a four by four and a five by five grid, with the four in a row and five in a row targets marked

Want to try it? Gomoku is playable right here.

Play Gomoku

Everybody works out that ordinary tic-tac-toe is a draw, and the obvious next thought is: make the board bigger.

It does not work. A bigger board on its own makes the game worse — it hands the first player a forced win. To get a real game back you have to lengthen the line as well, and there are only a few combinations that land in the right place.

Here they are, each one solved completely rather than guessed at.

  • 4×4 with three in a row — a first-player win, so not worth playing
  • 4×4 with four in a row — drawn, and the smallest good bigger board
  • 5×5 with four in a row — still drawn, and the best of the small set
  • Nobody ever wins as second player — that is provable, on any size

Which board sizes are worth playing?

Two numbers define the game: the board, and how many in a row you need. Written together they make the name — the ordinary game is 3,3,3.

Grid of solved tic-tac-toe variants. On a 3 by 3 board three in a row is drawn. On 4 by 4, three in a row is a first-player win while four in a row is drawn. On 4 by 5 and 5 by 5, four in a row is drawn and on 5 by 5 five in a row is also drawn, while three in a row is a first-player win on every board larger than 3 by 3.
Every cell searched from the empty board to the end. Red means the game is already decided before anybody sits down.

The pattern is the useful part: keeping three in a row and enlarging the board breaks the game immediately. On 4×4 the first player already wins, and it only gets worse from there.

Four in a row, on the other hand, holds up. It is drawn on 4×4, on 4×5 and on 5×5 — three genuinely playable variants, and the largest of them is the one worth learning.

How do you play 4x4 tic-tac-toe?

Sixteen squares, and you need four in a row — horizontally, vertically or diagonally. Everything else is unchanged: take turns, place one mark, first line wins, full board is a draw.

Do not play 4×4 with three in a row. It looks like the natural extension and it is a solved win for whoever starts, which the table above shows costs about forty thousand positions to prove and one game to notice.

How do you play 5x5 tic-tac-toe?

Twenty-five squares, and four in a row is the version to use. It is drawn with correct play, the board is big enough that the draw is not obvious, and games last long enough to be interesting.

Five in a row on 5×5 also works — it is drawn too — but it is much duller, because a line of five on a board of five has only twelve places it can go. You spend the game watching the same handful of rows.

Why does a bigger board favour whoever starts?

Because the two sides are not doing the same job. The attacker needs one line. The defender has to stop all of them.

Two bar charts. On the left, holding three in a row fixed while the board grows from 3 by 3 to 6 by 6 takes the number of winning lines from 8 to 80. On the right, holding the 5 by 5 board while the required line grows from three to five takes it from 48 down to 12.
Counted directly from the geometry of each board.

Hold the line length at three and grow the board, and the number of winning lines runs away: 8 lines on 3×3, 80 on 6×6. The defender's job grows ten times over while the board only grows four times. That is the whole reason the game breaks.

Lengthening the line pulls hard in the other direction. On the same 5×5 board, going from three in a row to five cuts the lines from 48 down to 12. The two effects have to be balanced against each other, and that balancing act is the entire design problem.

Is there a rule of thumb for designing your own?

There is one, and it falls straight out of the solved boards: divide the number of winning lines by the number of squares.

BoardIn a rowLines per squareResult
5×550.48drawn
4×440.63drawn
4×540.85drawn
3×330.89drawn
5×541.12drawn
6×541.30first player wins *
4×431.50first player wins
4×531.70first player wins
5×531.92first player wins

* 6×5 is the expensive one: 13.3 billion positions and an hour and a half, against 64 million and forty seconds for 5×5. It is in the table because it is the first win for four in a row, and so it pins down where the tipping point lies. The result matches Uiterwijk'sSolving Strong and Weak 4-in-a-Row, IEEE Conference on Games 2019 — which proves the 5×6 board a first-player win, and a monotone one at that. We did not use that as an input; the search was run before the paper was found.

Every draw sits at 1.12 or below; every win at 1.30 or above. The tipping point lives in that narrow gap.

So if you are inventing a variant — a hexagonal board, a board with holes in it, whatever — count the lines, divide by the squares, and if the answer is much past one, expect the first player to win and lengthen the line before you bother playing it.

This is a rule of thumb read off these nine cases, not a theorem. But it costs thirty seconds and it will save you an evening.

How do you actually win on a bigger board?

The same way as on the small one, only with more room for it: the double threat. One mark that creates two separate lines-of-three at once. The opponent blocks one and you complete the other.

Everything else is preparation. On 4×4 and 5×5 you are not trying to build a line directly — a line you build in the open simply gets blocked at one end. You are trying to arrange marks so that a single future move opens two threats that cannot both be answered.

Which is why the lines-per-square number matters so much. More lines through each square means more chances for one mark to sit on two threats at once, and that is precisely what tips a game from drawn to broken.

Why can the second player never win?

Not "usually does not" — cannot, on any board, with any line length. The argument is short enough to give in full.

Suppose the second player had a winning strategy. Then the first player could simply steal it: make one arbitrary move anywhere, then pretend to be the second player and follow that strategy. In this game an extra mark of your own never hurts you — there is no rule that punishes having more on the board. So the first player would win too, and both cannot win the same game.

Therefore no second-player win exists, and every entry in the table is either a first-player win or a draw. The solver checks this at the root of every search rather than assuming it.

What about a 16x16 board, or bigger?

At that size you are no longer playing tic-tac-toe — you are playing Gomoku, which is five in a row on a large grid and a real game with a real literature.

Two things worth knowing before you set one up:

  • Free-style Gomoku on the standard 15×15 board is a first-player win. That was established by computer proof (L.V. Allis, 1993). Serious play therefore uses opening restrictions to claw the balance back.
  • The turning point for four in a row is 6×5, which is a first-player win while 5×5 is drawn. Four in a row simply runs out of room to stay fair very quickly.

So the honest advice for a big grid is: use five in a row, expect the first player to have an edge, and adopt an opening rule if you play seriously.

How were these worked out?

Each cell of the table is a complete search of the game from the empty board, using the same three ideas that make such searches finish at all: alpha-beta pruning, a table of positions already evaluated, and folding the eight symmetries of the board into one.

Two checks sit under the results, because a solver that only agrees with itself has proved nothing:

  • Every board small enough is also solved by brute force — no table, no pruning, no symmetry, just the whole tree. Both methods must agree, and the script stops if they do not.
  • The 5×5 result was recomputed without symmetry folding — 1.73 billion positions instead of 63.9 million, an entirely different path through the search — and returned the same answer.

That second check earned its keep. The 5×5 four-in-a-row result came out drawn when we expected a first-player win, and the natural reaction was to distrust the solver. The solver was right; the expectation was wrong — 5,5,4 is a draw, and the first win for four in a row is 6,5,4.

There is a third check, and it is the one worth having. The 6×5 board was searched here in full — 13,334,540,017 positions over an hour and a half — and it comes out a first-player win, which is what Uiterwijk (IEEE CoG 2019) proved by an entirely different route. Two methods with nothing in common landing on the same answer is worth more than either alone.

Where to go next

If the bigger boards appeal, Gomoku is where this line of thinking ends up, and Four in a Row is the same idea with gravity added — which changes it completely.

For the ordinary board there is how many tic-tac-toe games there are with every counting question worked through, and who invented tic-tac-toe, where the Roman version turns out to be a different game. If you just want grids to play on, the printable tic-tac-toe sheets are here.