TL;DR
  • Minimax wins by calculating every possible outcome in advance; a neural network wins, eventually, by playing many games and adjusting itself after each one.
  • A neural network starts out knowing nothing - Not even that three in a row is the goal - And learns purely from win, lose, or draw feedback.
  • Early games look almost random because the network is still exploring; good play only shows up after enough repetition.
  • Tic tac toe is small enough that this approach is overkill, which makes it a good place to see the idea before it gets used on something huge, like Go.

Two Different Ways to Be Good at a Game

There's more than one way for a computer to get good at tic tac toe. The two most common ways barely resemble each other. One calculates. The other learns. Both end up playing well, but they get there through completely different routes.

Minimax: Calculate Everything, Every Time

Our Hard mode uses minimax, a thorough form of looking ahead. It imagines every move it could make. Then it imagines every reply to that move. Then every reply after that, all the way to the end of the game. It picks whatever path guarantees the best result. Minimax isn't learning anything - It's calculating, fresh, on every single turn.

Neural Networks: Learn From Experience

A neural network does almost the opposite. Instead of calculating the whole future every time, it plays a huge pile of games first, usually against itself. Slowly, it builds a rough sense of which positions tend to go well and which tend to go badly. It's less like a calculator and more like a patient kid who's played checkers with grandpa five thousand times and is just starting to develop a feel for it.

What a Neural Network Actually Is, in Plain Words

Strip away the name, and a neural network is just a big pile of adjustable numbers. Those numbers are loosely arranged to copy how brain cells pass signals to each other. That's really all it is.

Weights: The Numbers That Do the Work

Each connection inside the network has a number attached to it, called a weight. Feed the network a board position - Which squares have X, which have O, which are empty - And it multiplies, adds, and passes those numbers along until it spits out a guess: how good this position is, or which move looks best from here. At first the guess is garbage. All those weights start out random.

Turning a Guess Into Learning

What makes this "learning" rather than just guessing is what happens after the guess. Say the network liked a move that led straight to a loss. The weights connected to that mistake get nudged, just slightly, using a process called backpropagation - It works backward from the wrong answer and figures out which weights caused it. A similar position next time becomes a little less likely to get the same wrong answer. Do that nudging millions of times, and a random pile of numbers slowly turns into something that plays well, even though nobody ever explicitly told it a single rule of strategy.

Learning by Losing, Over and Over

The training process is repetitive, almost embarrassingly so. Here's what one round looks like, step by step.

The Training Loop, Step by Step

  1. Play a game. The network plays a full game, often against a copy of itself, making moves based on its current, imperfect sense of the board.
  2. Find out the result. Only at the very end does it learn whether it won, lost, or drew.
  3. Adjust the weights. It goes back over every move in that game. Moves from a winning game get nudged toward "do this again." Moves from a losing game get nudged toward "try something else."

Then it plays again. And again. Thousands of times.

Self-Play: Practicing Without a Human Opponent

This training method is called reinforcement learning. A big part of what makes it work is self-play - The network practicing against a copy of itself instead of waiting for a person to sit down across the board. It's a very different relationship with mistakes than a human has. The network doesn't feel bad about losing. It updates a few thousand numbers and plays again, instantly, with zero hesitation. It can play more games in an hour than a person could play in a lifetime. That's really the only reason this slow, trial-and-error method works at all.

Why It Takes Thousands of Games to Click

Early on, a training network plays like a confused toddler. It hasn't learned yet that a fork two moves later is a disaster, so it might walk right into one fifty times before the penalty sinks in.

Exploration: Trying Bad Moves on Purpose

Researchers usually force in some randomness on purpose during this phase. It's called exploration, and it stops the network from getting stuck repeating one mediocre habit forever just because it happened to work once. A common way to do this is called epsilon-greedy: the network usually plays its best-known move, but some small percentage of the time it picks a random move instead, just to see what happens.

Tic Tac Toe vs. a Game Like Go

Tic tac toe is small enough that this phase doesn't take long. A few thousand self-played games is usually plenty to get a network playing solidly. That number would be laughably small for a game like Go, which has more possible positions than atoms in the observable universe. Go-playing networks need millions of training games and far more computing power. The size of the game mostly decides how painful this trial-and-error phase gets.

Quick comparison: Tic tac toe has 255,168 possible games from start to finish. Go has more legal positions than atoms in the observable universe. That gap is why a network built for Go needs millions of practice games, while one built for tic tac toe needs only a few thousand.

Minimax vs. a Trained Network

Side by side, the two approaches barely look like they're solving the same problem, even though both are trying to master the same nine squares and the same simple rules.

At a Glance

MinimaxNeural network
How it decides a moveCalculates every outcome, fresh, each turnRecognizes patterns learned from past games
Needs training?No - Works instantly with zero practice gamesYes - Needs thousands of games first
Guaranteed not to lose?Yes, in a small solved game like this oneOnly if training went well; mistakes are possible
Scales to bigger games?Badly - The search explodes in size fastBetter - This is how Go and chess engines get strong

Where Each One Wins

  • Small, solved games like tic tac toe: minimax wins easily. It's instant, exact, and never needs practice.
  • Huge games like chess or Go: a trained network wins. Calculating every branch would take longer than the universe has existed.
  • Explaining a decision: minimax can show you its exact reasoning. A neural network's reasoning is buried inside millions of weights, so it's much harder to explain "why."

Tic Tac Toe Is the Kiddie Pool for a Much Deeper Idea

Using a neural network to play tic tac toe is a little like renting a moving truck to carry a houseplant. It works, but it's way more machine than the job needs. Our math page shows that a full brute-force search checks every possible game and finishes in milliseconds. There's no real need to train anything.

Why Bother, Then?

Because it's small enough to actually watch the learning happen, move by move, mistake by mistake. That makes it a great practice run before the same idea gets pointed at something too big for any human to fully picture - A much larger game, a robot arm, or a self-driving car figuring out its very first turn.

The Bigger Ideas Hiding Inside a Tiny Game

Everything described above scales up, just with more layers and far more training. A few terms worth knowing if you go looking for them: a policy network suggests which move to try next, a value network judges how good a position already is, and overfitting is what happens when a network memorizes its training games instead of learning general patterns - It looks great in practice and falls apart against anything new. If you want to see the calculating side of this comparison up close, our guide on building a tic tac toe AI with minimax walks through the other half of the story.

If minimax is a chess master who's already memorized the whole book, a neural network learning tic tac toe is a rookie figuring out the book by getting hit in the face with it a few thousand times. Different paths, same destination. Watching the rookie stumble through it is, honestly, the more interesting story.