Class HumanSolver

java.lang.Object
mastermind.core.solvers.MastermindSolver
mastermind.core.solvers.HumanSolver

public class HumanSolver extends MastermindSolver
A solver that allows a human player to guess the secret code.

It is the solver used for code maker mode.

It compares user input against generated secret code and provides hints.

  • Constructor Details

    • HumanSolver

      public HumanSolver(Code secretCode)
      Constructs a HumanSolver instance with the given secret code.
      Parameters:
      secretCode - the code to be guessed during the game
  • Method Details

    • guess

      public Tuple2<Status,Response> guess(Code guess)
      Evaluates a guess against the secret code and determines the game status.

      This method processes a given guess and generates a response indicating the correctness of the guess in terms of the secret code. Based on the number of correct matches and the player's remaining attempts, the method returns a tuple containing the game status and a response object.

      The game status can be one of the following: - Status.Win: If the number of correct matches equals the code length. - Status.Lose: If the maximum number of guesses is reached without success. - Status.Continue: If the game is ongoing and further attempts are allowed.

      Parameters:
      guess - the code guessed by the player
      Returns:
      a tuple containing the game status and the response