Mastermind game implemented in Java with an AI solver based on graph traversal , greedy heuristics, and extensible architecture for Dynamic Programming and Backtracking optimizations, inspired by ideas from Simon Tatham.
This project is an advanced Java-based implementation of the Mastermind game
featuring an AI solver using Graph-based Breadth First Search (BFS) combined with
a Greedy strategy.
The game includes a fully interactive Java Swing GUI allowing both human and
AI turns.
- Graph Modeling of Game States
- Breadth First Search (BFS)
- Greedy Decision Making
- Constraint Pruning
- Object-Oriented Programming (OOP)
- Java
- Java Swing (GUI)
- BFS Graph Traversal
- Greedy Algorithms
- Event Handling
- Interactive drag-and-drop color selection
- BFS-based AI solver with pruning
- Greedy move selection for deterministic AI behavior
- Visual feedback with black & white pegs
- Restartable gameplay
- Human vs AI turn system
-
MastermindEngine
Handles secret generation, guess evaluation, and graph vertex generation. -
GraphBFSNavigator
Implements BFS traversal, pruning of invalid states, and greedy selection. -
MastermindBoardGUI
Java Swing-based graphical interface integrating human and AI gameplay.
- Clone the repository
git clone https://github.com/yourusername/Mastermind
2. Compile all filesjavac *.java
- Run the game
java MastermindBoardGUI