Mastermind clone
Integrating Donald Knuth's Five-Guess Algorithm into the Mastermind game will allow the application to act as a codebreaker and efficiently solve the player's secret code. The algorithm systematically minimizes the possible solutions based on feedback from the guesses, making it a powerful choice for this application.
Here’s how to modify the existing code to add this feature:
|-- Mastermind/
|-- main.cpp
|-- Game.h
|-- Game.cpp
|-- Menu.h
|-- Menu.cpp
|-- Solver.h
|-- Solver.cpp
|-- SFML/
|-- arial.ttf
-
Solver Mode:
- Uses Donald Knuth's Five-Guess Algorithm to efficiently solve the player's secret code.
- Runs automatically and provides feedback for each guess until the code is cracked.
-
Two Game Modes:
- Player-plays mode: The player guesses the code.
- Solver mode: The application solves the code set by the player.
-
Interactive Feedback:
- Displays progress visually using polygons.
This implementation provides both a human-playable game and an automated code-solver using Knuth's algorithm. Let me know if you'd like additional features or enhancements! 😊
Here's a detailed README file for your Mastermind application:
MasteroftheMind is a modern implementation of the classic code-breaking game Mastermind. This application not only allows players to challenge themselves but also features a sophisticated solver mode powered by Donald Knuth's Five-Guess Algorithm. The solver acts as the codebreaker and efficiently cracks the player's secret code. Built with SFML, this game brings together interactivity and powerful logic in one engaging experience.
- Classic Player Mode: Take on the role of the codebreaker, guessing the randomly generated secret code.
- Solver Mode: Watch as the application, using Knuth's Five-Guess Algorithm, cracks your code with impressive efficiency.
- Interactive Gameplay: User-friendly interface with keyboard controls and visual feedback.
- Customizable Game Rules:
- Adjustable code length.
- Configurable number of colors.
- Simple and Intuitive Menu: Navigate between options such as starting a new game, enabling solver mode, or exiting the app.
- A C++ compiler with C++11 or higher support.
- SFML 2.5 or later installed on your system.
- A terminal/command line environment.
- Clone the repository:
git clone https://github.com/YourUsername/MasteroftheMind.git cd MasteroftheMind
- Install SFML following the instructions for your system from SFML's website.
- Build the application:
g++ -std=c++11 -o Mastermind main.cpp Game.cpp Menu.cpp Solver.cpp -lsfml-graphics -lsfml-window -lsfml-system
- Run the application:
./Mastermind
- Launch the application.
- Choose from the menu options:
1. Play Game
: Start a new game where you will act as the codebreaker.2. Solver Mode
: Set a secret code and let the AI solve it for you.3. Quit
: Exit the application.
- Player Mode:
- Use keys (
1-6
) to select colors and pressEnter
to submit your guess. - Receive feedback on your guess: the number of correct colors in the right position and correct colors in the wrong position.
- Crack the secret code to win!
- Use keys (
- Solver Mode:
- Enter your secret code.
- Watch the solver deduce the correct code step by step with visual feedback.
|-- Mastermind/
|-- main.cpp # Entry point for the application
|-- Game.h # Header file for the game logic
|-- Game.cpp # Implementation of the game logic
|-- Menu.h # Header file for the menu
|-- Menu.cpp # Implementation of the menu
|-- Solver.h # Header file for Knuth's Five-Guess Algorithm
|-- Solver.cpp # Implementation of Knuth's Five-Guess Algorithm
|-- SFML/ # Dependencies for the SFML library
|-- arial.ttf # Font file for the menu text
- Navigation: Use keyboard number keys to select menu options.
- Player Mode:
1-6
: Select colors for your guess.Enter
: Submit your guess.
- Add a graphical representation for guesses and feedback using SFML.
- Allow users to configure game settings (e.g., code length and number of colors) through the menu.
- Implement a leaderboard for tracking player performance.
This project is released under the MIT License. Feel free to modify and distribute it.
- Developed by: Jon-Arve Constantine Grønsberg-Ovesen
- Algorithm: Donald Knuth's Five-Guess Algorithm
- Library: SFML