{{ winner }} wins!
Draw
Current Player – {{ currentPlayer }}

Tic Tac Toe is a two-player alignment game. Players alternately place marks on a three-by-three grid, aiming to create an uninterrupted line of three. The game highlights turn-based strategy, spatial reasoning, and equilibrium. It serves as a teaching example in computer science. Draws occur when no remaining moves yield a line.

This online version lets you play instantly without installation. Choose to face a second human or a computer opponent that never makes an error. Reset the board anytime, then share the current position through the address bar and resume on another device. Animated highlights make each winning line clear for observers.

You can embed the game in lessons to demonstrate optimal play, or use it during breaks for light competition. The AI illustrates perfect decision making, letting learners test strategies and discover forced draws. Quick links allow tournament organisers to record pivotal positions for later analysis. Mobile-friendly design keeps controls accessible on phones.

Features:

Explore the interactive controls and built-in assistance.

  • Single-click or tap squares to place your mark.
  • Toggle between Computer and Second Human opponents before the first move.
  • AI uses a minimax search for perfect play, ensuring no unwinnable mistakes.script.js](file-service://file-6JVgP4Qymx5pkjBpmZ5sn6)
  • Dynamic status banner shows the current player, winner, or draw outcome.
  • Winning squares flash for quick recognition.style.css](file-service://file-BwNqMV1CJJyLH4CobjTPUu)
  • Reset button clears the board and opponent choice in one click.
  • URL query encodes moves so you can bookmark or share a live position.script.js](file-service://file-6JVgP4Qymx5pkjBpmZ5sn6)

Step-by-Step Guide:

Follow these steps to start a match and share results.

  1. Select Opponent from the dropdown before your opening move.
  2. Click any empty square to place your X.
  3. The game board updates, and the status banner shows whose turn is next.
  4. If Computer is selected, the AI responds instantly. Tip
  5. Observe the flashing line when a player wins, or the modal when a draw occurs.
  6. Press Play Again in the modal or the Reset Game button to start over.
  7. Copy the page URL to share the current position with friends or students.

FAQ:

Find quick answers to common questions.

Can I change the opponent mid-game?

No. Switch opponents before the first move, then reset to apply changes.

Why does the AI never lose?

The minimax algorithm evaluates every possible outcome and selects moves that avoid defeat.

What does the flashing line mean?

It identifies the three-square sequence that secured victory, helping viewers see the result instantly.

How do I share a specific board state?

The game encodes moves into the page URL. Copy the link and paste it anywhere; the board recreates itself on load.

Is my game data stored on a server?

No. All moves remain within your browser session. Closing the tab removes them.

Outcomes are purely random and hold no monetary value.

Embed this tool into your website using the following code: