An unbeatable Tic-Tac-Toe game built in Java. Implements the Minimax algorithm (Game Theory) to simulate Artificial Intelligence without neural networks to determine the optimal move in a zero-sum game. Demonstrates recursive decision making, state management, and Swing GUI design.
- Unbeatable AI: The computer plays perfectly and will never lose. The best outcome a human can achieve is a draw.
- Graphical Interface: Clean, wooden-themed UI built with Java Swing.
- Game Logic: Full implementation of win/loss/draw detection.
- Reset Functionality: Automatic board reset upon game completion.
- Algorithm: Minimax (Recursive Backtracking)
-
Time Complexity:
$O(b^d)$ — effectively$O(n!)$ for Tic-Tac-Toe. -
Space Complexity:
$O(d)$ where$d$ is the depth of the game tree.
Follow the below instructions to set up and run the game on your local machine.
- Java Development Kit (JDK): Version 8 or higher.
- An IDE (Optional): IntelliJ IDEA, Eclipse, or VS Code.
-
Clone the Repository:
git clone [https://github.com/76aditya/Minimax-TicTacToe-Java.git](https://github.com/76aditya/Minimax-TicTacToe-Java.git)
-
Navigate to the Directory: Open the project folder in your terminal or IDE.
-
⚠️ Important Configuration (Image Path):- This game uses a background image (
wood-texture-wallpapers.jpg). - Open
Game.java. - Locate the line inside
main()andBackgroundclass where the image path is defined:// Look for lines similar to: new ImageIcon("C:/Aditya/DSA in JAVA/...");
- Update this path to match the location of the image file on your specific computer.
- This game uses a background image (
Option 1: Using Command Line Compile and run the Java file:
javac Game.java
java GameOption 2: Using IDE Compile and run the Java file on the IDE you are using.