How Tic Tac Toe AI Works
By Duetly Editorial · Published 2026-08-30 · Updated 2026-08-30
Hard mode on Duetly is not a personality and it does not 'learn' from you. It searches the rest of the game tree and picks a move that cannot lose.
Minimax in one paragraph
For each empty cell, imagine placing your mark there. Then imagine the opponent picking the reply that is worst for you. Then imagine you picking the reply that is best for you. Repeat until the board is won or full. Score a win for you as positive, a win for them as negative, a draw as zero. Prefer shorter wins and longer losses. Choose the empty cell with the best score.
Why it is fast
A 3×3 board has at most nine empty cells. Many branches end early because someone already has three in a row. Alpha-beta pruning skips branches that cannot change the decision. Your phone can finish this search in well under a millisecond.
What Easy mode does instead
Easy picks a random legal cell. It can still win if you hand it a line. It can also play the worst square on the board. That is the point: it is a sparring partner, not a weaker minimax with a bug.
Why the client cannot cheat Hard
Vs Computer runs in your browser. You could, in theory, alter it. Online games are different: the server validates every move and never asks the client who won. If you want the fair fight, play Tic Tac Toe vs Hard computer for practice, then play online with a friend when you want a human.