## TUTORIAL ON MASTERMIND CODEBREAKING STRATEGY (7) VARIOUS CODEBREAKING STRATEGIES IN USE

Game Setting: No. of colours: 7; Start from: Trial 1; Length of code: Unspecified (3 - 5); Hints contain error(s)?: No error; Order type: Random order; Colour repeated?: Each colour at most 4 times

Code: 11410

In each of Tutorials (1) to (6), I concentrated on introducing one specific strategy for Mastermind codebreaking. In this Tutorial, let us see how we can use various codebreaking strategies to break a Code which is not so simple - the digits of the Code are arranged in random order; the Code may contain at most two blank spaces; each digit may be repeated at most four times. Let's start the game now.

In the beginning there is no constraint for Phases 1 and 2 and we may input any 5 digits. Suppose we input 00012 and the hint we get is 1,1. At the end of the 1st Round, we get the following Trace Table (please note that the following Trace Tables are a a combination of the Trace Tables as appeared in Tutorials (1) and (6):

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be CorrectPosition(s) Assumed to be Correct
1000121,100012--

Then we enter Phase 1 of the 2nd Round, i.e. we have to determine what digits should be included in the Code. Let's review our guess result in the 1st Round first. As we got 2 correct digits in the 1st Round, we assume that these 2 digits are 00. In addition, we also need 3 new digits, 334 say. Thus after the reasoning process of Phase 1, we obtain 00334 as the input for Phase 2.

Next we enter Phase 2, i.e. we have to determine the positions of the five digits - 00334. As in the 1st Round we got 1 digit in correct position, we assume that this position is A, i.e. we assume that the first digit of the Code is 0. The positions of the remaining 4 digits are yet to be determined. We consider positions B and C first. The digits in these two positions cannot be 0 (because we assume that B and C are not correct positions in the 1st Round). But they can be 3 or 4. So let us assume that these two digits are 33. Next we consider position D. There is not any constraint on the digit in this position, and so we assume that it is 0. Finally we determine the digit in position E to be 4. Having finished the reasoning process of Phase 2, we input 03304 and the hint we get is 0,2. Thus at the end of the 2nd Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be CorrectPosition(s) Assumed to be Correct
1000121,10001200A
2033040,2334--

Then we enter Phase 1 of the 3rd Round and review our guess results in the 2nd Round first. As in the 2nd Round we assumed that we had 2 correct digits (00), and the hint for that Round also showed that we got 2 correct digits, no progress was made. So we continue to assume that 00 is correct. In addition, we need 3 new digits, 556 say. Thus after the reasoning process of Phase 1, we obtain 00556 as the input for Phase 2.

Next we enter Phase 2, i.e. we have to determine the positions of the 5 digits - 00556. Previously we assumed that position A was the correct position for the 1st Round. However, the guess result for the 2nd Round was that no digit was in correct position. This shows that our assumption for the 1st Round was incorrect and so we return to the 1st Round and change the Position(s) Assumed to be Correct from A to B. There are still 4 positions yet to be determined. Based on our current assumption and the guess results for the 1st and 2nd Rounds, the digits in positions A, C and D cannot be 0. But they can be 5 or 6. So we assume that the digits in these 3 positions are 5, 5 and 6, respectively. Finally we determine the digit in position E to be 0. Having finished the reasoning process of Phase 2, we input 50560 and the hint we get is 1,0. Thus at the end of the 3rd Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be CorrectPosition(s) Assumed to be Correct
1000121,10001200B
2033040,2334--
3505601,0556--

Then we enter Phase 1 of the 4th Round and review our guess results in the 3rd Round first. As in the 3rd Round we assumed that we had 2 correct digits (00), but the hint for that Round was that we actually got only 1 correct digit. This shows that our assumption is incorrect. We must return to the 1st Round and change the Digit(s) Assumed to be Correct from 00 to 01. Next we proceed forward to the 2nd Round. Comparing 01 and 03304, we conclude that if the Code really contains 01, then we should get at least 1 correct digit in the 2nd Round. But the hint for that Round shows that we have 2 correct digits, which is one more than what we expected. We assume that this digit is 3. Next we proceed onward to the 3rd Round. Comparing 013 and 50560, we conclude that if the Code really contains 013, then we should get at least 1 correct digit in the 3rd Round. The hint for that Round is exactly that we get 1 correct digit. This shows that our assumption 013 is consistent with the guess result for the 3rd Round.

So far the assumed Code contains only 3 digits and we need 2 more digits. Although there is no new digit for us to use now, we may repeat the digits already used. So we next analyse which digit(s) may be included in the Code or repeated. Based on our present assumptions and the guess results for the 1st to 3rd Rounds, we find that 2, 4, 5, 6 cannot be included in the Code, while 0 and 3 cannot be repeated and only 1 is repeatable (the readers are asked to prove this). Thus after the reasoning process of Phase 1, we obtain 01113 as the input for Phase 2.

Next we enter Phase 2, i.e. we have to determine the positions of the five digits - 01113. As we have already modified the digits assumed to be correct in the 1st Round, in principle we have to make assumption for the correct positions anew. However, according to the previous reasoning, we know that position A cannot be the correct position in the 1st Round, so we may at the outset assume B to be the correct position in that Round. This assumption is consistent with our guess results in the 2nd and 3rd Rounds. Next we determine the digits in the remaining 4 positions. Based on our present assumption and the guess result for the 1st Round, 1 cannot be in positions B and D. But it can appear in the other positions. So we fill the 3 1s in positions A, C and E. Finally we determine the digit in position D to be 3. Having finished the reasoning process of Phase 2, we input 10131 and the hint we get is 1,3. Thus at the end of the 4th Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be CorrectPosition(s) Assumed to be Correct
1000121,10001201B
2033040,23343-
3505601,0556--
4101311,311--

Then we enter Phase 1 of the 5th Round and review our guess results in the 4th Round first. As in the 4th Round we assumed that we had 3 correct digits (013), and the hint for that Round shows that we actually got 4 correct digits, which is one more than what we expected. We assume that this digit is 1 (this 1 is not the 1 we used in the 1st Round, but is one of the two 1 newly added in the 4th Round). Now we assume that we have 4 correct digits and we need 1 more digit. Let's anaylse which digit(s) may be included in the Code or repeated. Based on our present assumptions as well as the guess results for the 1st to 4th Rounds, we find that 2, 4, 5, 6 cannot be included in the Code, while 0, 1 and 3 are not repeatable (the readers are asked to prove this). In other words, there is no number for us to use. But under the present game setting, we may use at most two blank spaces. Therefore we now use one blank space to fill the remaining vacant position. Thus after the reasoning process of Phase 1, we obtain 0113b as the input for Phase 2 (Note 1).

Next we enter Phase 2, i.e. we have to determine the positions of 0113b (please note that as b is not counted as a digit, in what follows we do not need to consider the position of b. We only need to determine the positions of the 4 digits - 0, 1, 1 and 3, and the remaining position will then be the position of b). As we have not modified the digits assumed to be correct in the 1st Round, we may continue to assume that B is the correct position in the 1st Round and try to determine the digits in the other positions. But when we review the guess result for the 4th Round, we will find that if B is the correct position, then the three 1s in the 4th Round are all in wrong positions, i.e. the digits in A, C and E are not 1. But then there will be no positions for the two 1s used in this Round. This shows that B is not the correct position in the 1st Round. So we return to the 1st Round and change B to C. However, this assumption cannot pass the verification in the 3rd Round, because the hint for the 3rd Round shows that we have got 1 correct position, but the digit 5 in position C in that Round is not among the digits assumed to be correct. So the correct position must be a position other than C. However, the digits that appear in that Round only include 0, 5 and 6, of which 5 and 6 are not among the digits assumed to be correct, and since we have now assumed that 0 is in position C, there cannot be another 0 appearing in another position. This contradiction shows that C is not the correct position. So we return to the 1st Round again and change C to D.

The above new assumption passes the verification in the 2nd Round. Next we proceed to the 3rd Round. Since the hint for the 3rd Round shows that we have got 1 correct position but the digit in position D in that Round - 6 is not among the digits assumed to be correct, the correct position must be a position other than D, and must be B or E. Let's assume B to be correct first, i.e. we now assume that the Code is x0x1x, where x denotes the digits which are yet to be determined in the respective positions. We try to fill the remaining 1 and 3 into these x. However, when we scrutinize the guess result for the 4th Round, we will find that there is no way for us to find a suitable position for the remaining 1 (the readers are asked to prove this). This shows that our assumption made just now (position B) is incorrect. So we return to the 3rd Round and change B to E. Next we consider the guess result for the 4th Round again. Since the hint for the 4th Round shows aht we have got 1 correct position but the digits in D and E are not the digits assumed to be correct in the 1st and 3rd Rounds, the correct position must be a position other than D and E, and must be A or C. Let's assume A to be correct first, i.e. we now assume that the Code is 1xx10. The position of 3 is yet to be determined. However, no matter whether we put 3 in B or C, it will contradict the guess result for the 2nd Round. This shows that the assumption made just now (position A) is incorrect. So we change the position assumed to be correct in the 4th Round from A to C, i.e. we now assume that the Code is xx110. We can then put 3 in position A and the remaining position B is then left blank. Having finished the reasoning process of Phase 2, we input 3b110 and the hint we get is 2,1. Thus at the end of the 5th Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be CorrectPosition(s) Assumed to be Correct
1000121,10001201D
2033040,23343-
3505601,0556-E
4101311,3111C
53b1102,1---

Then we enter Phase 1 of the 6th Round and review our guess results in the 5th Round first. As in the 5th Round we assumed that we had 4 correct digits (0113), and the hint for that Round shows that we only got 3 correct digits, which is one less than what we expected. This shows that our assumptions are incorrect and so we must go back to modify our previous assumptions. We return to the 4th Round first. As the new digits used in the 4th Round are all 1, which are unchangeable, we return to the 2nd Round and change the assumption for that Round from 3 to 4. Then we see if the new assumption can pass the verifications in the 3rd to 5th Rounds. The verification results show that we must assume 11 to be correct in the 4th Round (the readers are asked to prove this). Now that we have found 5 correct digits (01114), the reasoning process of Phase 1 is finished with 01114 as the input for Phase 2.

Next we enter Phase 2, i.e. we have to determine the positions of the five digits - 01114. As we have modified the digit assumed to be correct in the 2nd Round, we may preserve the position assumed to be correct in the 1st Round (D). But we have to consider the correct positions in the 2nd to 5th Rounds anew. As there is no correct position in the 2nd Round, we may skip that Round. In the 3rd Round there are two possible correct positions: B or E. But the reasoning we previously made tells us that if we assume B to be correct, there is then no way for us to find a suitable position for the remaining two 1s. So we can only assume E to be correct. Next in the 4th Round there are again two possible correct positions: A or C. This time we may assume A to be correct, i.e. we now assume that the Code is 1xx10. This assumption does not contradict the guess result for the 5th Round. Now the positions of the remaining 1 and 4 are yet to be determined. Based on the guess result for the 4th Round, 1 cannot appear in position C, and so it must be in position B. Finally we determine the digit in position C must be 4. Having finished the reasoning process of Phase 2, we input 11410. As a result, we break the Code. At the end of the 6th Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be CorrectPosition(s) Assumed to be Correct
1000121,10001201D
2033040,23344-
3505601,0556-E
4101311,31111A
53b1102,1---
611410WIN---

Note 1: Some readers may point out that as the Code for this game does not contain any blank space and now we assume that the Code contains one blank space, does it mean that the codebreaking strategy I adopt is far from satisfactory? My response is that during the process of making guesses, the Codebreaker does not know what the Code is and so he / she must not omit any logically possible Code. As a matter of fact, a careful reader should be able to find that the combination 3b110 is logically consistent with the guess results for the 1st to 4th Rounds and so it is absolutely a logically possible Code. Go to 3-Way A.I. Mastermind Website.