<p>Optimal play on NxN boards where you need N in a row leads to a draw for all N > 2.</p>

<p><a href="https://books.google.com/books?id=PZV6yhwa_ZQC&amp;pg=PA133&amp;lpg=PA133" rel="nofollow noreferrer">Contemporary Combinatorics, by Bela Bollobas</a> has a proof of it.  Below is a summary of this.  The images below are from this book.</p>

<p>All board sizes 5x5 and up can be proven to be a draw by the second player employing a pairing strategy, namely where the second player plays a piece in a location next to or near the location of the first players move that most limits the options the first player has to play further.</p>

<p>For example, in the 5x5 game, optimal play for player 2 involves playing in the space with the same number as that played by player 1.  If player 1 goes in the center, or if the matching space is already occupied, player 2 can go anywhere.</p>

<p><a href="https://i.sstatic.net/0WwUL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0WwUL.png" alt="Optimal play chart for 5x5 tic-tac-toe"></a></p>

<p>Similarly, for 6x6:</p>

<p><a href="https://i.sstatic.net/Z2Z3a.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Z2Z3a.png" alt="Optimal play chart for 6x6 tic-tac-toe"></a></p>

<p>3x3 tic-tac-toe can be proven a draw by brute force method, and 4x4 can be proven a draw by creating 3 different pairing strategies based on each of the three possible opening moves by player 1 (ignoring symmetry and rotation).</p>

<p>So, under optimal play, there is no winning strategy.</p>

<p>However, if you want to write a good strategy, it seems the thing you want to do in general would be to play pieces that give you as many options to win as possible.  This would be central locations at the beginning and locations that are part of multiple lines of your pieces in the mid-game and late-game.  Early game, I'd go for spaces on the optimal move chart where the blocking move is the furthest away.  Late game, I'd go for moves that win the game or block winning moves, and otherwise ones that give the most options in conjunction with existing pieces.</p>

CC BY-SA 4.0
2019-04-28T13:59:05.797Z
This video generalizes even further, also dealing with 3 or higher dimensional boards: https://youtu.be/FwJZa-helig
Swier
CC BY-SA 4.0
2020-03-11T13:32:13.233Z
the link http://www.weijima.com/article-11-15.html is broken
Cohensius
CC BY-SA 4.0
2020-03-11T14:15:18.203Z
@Cohensius Thanks.  I updated it to a different source and added more of the related content
Zags
CC BY-SA 4.0
2019-04-26T18:18:39.180Z
2020-03-11T14:14:59.437Z
2020-03-11T14:14:59.437Z
Zags
<p>There are several generalizations to tic-tac-toe. The most natural one (imho), is the <a href="https://en.wikipedia.org/wiki/M,n,k-game" rel="nofollow noreferrer">m,n,k-game</a>, which is the game of k-in-a-row played on an (m,n) board.</p>

<p>In (n,n,n) games, for n>2, the second player can force a draw.  See <a href="https://en.wikipedia.org/wiki/M,n,k-game" rel="nofollow noreferrer">m,n,k-game</a> for many other results.</p>

CC BY-SA 4.0
2020-03-12T02:15:37.980Z
If n<3, it's impossible for player 1 to lose, as they will always win on their nth turn no matter what plays are taken for an n,n,n game.
Andrew
CC BY-SA 4.0
2020-03-11T13:45:44.443Z
2020-03-12T06:54:13.067Z
2020-03-12T06:54:13.067Z
Cohensius
<p>In a standard 3x3 Tic-Tac-Toe board, there is a strategy to win if the opponent makes a mistake. As far as I know, the strategy goes like:</p>

<ul>
<li>Capture the centers</li>
<li>Capture the edges</li>
<li>Capture a square which can lead to multiple immediate wins</li>
<li>Be careful of immediate threats</li>
</ul>

<p>I'm looking for a common strategy which works for all NxN board variants. Is there one?</p>

<p><strong>EDIT:</strong></p>

<p>The variant has the same rules as the standard one. All squares in a diagonal, row, or column occupied by a player is a win. And of course, if there isn't any moves to make, it's a tie.</p>

CC BY-SA 4.0
2019-04-26T09:07:36.707Z
On larger boards usually you need more than 3 in a row.  Do you mean 5 in a row on a NxN board?
Cohensius
CC BY-SA 4.0
2019-04-26T16:40:56.297Z
Thanks for pointing it out! I have edited the question accordingly.
Sriv
<variants><combinatorial-game-theory><tic-tac-toe>
Winning strategy for NxN Tic-Tac-Toe
Sriv
# Winning strategy for NxN Tic-Tac-Toe

(Asked by: username_0 on 2019-04-26)

In a standard 3x3 Tic-Tac-Toe board, there is a strategy to win if the opponent makes a mistake. As far as I know, the strategy goes like:

* Capture the centers
* Capture the edges
* Capture a square which can lead to multiple immediate wins
* Be careful of immediate threats

I'm looking for a common strategy which works for all NxN board variants. Is there one?

**EDIT:**

The variant has the same rules as the standard one. All squares in a diagonal, row, or column occupied by a player is a win. And of course, if there isn't any moves to make, it's a tie.

**Tags:** variants, combinatorial-game-theory, tic-tac-toe

> **Comments:**
> **username_1**: On larger boards usually you need more than 3 in a row.  Do you mean 5 in a row on a NxN board?  
> **username_0**: Thanks for pointing it out! I have edited the question accordingly.  

---

## 2 answers

### Answer by username_2 on 2019-04-26. Score: 2

Optimal play on NxN boards where you need N in a row leads to a draw for all N > 2.

[Contemporary Combinatorics, by Bela Bollobas](https://books.google.com/books?id=PZV6yhwa_ZQC&pg=PA133&lpg=PA133) has a proof of it. Below is a summary of this. The images below are from this book.

All board sizes 5x5 and up can be proven to be a draw by the second player employing a pairing strategy, namely where the second player plays a piece in a location next to or near the location of the first players move that most limits the options the first player has to play further.

For example, in the 5x5 game, optimal play for player 2 involves playing in the space with the same number as that played by player 1. If player 1 goes in the center, or if the matching space is already occupied, player 2 can go anywhere.

[![Optimal play chart for 5x5 tic-tac-toe](https://i.sstatic.net/0WwUL.png)](https://i.sstatic.net/0WwUL.png)

Similarly, for 6x6:

[![Optimal play chart for 6x6 tic-tac-toe](https://i.sstatic.net/Z2Z3a.png)](https://i.sstatic.net/Z2Z3a.png)

3x3 tic-tac-toe can be proven a draw by brute force method, and 4x4 can be proven a draw by creating 3 different pairing strategies based on each of the three possible opening moves by player 1 (ignoring symmetry and rotation).

So, under optimal play, there is no winning strategy.

However, if you want to write a good strategy, it seems the thing you want to do in general would be to play pieces that give you as many options to win as possible. This would be central locations at the beginning and locations that are part of multiple lines of your pieces in the mid-game and late-game. Early game, I'd go for spaces on the optimal move chart where the blocking move is the furthest away. Late game, I'd go for moves that win the game or block winning moves, and otherwise ones that give the most options in conjunction with existing pieces.

> **Comments:**
> **username_3**: This video generalizes even further, also dealing with 3 or higher dimensional boards: https://youtu.be/FwJZa-helig  
> **username_1**: the link http://www.weijima.com/article-11-15.html is broken  
> **username_2**: @username_1 Thanks.  I updated it to a different source and added more of the related content  

---

### Answer by username_1 on 2020-03-11. Score: 1

There are several generalizations to tic-tac-toe. The most natural one (imho), is the [m,n,k-game](https://en.wikipedia.org/wiki/M,n,k-game), which is the game of k-in-a-row played on an (m,n) board.

In (n,n,n) games, for n>2, the second player can force a draw. See [m,n,k-game](https://en.wikipedia.org/wiki/M,n,k-game) for many other results.

> **Comments:**
> **username_4**: If n<3, it's impossible for player 1 to lose, as they will always win on their nth turn no matter what plays are taken for an n,n,n game.  

---

