N-in-a-Row Games, Parts 1 & 2

These are two classic gPress posts, originally uploaded August 28, 2022 and September 2, 2022 respectively, combined into one.

Some years back, I challenged a friend to a long (100-game) series to determine who would be the World Champion Tic-Tac-Toe player. What started as a jest developed into a serious interest into the world of n-in-a-row games. In these posts, I over-analyze simple things, show the depth of the better games, and try to instill an interest in them.

Tic-Tac-Toe, three in a row…

Tic-Tac-Toe is proven to be a draw with perfect play, but it is a good starting point to understand the principles of n-in-a-row games.

As everyone in the western world knows, in a regular game of Tic-Tac-Toe, there are nine squares, in three rows and columns. Each player, X and O, take turns placing one of their pieces on an unoccupied square. If there is three-in-a-row of one piece, that player wins. Otherwise the game is a draw (or “cat” game).

Breaking it down more mathematically, we see that on a three-by-three (3×3) Tic-Tac-Toe board, there are eight possible rows of three: the two diagonals, three horizontal, and three vertical. Because the board layout is symmetrical, each corner and edge square initially have identical value. This also means that there are only three openings: center, corner, and edge. In general, a square that has more possible n-in-a-rows through it is a more powerful square, so the center square, which can be in four possible rows, would seem to be the strongest starting position.

a b c
3
2 X
1

In this situation, O has two options, a corner or an edge. After subtracting the rows that are made unwinnable due to the first player’s move, any corner has two rows that go through it; any edge has only one, so the corner is mathematically and intuitively the stronger square.

(If we play the edge, we find that the edge defense loses; X plays either a corner or an edge diagonal to the edge chosen, forcing O to defend against 3r, then X can immediately set up a 3r threat from both of his previous squares.

Center Game, Edge Blunder, Corner Variation
1. b2 a2
2. a1+ c3
3. c1#

a b c
3 O
2 O X
1 X X

On the other hand, after the corner move, although X is in the stronger position and has the initiative, he is usually unable to win. Most moves he makes will set up a 3r threat, but can also be immediately and directly countered by O.

Center Game, Corner Line
1. b2 a1
2. a3+ c1+
3. b1+ b3
4. c2+ a2~ (draw)

a b c
3 X O
2 O X X
1 O X O

X does have one possible option for a trap:

Center Game, Trap Sprung
1. b2 a1
2. c3 a2+
3. a3#

a b c
3 X X
2 O X
1 O

The proper defense is to play on a corner.

Center Game, Trap Avoided
1. b2 a1
2. c3 c1+
3. b1+ b3 … and draw

a b c
3 O X
2 X
1 O X O

This sums up the center game.


Because of the simplicity of the defense against it, the center opening is sometimes eschewed in favor of a corner attack.

a b c
3
2
1 X

Consider the position O is in. A corner is taken, meaning that there are only five out of the eight possible rows that O can still win. The center now has three such paths; each remaining corner has two. The edges orthogonal to the occupied corner have one, but the others still have two.

The corner and edge defenses are fatally flawed in a similar fashion to the edge defense previously discussed.

Corner Game, Opposite Corner Blunder
1. a1 c3
2. c1+ c2
3. a3#

a b c
3 X O
2
1 X O X

Corner Game, Adjacent Corner Blunder
1. a1 c1
2. c3 b2
3. a3#

a b c
3 X X
2 O
1 X O

Corner Game, Opposite Edge Blunder
1. a1 b3
2. a3+ b2
3. c1#

a b c
3 X O
2 O
1 X X

Corner Game, Adjacent Edge Blunder
1. a1 a2
2. b2+ a3
3. c1#

a b c
3 O
2 O X
1 X X

So, O moves in the center.

a b c
3
2 O
1 X

Because of O’s move, X’s square is now worse than it was previously, and is actually worth a little less than O’s. Having the first move advantage means he keeps the momentum, but this is only enough to guarantee a draw. Why, then, does anyone prefer the corner?

If O isn’t careful, she may wander into a trap.

The favorite X response is normally to play the corner opposite to his initial move, which sets up the corner trap: if O moves in one of the other corners, X takes the third corner, blocking 3r and creating two 3r threats of his own, winning the game.

Corner Game, Corner Trap Sprung
1. a1 b2
2. c3 a3+
3. c1#

a b c
3 O X
2 O
1 X X

A more subtle but similar variation is the edge trap. X plays in one of the edges adjacent to the opposite corner. If O plays in the wrong corner (the corner furthest from the other two squares), X can again block her 3r attempt and create two threats of his own.

Center Game, Edge Trap Sprung
1. a1 b2
2. b3 c1+
3. a3#

a b c
3 X X
2 O
1 X O

However, both of these traps require specific wrong moves from O to succeed. With other easily found moves, the game will end with a draw after a series of blocked 3r attempts. Some games may run out of possible rows before they run out of moves.

Corner Game, Corner Trap Avoided
1. a1 b2
2. c3 a2+
3. c2+ c1+
4. a3+ b3+
5. b1 and draw

a b c
3 X O X
2 O O X
1 X X O

Corner Game, Edge Trap Avoided
1. a1 b2
2. b3 a3+
3. c1+ b1 and an easy draw

a b c
3 O X
2 O
1 X O X

Some players have criticized the edge opening and claimed that it loses outright. This is false, but it does require more precise play from X than the other lines. However, because some players are unfamiliar with this system, this may be a way to try for a win.

There are unsound defenses from O that lose by force. These are the adjacent edge and opposing corner.

Edge Game, Adjacent Edge Blunder
1. a2 b3
2. a3+ a1
3. b2#

a b c
3 X O
2 X X
1 O

Edge Game, Opposite Corner Blunder
1. a2 c1
2. a1+ a3+
3. b2#

a b c
3 O
2 X X
1 X O

On the other hand, the center, opposing edge, and adjacent corners are all solid defensive options, with good chances for O if X makes a mistake.

Edge Game, Center Defense
1. a2 b2
2. b3 a3+
3. a1+ a3+
4. c1+ b1 and draw

a b c
3 O X O
2 X O
1 X O X

Edge Game, Symmetrical Defense
1. a2 c2
2. c1 a1 and draw

a b c
3
2 X O
1 O X

Edge Game, Adjacent Corner Defense, Opposite Blunder
1. a2 a1
2. c2+ b2+
3. c3+ c1#

a b c
3 X
2 X O X
1 O O

There are a couple of principles that we can observe in this. The first is that the direct approach seems less successful in an n-r game. The attacks with the best chance of working involve delayed actions that produce multiple threats. Anyone can notice when you have two pieces lined up in a row against him, but it is possible to miss the point of a ‘developing’ move and respond with a play in a bad square.

The second is that when it comes to balanced games, you don’t win so much as wait for your opponent to lose. If your adversary intends to draw, and moves with the purpose of blocking you as much as possible, there’s no reason they shouldn’t be able to get what they’re after. They are in danger when they decide to play a tricky game and try to ‘steal’ a victory. Of course, the larger and more complicated the game, the less applicable this is.

On that note, stay tuned for the next part, where we discuss some more advanced n-in-a-row games – Tic-Tac-Toe on larger boards, both balanced and imbalanced games.

* * *

Considering the ubiquity of regular Tic-Tac-Toe, it is curious that few have thought to take their game to the next level. In this article, we will explore the next step in n-in-a-row play, larger boards and larger row requirements.

It is evident after a brief look that an expanded Tic-Tac-Toe game is going to require more than three-in-a-row. For a thought experiment, consider the play of Tic-Tac-Toe+1. This game is exactly like Tic-Tac-Toe, except that an extra square is added onto the edge of the board: next to any of the existing squares, either horizontally or diagonally.

If the new square is anywhere but to the diagonal of a corner square, the game becomes a forced win for X:

New Square at a4, Game 1
1. a3 b2
2. a2#

New Square at a4, Game 2
1. a3 a2
2. b2+ c1
3. b3#

New Square at b4, Game 1
1. b2 c3
2. b3#

New Square at b4, Game 2
1. b2 b3
2. a3+ c3
3. a1#


By the same measure, a greater row requirement can lead to a game that is too easily drawn, even by the standards of a game like Tic-Tac-Toe. A brief playthrough of 4-in-a-row on a 4×4 board should illustrate the point.

A Bad, Boring 4×4 Game
1. a1 c3
2. b1 b3
3. c1+ d1
4. a2 d2
5. a3+ a4+
6. c2 d4+ 7. d3 c4+
8. b4 and a draw

The best size for a board tends to be the largest one that is not proven to be a win for the first player. For 4-in-a-row games, the only suitable symmetrical board is 5×5 [1].


Given a 5×5 board and 4r, what does the opening play look like?

Although X may have motivation to try different options in Tic-Tac-Toe, in this game, there is no reason to play anything but the center. This gives him the most room to expand his attack.

At this point, O must move in a square diagonally adjacent to the center. Anything else is a forced win for X.

Edge Defense Refutation
1. c3 b3
2. b4 d2
3. d4 c4
4. b2#

a b c d e
5
4 X O X
3 O X
2 X O
1

Time and space don’t presently allow an exhaustive listing of X’s options after a corner defense, but the strategy is focused on getting one of the possible combinations which lead to 4r in short order, which include:

  • 1 three-in-a-row, with no pieces blocking either end.

  • 2 simultaneous three-in-a-rows, either or both of which may be blocked on one end.

  • 2 simultaneous two-in-a-rows, with no pieces blocking either end.

A solid strategy for this game is to play the center of the board as a regular game of Tic-Tac-Toe. If you keep this foundation in order, the threats at the edges are easy to prevent. The biggest problem a player is likely to run into is the desire to ‘cheat’ by playing a move oriented towards getting a winning threat when they should be focused on defense.

A Sample 5×5 Game
1. c3 b2
2. b4 d2
3. e2 d4?!
(Complicates the game, but probably for the worse.)
4. d3 c2!
Saves the draw.
5. a2 b3
6. a3 a4
7. d1 e3
8. c4 b5
9. c5 and draw

Another Sample 5×5 Game
1. c3 b2
2. b4 d2
3. e2 c2
4. a2 d3
5. d4 e4
6. b1 a4
7. b3 d5 and draw

It is occasionally useful, at least psychologically, to make a move that blocks only one end of a row, when you have the option to do otherwise. This seems to be halfway between playing a solid defensive move and a ‘cheat’. Whether it will prove to be sound or unsound depends on the details of the position and whether your opponent keeps track of what you’re up to, but I suspect that it is slightly incorrect and this habit can get you punished in similar games on larger boards.


A game like 5r Tic-Tac-Toe is known and appreciated around the world. It has a variety of names but is best known as the Japanese “Gomoku”.

At sufficiently large board sizes, without or sometimes even with artificial restrictions, Gomoku is known to be a forced win for the first mover; this is true on boards as small as 15×15. [2] It appears to be unknown at present what the largest size is that is proven to be a draw.

I’ve played 5r games at 7×7 and 9×9 sizes. My expectation is that the latter is drawn, but this hasn’t yet been proven. Play allows no room for error.

I’ve never focused my attention on this game in the way that I might have, for two reasons.

Firstly, the fact that it already has many expert and professional players has a chilling factor on my level of interest. I admit being opportunistic in this respect. I would rather try to break ground in a new land and be first-rate at something than to be second or third-rate in a sprawling metropolis. At any rate, I’m not sure how much value I can offer writing about a game that has already been discussed and solved and revised and re-solved multiple times (the previous content in these articles notwithstanding).

Secondly, I discovered Ultimate Tic-Tac-Toe shortly after my first 5r series, and my enthusiasm for that game further dampened my interest in doing an in-depth study of this one. It is therefore appropriate that Ultimate (or, as we’ve taken to calling it, ULT) should be the subject of the next article in this series.

[1] There are larger boards which are said to lead to interesting games. The key phrase here is “symmetrical board”. This vintage site is informative about that, and such variants generally: “Generalized Tic-tac-toe”, by Wei Ji Ma
[2] The proof text is Searching for Solutions in Games and Artificial Intelligence, a 1994 thesis by Louis Victor Allis.