Mastermind is a game played by two players, the codemaker and the codebreaker. The game begins with the codemaker selecting a code, a sequence of four colors (digits, pegs or other symbols) (c1, c2, c3, c4) chosen from a set of six colors (repetitions allowed). The codebreaker will then try to guess the code. After each guess (g1, g2, g3, g4), the codemaker responds with two numbers. The first, the number of exact matches, is the number of times ck = gk , k = 1, . , 4. The second, the number of near matches, is the number of colors in the guess which are the right color, but in the wrong position. In the applet bellow the number of exact matches is indicated by small red dots,
while white dots define the second number. In the real game the codemaker uses small pegs for the same purpose.
Now, you are the codemaker. You must assist computer to arrive at the secret code by providing feedback to his/her guesses. To this end click on the two numbers to the right of every row. (In the game with only exact matches only one number is displayed.)
See if the computer is any good at it. Usually the computer follows a predefined strategy. But you may make it select a move randomly from the set of all eligible moves, i.e. moves that do not contradict your responses.