A modern, web-based Tic-Tac-Toe game with a competitive AI using the Minimax algorithm. Challenge the AI or play 2-player mode with your friends! Perfect for learning web development, game logic, and AI implementation.
- Single-player vs AI:
The AI plays perfectly using the Minimax algorithm. It always tries to win or block you. - 2-player mode:
Play against a friend on the same device. - Interactive UI:
- Hover animations
- Color-coded X (red) and O (blue)
- Highlight winning line
- Smooth restart animations
- Responsive design: Works on desktop and mobile.
- Open the
index.html
file in your browser. - Click on an empty cell to make your move.
- The AI will automatically play after your move.
- The game announces a winner or draw when the board is full.
- Click Restart Game to play again.
The AI uses the Minimax algorithm, a decision-making algorithm for perfect-play games.
- The AI simulates all possible moves and chooses the one with the highest score.
- Winning moves =
+10
, Losing moves =-10
, Draw =0
- The AI blocks the player if they are about to win.
- This ensures competitive gameplay where the AI never loses.