Global Araç
Tic Tac Toe
Sıra: X
X galibiyet
0
O galibiyet
0
Beraberlik
0
YZ, tam oyun ağacı araması ile minimax kullanır — 9 hücreli tahta anında hesaplanabilecek kadar küçüktür. Yapabileceğiniz en iyi şey berabere kalmaktır.
The classic 3×3 tic-tac-toe game with an unbeatable AI opponent powered by full minimax search. Three modes: vs Easy AI (random moves — beatable most of the time), vs Hard AI (perfect minimax — best you can do is force a draw), vs Friend (pass-and-play, two players on one device). Win/loss/draw stats track across your session.
Tic-tac-toe is the canonical example of a solved game — one where perfect play from both sides always leads to a draw. The mathematical analysis dates to at least the 1960s; with optimal play, neither player can force a win. The minimax algorithm (introduced in 1928 by John von Neumann) is the theoretical foundation for solving any zero-sum game, including chess and Go (though those games are too large to be solved exhaustively the way tic-tac-toe is).
The AI here implements full minimax with alpha-beta pruning over the entire tic-tac-toe game tree — there are only ~26,830 distinct positions, so the algorithm runs in microseconds. It evaluates every possible continuation from each move and picks the one that maximizes your worst-case outcome. There's no random variation, no opening book hacks; it's just pure search. Try to win for a while, then enjoy figuring out the drawing strategy.
Nasıl Kullanılır
- Pick the mode: Easy AI (random play, you'll usually win), Hard AI (minimax, you can only draw), or Friend (pass-and-play).
- Click any empty square to place your X. The first move is yours by convention.
- Watch the AI (or your friend) play O.
- Three in a row — horizontally, vertically, or diagonally — wins.
- After the game ends, click 'New game' to start over. Stats track across your session.
Ne Zaman Kullanılır
- Quick 30-second break — most games end in 5-9 moves.
- Teaching kids the minimax concept (start them on Easy, then explain why Hard is unbeatable).
- Demonstrating game-theory ideas in CS lectures or educational content.
- Casual two-player game when you're sharing a single screen / phone.
Ne Zaman Kullanılmaz
- When you want a long game — tic-tac-toe is intentionally short.
- When you want strategic depth — connect-four, chess, Go all offer more depth. Tic-tac-toe is solved.
- Multiplayer over the network — this is local-only (you and the AI, or pass-and-play).
Yaygın Kullanım Senaryoları
- Onboarding a colleague who needs the same calculation/conversion
- Verifying a number or output before passing it on
- Quick use during a typical workday
- Pre-decision sanity-check on inputs and outputs
Sık Sorulan Sorular
Can I beat the Hard AI?
No. With perfect play, tic-tac-toe is always a draw — neither side can force a win. The minimax AI here never makes a suboptimal move; the best outcome you can achieve is a draw. If you do better than that, there's a bug in the AI (please report).
What's the optimal first move?
Center is universally best — it's part of 4 of the 8 possible winning lines. Corners are second-best (each is part of 3 winning lines). Edges are worst (part of only 2 winning lines). Against a perfect AI, the strongest opening play is center; against a weaker AI, corner traps work well.
How does minimax work?
From the current position, recursively evaluate every possible move. For each, recursively evaluate the opponent's best response, and so on, all the way down. Score leaf positions: +1 for AI win, -1 for AI loss, 0 for draw. Each level alternates between picking the maximum (AI's turn) and minimum (opponent's turn) of children. The AI plays the move leading to the best worst-case outcome.
Why does the Easy AI sometimes still win?
Because you're playing first (X), and even random opponents occasionally get lucky if you make a mistake. The 'Easy' AI doesn't see threats; if you set up a fork (two simultaneous winning lines), it'll let you win. But if you don't see the same forks the AI doesn't see, you'll occasionally lose to a random move that happens to be a winning move.
Is the game tree really only 26,830 positions?
Yes — that's the count of distinct legal positions accounting for symmetries. Naive count is 9! = 362,880, but most of those are equivalent under rotation/reflection or end games early. Either way, the game tree is small enough to fully solve in a few microseconds on any modern computer.
Are there variants?
Yes — gomoku (5-in-a-row on a larger board), 4×4 tic-tac-toe (also a draw with perfect play), 3D tic-tac-toe, ultimate tic-tac-toe (a meta-board where moves on the small grid send opponent to the corresponding small grid). These are all interesting; full minimax doesn't work on the larger ones because the game tree explodes.