Tic-tac-toe
You are X. Casual mode makes mistakes; Perfect mode has never lost a game in the history of mathematics.
What you are actually up against
You play X and always move first, which in tic-tac-toe is the entire advantage the game has to give. The two opponents differ in one number. Perfect mode searches the complete game tree with the minimax algorithm every turn, assuming you will also play perfectly, and it prefers faster wins and slower losses, so it will not even let you drag out a doomed position. Casual mode runs the same brain but rolls dice first: 35 percent of its moves are chosen completely at random from the open squares, and the other 65 percent are the perfect move. The scoreboard keeps a running tally of your wins, draws, and losses on your device, across visits.
Beating casual, drawing perfect
Against perfect mode your ceiling is a draw, and there is no shame in that ceiling: tic-tac-toe was solved long ago, and best play by both sides always draws. Treat perfect mode as a discipline test. Open in the center, which sits on four winning lines, more than any square. Corners touch three lines, edges only two. Then block every threat the moment it appears and never play a move that creates zero threats of your own. If you can draw perfect mode ten times running, you have effectively memorized the solution, whether you meant to or not.
Casual mode is a different puzzle: it punishes you 65 percent of the time and blunders 35 percent, and the way to farm wins is to build forks, positions with two winning threats at once. A single threat gets blocked whenever the dice come up perfect, which is most turns; a fork wins even against a perfect reply, so it wins against casual regardless of the roll. The standard construction: take the center, and when the computer answers on an edge rather than a corner, take a corner adjacent to its edge and you can usually force the double threat within two moves. Playing for forks rather than quick lines converts casual games at a dramatically better rate than hoping the random move arrives on schedule.
Reading your tally
Against perfect mode, a healthy tally is all draws and losses trending to zero as you tighten up; wins are impossible, so a clean sheet of draws is a perfect score. Against casual, strong fork play converts a large share of games, with the remainder mostly draws from the games where the computer happened to answer perfectly throughout. Note the tally does not separate the two modes, so a purist tracking their perfect-mode record should reset expectations after a casual farming session inflates the win column.
Design notes
The computer's 220 millisecond pause before moving is theater; minimax on a 3 by 3 board resolves in well under a millisecond, but an instant reply feels like playing a wall. The depth preference in the search matters in one visible way: when the computer has a forced win, it takes the shortest path rather than toying with you, and when it is losing in casual mode's random-move aftermath, it plays whatever delays the end longest, occasionally producing weirdly stubborn defenses. There is no difficulty slider between the two modes, no first-move option for the computer, and no online play. The whole game, including the tally, lives in your browser, and the algorithm is the same textbook minimax students implement in their first AI course, running unmodified and unbeaten.
Frequently asked questions
Can the perfect AI be beaten?
No. Tic-tac-toe is a solved game: with best play from both sides it always ends in a draw. The perfect mode plays the minimax-optimal move every turn, so a draw is your best possible result. Getting one every time is harder than it sounds.
What is the best opening move?
The center. It participates in four winning lines (both diagonals, middle row, middle column), more than any other square. Corners are next best with three lines each; edges are weakest with two.
How does the computer decide its moves?
Perfect mode searches the entire game tree with the minimax algorithm, assuming you also play perfectly, and prefers faster wins and slower losses. Casual mode plays the perfect move most of the time but sometimes picks randomly, which opens the door.