Tic-tac-toe online free
Tic-tac-toe is the classic game of X and O: two players take turns marking a 3×3 grid, and the first to line up three of their own symbols wins. It takes thirty seconds to learn and years to notice that, played properly, it should never produce a winner at all. Play free against the unbeatable computer or against a friend on the same device — this guide explains why the computer never loses and how you can always force the draw.
History
It is one of the oldest games still in play. Three-by-three grids scratched into stone turn up across Roman sites, associated with terni lapilli — which, curiously, was not quite our game: each player had only three pieces and, once all of them were placed, began moving them around the board. That is the same idea as the infinite variant.
The modern fixed-mark format settled in England under the name noughts and crosses. In 1952 A. S. Douglas programmed OXO on the EDSAC computer at the University of Cambridge as part of his doctoral work on human-computer interaction — one of the earliest video games with a graphical display on record.
Ever since, the game has been a rite of passage for anyone learning to program: small enough to finish in an afternoon, complete enough to teach search trees, minimax and basic game theory.
How to play
Each player takes a symbol, X or O, and you alternate marking one empty square at a time. The first to form a line of three matching symbols — horizontally, vertically or diagonally — wins. If all nine squares fill up with nobody lining up three, the game is drawn.
In vs computer mode you always play X and always move first. That is not a convenience: moving first is an advantage in tic-tac-toe, and even so, against this computer the best result available to you is a draw. In 2 players mode both sides share one device, taking turns tapping.
Rules
- The board is 3×3 and X always moves first.
- Players alternate, marking one empty square per turn.
- Three matching symbols in a line — horizontal, vertical or diagonal — win the game.
- Nine squares filled with no line of three is a draw.
- Marks never move and never leave the board.
Strategies
- Take the centre. It belongs to four of the eight winning lines — more than any other square.
- Prefer corners to sides. A corner sits on three winning lines; a side square sits on only two and has no diagonal.
- Build a fork. A move that creates two threats at once cannot be answered, because your opponent only blocks one per turn.
- Block the fork, not just the line. You rarely lose to a threat you saw; you lose to the double threat you allowed to form.
- Check your opponent before chasing your own line. One square from defeat beats two squares from victory every time.
The board is not symmetrical
The nine squares look interchangeable and are not. What separates them is how many of the eight winning lines each one belongs to.
Hence the preference order every experienced player follows by instinct: centre, then corner, side last. A side square is only a good move when it blocks something or creates a concrete threat.
- Centre — 4 lines. Both diagonals, one row and one column. The most valuable square on the board.
- Corners — 3 lines each. One diagonal, one row, one column.
- Sides — 2 lines each. One row and one column, no diagonal at all.
The three openings, and the reply to each
Since X always starts, everything depends on where X opens. There are only three genuinely distinct openings — everything else is a rotation or a mirror image.
If you remember one thing, make it this: when your opponent opens in a corner, take the centre. It is the single rule that prevents the most losses in practice.
- X in the centre: the drawing reply is a corner. Any side square loses.
- X in a corner: the only drawing reply is the centre. Every other answer loses to correct play, which makes this the most treacherous opening for beginners.
- X on a side: the weakest opening. O has several safe answers: the centre, either corner adjacent to X, or the opposite side.
Why the computer never loses
The computer here uses minimax: before every move it walks the entire tree of possible continuations to the end of the game, scores each ending as a win, draw or loss, and picks the move whose worst outcome is the best available. Tic-tac-toe has so few positions that it solves the whole thing instantly — there is no approximation and no randomness involved.
There is one detail in the tie-breaking: among moves that all win, it prefers the one that wins in fewer moves. So when you slip, it does not drag the game out; it closes at the first opportunity.
The practical consequence is blunt: you cannot beat it. You can draw every single time, and that is the goal worth chasing. If a game ended in defeat, there was exactly one wrong move on your side — usually a reply other than the centre after a corner opening.
Tips for beginners
- Open in the centre whenever it is free; if your opponent took it, answer in a corner.
- Before marking, check whether your opponent is one square from winning.
- Watch the diagonals — they are the lines the eye skips.
- Look for a move that blocks and threatens at the same time.
- A draw against a perfect opponent is a good result, not a failure.
Trivia
- There are 255,168 possible games. Discounting rotations and reflections, only 26,830 are genuinely distinct.
- There are 138 distinct final positions: 91 end in a win for X, 44 in a win for O and 3 in a draw.
- With perfect play from both sides the result is always a draw — the game is completely solved.
- In the 1970s, MIT students built a computer out of Tinkertoy parts that played tic-tac-toe without losing.
- Want a classic with fewer draws? Try the infinite variant, where each player has only three pieces and starts moving them.
Mobile version
On a phone, tap an empty square to place your symbol. The board scales to the screen width with no zooming or sideways scrolling, and the squares are large enough that mis-taps are rare.
In 2-player mode one device serves both sides: the indicator above the board always shows whose turn it is, which avoids the common confusion of one player tapping twice in a row.
Frequently asked questions
How do you win at tic-tac-toe?
By lining up three of your symbols horizontally, vertically or diagonally before your opponent. Against an attentive opponent that only happens through a fork: a move that creates two threats at the same time.
Can I beat the computer?
No. It calculates the whole game before every move and plays perfectly. The best available result is a draw — and that is entirely achievable.
What is the best first move?
The centre, because it belongs to four of the eight winning lines. Corners come next with three each; the sides are the weakest squares with two.
My opponent opened in a corner. What do I do?
Take the centre. It is the only reply that guarantees a draw — anything else lets them build a fork and win.
Does tic-tac-toe always end in a draw?
Between two players who do not make mistakes, yes. A win only appears when someone departs from correct play, and the game is mathematically solved in that sense.
What is a fork?
A move that creates two three-in-a-row threats at once. Since your opponent can only block one per turn, the other becomes a win on the following move.
Do I need to install anything or create an account?
No. Tic-tac-toe runs straight in your browser, free and with no sign-up.