Algorithm Overview:
This algorithm is designed to solve the Mastermind game in fewer than 5 moves. It consists of three main functions.
  1. evaluateGuess determines how close a guess is to the solution by counting correct placements and misplaced values.
  2. computerGuess selects the most optimal next guess based on minimizing the average number of remaining possibilities.
  3. letComputerPlay automates the guessing process, interacts with the game interface, and provides feedback on each guess

evaluateGuess(solution, guess):
The evaluateGuess function evaluates how accurate a guess is compared to the solution. It returns two counts:
correctPlace: The number of values in the guess that are correct and in the correct position.
wrongPlace: The number of values in the guess that are correct but in the wrong position.

Here's how it works:
It first iterates through the solution and guess, incrementing correctPlace for each match. It then counts occurrences of each value in both the solution and guess using arrays solutionCount and guessCount. For each possible value (1 through 6), it adds the minimum count from both arrays to wrongPlace. It subtracts correctPlace from wrongPlace to avoid double-counting values that are both correct and correctly placed.

computerGuess(possibleSolutions):
The computerGuess function selects the most strategic next guess from the list of possible solutions. It aims to minimize the average number of remaining possibilities by:
 - Iterating over each possible guess and evaluating it against all possible solutions.
 - Calculating the feedback for each solution and counting how many solutions would remain if that guess were made.
 - Determining the guess that, on average, leaves the fewest remaining possibilities, thus improving the chances of solving the game quickly.

letComputerPlay():
The letComputerPlay function controls the entire guessing process:
 1. Initiates the guessing process and inserts the guess into the game interface.
 2. Evaluates the guess using evaluateGuess and colors the feedback cells accordingly.
 3. Continues the process until the correct guess is found or a maximum number of attempts is reached.
 4. If the guess is correct (all values in the correct place), it triggers a delay and restarts the game.
 5. Updates the list of possible solutions by filtering based on feedback.
 6. Generates the next guess using computerGuess.


If you want to have a look at a source code, feel free to visit my Github

If you want to read more about this app, click here

If you want to read more about Mastermind game rules, click here

If you want to learn more about me, click here