Package mastermind.core.solvers
Class EasyAlgorithm
java.lang.Object
mastermind.core.solvers.MastermindSolver
mastermind.core.solvers.MastermindAlgorithm
mastermind.core.solvers.EasyAlgorithm
An implementation of the MastermindAlgorithm class that provides a simple
algorithm for solving the Mastermind game, by randomly choosing codes that
have not guessed before.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class mastermind.core.solvers.MastermindSolver
getAttempts, hasExceededMaxGuesses, isInitialGuess
-
Constructor Details
-
Method Details
-
guess
This simple guess algorithm generates a random guess that has not been made before.The algorithm generates a random guess by selecting a random color for each of the four positions in the code. If the generated guess has already been made, the algorithm generates a new guess until a unique guess is found.
- Specified by:
guess
in classMastermindAlgorithm
- Returns:
- The initial guess to be made by the algorithm.
-
guess
Determines the next guess for the Mastermind game.The algorithm generates a random guess by selecting a random color for each of the four positions in the code. If the generated guess has already been made, the algorithm generates a new guess until a unique guess is found.
- Specified by:
guess
in classMastermindAlgorithm
- Parameters:
response
- The response to the previous guess made by the algorithm.- Returns:
- A tuple containing the status of the game and the next guess to be made by the algorithm.
- Throws:
IllegalCallerException
- If this method is invoked for the initial guess.
-