Question
I have to create an AI and I am baffled. It's a mastermind game. Each game allows you/the AI to guess a 4 color code
I have to create an AI and I am baffled. It's a mastermind game. Each game allows you/the AI to guess a 4 color code with any combination of 7 colors and colors can be repeated (white, black, green, red, pink, blue, and yellow). You have a max of 8 guesses before the game is over. I've spend 2 days trying to figure this out and I'm at a loss for what to do. Any help would be appreciated!
"Another approach that never takes more than 6 attempts but takes more time for early Guesses is called MiniMax. The idea is to create a List containing all possible Guesses (how many are there?). The first Guess in the List has all possible combinations of black and white buttons (how many are there of these?) assigned to it, one at a time. Since we don't know what button combination would be returned for that Guess, we must consider them all. A pass through all other Guesses for each of the black and white button assignments is made, counting up the number of other Guesses in the List that would be eliminated as possible secret codes. That is, we increment the count if comparing the two Guesses does not generate the specific black and white button count under consideration. The smallest of these eliminations (the mini part) is stored, along with the Guess that generated it. The AI is keeping track of the worst case that can occur for that particular Guess.
The second Guess in the List goes through the same process. If the smallest number of eliminations for this Guess is larger (the max part) than the previous smallest number of eliminations, store this new value and the Guess that generated it, otherwise keep the previous values. The AI is keeping track of the best of the worst cases for all of the Guesses.
At the end of the process, the computer player knows which Guess will eliminate the most other Guesses in the worst case. Make this Guess. Now remove from the List of Guesses those that are not consistent with the black and white buttons returned from MasterMind (as well as the Guess just made). Repeat the entire process for the second Guess.
The first Guess takes a long time to compute, but it is always the same (why?). To save a substantial amount of time, hardcode the first Guess to be red, blue, green, purple (or any four different colors)."
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started