A desktop-based Tic Tac Toe game with AI built using Java Swing, featuring a modern GUI and an intelligent CPU opponent powered by the Minimax algorithm.
- 🧠 AI-powered opponent using the Minimax algorithm
- 🎨 Custom GUI design
- 🔄 Restart/New Game button
- 🏆 Game status (Win / Lose / Tie)
- 🖥️ Fully offline desktop application
- 📦 Clean, single-file Java implementation (easy to extend)
The CPU uses the Minimax algorithm to:
- Evaluate all possible game states
- Maximize its winning chances
- Minimize the player's chances
This makes the AI strategic and competitive, ensuring meaningful gameplay rather than random moves.
- Java
- Java Swing (GUI)
- AWT Graphics2D (custom painting & gradients)
- Java JDK 8 or above
javac TicTacToeAI.java
java TicTacToeAI
The game window will open automatically.
- Click on a tile to place your move (
O) - The AI plays as
X - Click the “new” button (top-right) to restart the game
TicTacToe-AI
----TicTacToeAI.java
----README.md
----.gitignore
- Difficulty levels (Easy / Medium / Hard)
- Beatable AI with adaptive difficulty
- Sound effects & animations
- Web version (HTML/CSS/JS or Spring Boot backend)
This project demonstrates:
- Strong Java fundamentals
- Understanding of game AI concepts
- GUI design beyond basic Swing components
- Ability to build user-focused applications
This project is open for learning and personal use.