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

Introduction

Tic‑Tac‑Toe challenges two players to fill a three‑by‑three grid with alternating marks. You win by aligning three identical marks horizontally, vertically, or diagonally before your opponent. Every move narrows the available options and rewards foresight, pattern recognition, and timing. Simple rules create surprisingly deep tactical trade‑offs that teach forward planning and spatial awareness.

This online version lets you compete against another person or a perfect‑play computer that never loses. The interactive board highlights turns, enforces valid input, and displays results in a focused overlay. Encoded URLs preserve move history so you can share puzzling positions with friends for discussion. Caution: Saved links expire if you manually clear the query parameters.

Use the game to practise unbeatable defence or demonstrate minimax search to students in a live workshop. For example, show how forcing a fork from the centre guarantees at least a draw. Caution: The AI always selects the optimal reply, so beginners may find winning impossible.

Features:

The following controls and enhancements ensure smooth play, clear feedback, and data‑safe sharing.

Opponent Selector

Switch between computer and human opponents instantly. Example: choose Computer to test tactics alone. Caution: Changing opponent mid‑game resets progress.

Responsive Grid

The board adapts to any screen width for comfortable tapping. Example: play comfortably on a phone in portrait mode. Caution: Rotating your device may re‑center but not resize running modals.

Turn Indicator

A heading shows the current player or result. Example: “Current Player – X” appears after the first move. Caution: The indicator locks when the modal is open.

Unbeatable AI

The minimax engine evaluates every possibility before responding. Example: expect a forced draw after optimal centre opening. Caution: Long calculations are unnecessary, yet rapid alerts might surprise newcomers.

Sharable Game Links

Moves serialise into the page URL for one‑click sharing. Example: copy the address bar to relaunch an in‑progress puzzle. Caution: Manual edits to the query string can break decoding.

Step-by-Step Guide:

Follow these steps to start, play, and share a match.

  1. Select your preferred opponent from the Opponent: dropdown.
  2. Check the Current Player heading to confirm who moves first.
  3. Click any empty square to place your mark.
  4. Continue alternating turns until a win line flashes or a draw occurs.
  5. When the result modal appears, choose Play Again or press Reset Game for a fresh board.
  6. Copy the page URL to share the current position with friends or students.

FAQ:

Find quick answers to common questions about play, privacy, and controls.

Is my data stored?

No data leaves your browser; all moves remain in the address bar only.

Can I change opponent mid-game?

Yes, but switching resets the current board to ensure fair play.

Why can't I click a square?

The square is already occupied, or the game ended and awaits reset.

What if the game draws?

The modal shows “Draw”; press Play Again to restart.

Is the AI unbeatable?

Yes. The algorithm always chooses an optimal move, ensuring at least a draw.

Advanced Tips:

Use these expert ideas to deepen strategy and teaching value.

  • Open in the centre to maximise future fork opportunities.
  • Create a double threat by controlling opposite corners.
  • Introduce time limits per move to simulate tournament pressure.
  • Ask learners to predict the AI’s reply before clicking a square.
  • Demonstrate symmetry by rotating stalemate positions for analysis.

Outcomes provide entertainment value only and hold no monetary worth.

No data is transmitted or stored server‑side.

Embed this tool into your website using the following code: