Mastermind - Strategy for Real People
There are many documents out there that talk about algorithms or strategies for cracking a mastermind code. These are suited ideally to a computer program however and not the way a normal human would typically play mastermind. Below I will present some general strategies for human players. Treat these as a guide however. You may come up with other methods that you prefer. These strategies are appropriate for the Game of Mastermind by Invicta or Code Breaker.
For this we will assume you are playing a game of Mastermind which has the following characteristics:
- 8 pegs to choose from
- 5 pegs in the code
- no empty spots in the code
- no duplicate colours in the code
The starting play
Your first attempt in Mastermind will be completely random. You have no information yet so there is nothing to base this attempt on. The result from this attempt however will influence your strategy in the rest of the game.
The ideal scenario is that you will get 5 correct pegs in the first attempt but this is highly unlikely. More likely is that you will get 2, 3, or 4 pegs correct as having only 1 correct peg is impossible so let's look at these.
(For now we won't worry about if they are in the correct position or not, only with if they are in the code.)
2 Pegs Correct
This is a great situation to be in. There are 8 pegs all up and you have already placed 5 meaning that the remaining 3 must be in the code. Working out which 2 of the initial 5 is in the code not too difficult.
3 Pegs Correct
This is getting a little trickier. 3 of the initial 5 pegs are in the code and 2 of the remaining 3 pegs are in the code. You now have two sets to work with so it's a little harder to narrow down.
4 Pegs Correct
This is harder yet again. 1 of the initial 5 pegs is incorrect and 1 of the remaining 3 pegs is in the code. This means you have a lot of different combinations to play with.
As you can see, it is actually better to have fewer pegs correct in your first attempt. This may seem counter intuitive but after you have played a few games it will start to make sense.
Beyond the first attempt
After your first attempt you have some feedback with which to work on. Remember, Mastermind is a game of logic and deduction so you could place your second attempt randomly but it's probably better to start using your brain.
Every Mastermind situation will be slightly different in terms of how you approach it but here are some general pointers.
Work with Colours First, Then with Placement
With some on-line versions of Mastermind it is hard to rearrange the pegs in your code. It is easy in this version however. Use this to your advantage. Place the colours that you think might make up the code Don't worry about the order right now, we'll deal with that next. Now go back through each previous attempt and compare the colours in conjunction with how many were correct for that particular guess. You're aiming to pick a set of colours that will satisfy the answer pegs for every previous attempt. The more attempts you've had the more effective this will be.
In this example you can see that we haven't got our colours right yet. We have four of the colours from the first attempt which suits the answer pegs. We have 4 of the colours from the third attempt which also suits the answer pegs. We have 4 of the colours from the second attempt however while the answer pegs state we should only have 3. We need to keep experimenting until we get the colours to fit. Can you think what might work?
Next Work with Placement
Once you are happy with the colours, let's play about with the order. For this we will be looking again at the previous attempts but now the black and white answer pegs become important to us. Sometimes you'll be lucky and it will be obvious that certain pegs must be in certain positions but often this is not the case.
The best approach is to work backwards. Don't search for the correct code, instead cancel out incorrect codes. Place your pegs in any order, then compare to the data you have in previous attempts and try to find a situation where this particular code will not fit in with the data given. Then we can cancel that out and try something different. Again compare to previous attempts and continue. Using this approach you will normally narrow down the range of possible codes dramatically.
In this example we have all our colours correct and are now playing with placement. In the third and fourth attempts we had some pegs that were placed correctly. I know that it cannot be the blue and aqua pegs as then I should also have atleast 2 correct in the fourth attempt and this is not the case. Could it be the green and orange? Let's see if it can fit. If the green and orange are correct then one of the others in the fourth attempt is also correct. It can't be the aqua or blue and that only leaves the first peg which is orange which can't be correct either. We have now cancelled out this possibility too. If we say that the aqua and orange in the third are correct then green must be in the first position. This leaves only pink and blue to place but we can't without breaking either the fourth or second attempt. Thus we can conclude that aqua and orange are not the 2 correct pegs in the third attempt. By similar reasoning we can knock out green and blue. We have now greatly narrowed down our possibilities and if we don't get it correct in this attempt we are virtually guaranteed to get it on the next one.
Now you have your mastermind strategy, let's go and put it into practice. See how you go at our on-line game.
Note: Mastermind was invented by Invicta Plastics in 1971 who holds the worldwide Trademark for this name. Hasbro is licensed to manufacture this game in most of the world if you would like to purchase a physical version. The game itself is actually based on a game called Bulls and Cows which is believed to have been created more than a century ago.
Mastermind - Proudly brought to you by CreativityGames.net.
Games to develop your creative thinking.