- Home
- Hobbies & Games
- Mastermind Game Strategy
Mastermind Game Strategy
- By George Lane
- Published 10/17/2008
- How To , Hobbies & Games
- Unrated
George Lane
Born in 1964 in Enfield, educated in Enfield & Manchester. I have competed in mind sports events (chess, mental calculations, poker etc) and won 27 medals in these in the last 11 years. I write in science fiction, general fiction, mathematics, general mind sports & several other topics besides. My interests are in the same subjects, as well as photography, wildlife, puzzles & quizzes, walking and just generally having some 'quiet thinking time'.
View all articles by George LaneMASTERMIND STRATEGY
Mastermind is a classic game, played with coloured pegs which are placed into holes in a playing board. There are several variations, with championship events using eight different colours of playing pegs and four spaces in each playing line on the board. That is thus the version we shall concern ourselves with here.
The game is played in two parts; the two players taking opposing roles for one part of the game, then they swap roles for the second half. In each of the two phases of the game, one player creates a ‘code’ from coloured pegs and the other player tries to deduce the Nature of that code. Here’s how that’s done:
Setting a code
One player places four coloured pegs of their choice into a row of four holes, one peg in each hole. These need not be pegs of four different colours; some players even set codes of four pegs of the same colour in a misguided attempt to confound their opponents. This tactic actually allows a skilled opponent to break the code slightly faster than average. Once the selected code is in place, the pegs are partially obscured by a small shield which, however, still allows the code maker to see the pegs for reference during the game.
Attempting to break the code
The player attempting to break the code then places four pegs into the first of several rows of four holes. The idea here is to replicate the code, i.e. the sequence of coloured pegs, set by their opponent. The code maker then places a set of slimmer pegs, used for marking purposes, in a small area alongside the code breaker’s attempt which is set aside for this purpose. The attempt at the code sequence, along with the marking pegs received, stays in place (for reference purposes) for the rest of this phase of the game. The code breaker uses the information thus gained in order to narrow down the possibilities until the code sequence is identified.
Marking an attempt
For each correctly coloured peg in the correct position, one black marking peg is issued. If the code breaker has placed into their attempt a peg of a colour used in a different position in the code, this attracts a white marking peg. No coloured peg can receive more than one marking peg, and no more than one marking peg should be issued in respect of any one peg within the code. However, if two pegs of any one colour are used in the code and two pegs of that same colour are used in one attempt, they should be ‘rewarded’ with two marking pegs.
Some examples:
Marks
Code Attempt Black White
Blue/Yellow/Red/Green Blue/Green/Pink/Brown 1 1
Blue/Red/Blue/Pink Blue/Green/Yellow/Purple 1 0
Red/Yellow/Pink/Purple Pink/Blue/Brown/Pink 0 1
Red/Brown/Red/Yellow Red/Purple/Pink/Red 1 1
Orange/Brown/Brown/Orange Orange/Brown/Orange/Brown 2 2
Red/Blue/Green/Brown Red/Blue/Green/Brown 4 0
This last example shows that the code has been identified fully; this marks the end of this phase of the game. The number of attempts required to break the code is recorded and the roles are exchanged. All pegs are removed from the board prior to the second phase being played.
Winning the game
Whoever takes the lower number of attempts to break their opponent’s code is the winner. If both players take the same number of attempts to achieve success, the game is drawn.
Competition rules
Competition tournament games carry additional rules which are not generally used in friendly/social games. Clocks are set to strict time limits and serious penalties are levied for running out of time whilst trying to break a code. These rules are liable to change from one tournament controller to another and so they need not concern us here.
One common – and, indeed, sensible – rule thus applied regards the conduct of the game in the event of an attempt being marked incorrectly. At the first mistake in the marking, the code breaker is deemed to have solved the code on the following line – unless the wrongly marked line is the correct code sequence, in which case this attempt is counted as the correct solution.
Using the information gained from marking
The code breaker can assemble small items of information gleaned from the markings for attempts already made in order to determine the likely colours (and their positions) in the code sequence. Take a look at the following game:
Marks
Code attempt Black White
Blue/Green/Red/Blue 1 0
Blue/Green/Blue/Green 0 0
Yellow/Orange/Pink/Purple 1 0
Brown/Purple/Red/Brown 2 2
From the first line, with only one marking peg, we can see that only one of the three colours used (blue, green, and red) is in the code. Furthermore, we can see that if that colour is blue then there is only one blue peg present. If the ‘scoring’ colour is green or red, the colour may be repeated within the code.
The second line attracts no marks – so we now know that there are no blue or green pegs in the code. Along with the information from the first line, we can thus deduce that the red peg has attracted the marker. Since the marker is black, we also now know that the red peg is in the correct position.
Line three is an experimental line which shows us that only one of the four colours used is present in the code, and that it has been placed in the correct position. And we know it can’t therefore be the pink peg; that’s in the position where we know a red peg should be.
The fourth line tells us, via the four marking pegs, that we have correctly identified the colours of the four pegs used in the code. Two of the pegs are in the correct positions, and we know the red peg is one of these. As this line tells us that a purple peg is used, that must have been the ‘scoring’ peg from the third line. This also tells us that the purple peg should be in the fourth position. Therefore the purple and the fourth-placed pegs are in the wrong positions. With the other two pegs having been correctly placed, these two are swapped over to give the correct solution – Brown/Brown/Red/Purple.
Ok, so now you’ve got a ‘feel’ for the basics of the game and how it’s played. But how to win? Well, there is no guarantee of this – even if you have a great strategy. Indeed, even a perfect strategy cannot guard against pure luck; you may play with perfect strategy (taking six lines to solve each of your opponents’ codes) and still lose each and every match in a tournament event.
A note about sacrifices
Most people are aware of sacrifices in chess, such as surrendering one’s own Queen in order to checkmate the opponent’s King. But can sacrifices be played in Mastermind too? Well, the answer is ‘yes’. There are two forms; strategic and tactical. Let’s look at each in turn:
Strategic sacrifices
These are typically used during the early stages of seeking the solution. Many possibilities still exist for the opponent’s code, but none of these seems to generate a great ‘spread’ of scores. Each ‘logical’ attempt at the code has very few scoring possibilities – and each of these leads to a large number of possible codes. By playing a line which cannot possibly be the correct answer, i.e. a sacrifice, it is possible that such a line might yield any one of a somewhat wider range of possible scores; each such possibility would thus lead to fewer possible solutions and thus effect an overall acceleration towards the final solution. Numerous examples of this form of sacrifice are to be found within this strategy, notably the lines following some of the lower scoring responses to the second attempt at the code once the solver has achieved three mixed scoring marks for the first attempt.
Tactical sacrifices
This type of sacrifice is used when you have most of the code already solved. By sacrificing one or two points in the part of the code you already know, you can gain much information on the remainder. Here are two examples of how tactical sacrificial play can be put to good use:
Example 1
You know the first three pegs are blue/blue/red, but you have still to choose between green, pink and yellow for the last. If you were to take each in turn, you would take an average of two lines to solve the code and a maximum of three lines. By playing blue/blue/green/pink on your next attempt, you are sacrificing the chance of solving in one further line (the one you have just played) in order to guarantee knowing the correct solution for the following attempt. This still takes an average of two lines, but the maximum length of the solution comes down from three lines to two – and that can be enough to save the game.
Example 2
You have blue/red/red for the first three colours, but you have still to choose between green, pink, orange, purple and yellow for the last. If you now play blue/orange/purple/yellow, you will still get the mark for the blue peg at the beginning of the code plus one possible further mark. An additional black mark identifies the final peg as being yellow, a white mark leaves you to choose between orange and purple, and no additional mark means the final position is either pink or green. By playing this sacrifice, you reduce the maximum length of solution from 5 to 3 lines and the average from 3 to 2.4. This would be recommended in all such cases except where an immediate solution is essential for saving the game.
And now, the strategy itself
Now that you know about sacrifices as well as standard play, I’m, sure you’d agree that it would be an insult to walk you through the whole game like a baby. It would also take all the fun out of it for you, since it would leave you with nothing to do for yourself. I therefore offer to chauffeur you through the first three moves – then I put you in the driving seat. Good luck!
Firstly, here’s a numeric representation. Replace the numbers with colours, even shuffle the positions – and away you go.
First line Score (B/W) Second line Score (B/W) Third line
1123 0/0 4567 0/0 8888
0/1 8488
0/2 8845
0/3 5648
0/4 5674
1/0 4488
1/1 4858
1/2 4685
1/3 4656
2/0 4548
First line Score (B/W) Second line Score (B/W) Third line
2/1 4546
2/2 4576
3/0 4568
4/0 Finished!
0/1 2456 0/0 3778
0/1 3748
0/2 3547
0/3 4275
0/4 4562
1/0 3478
1/1 5471
1/2 4752
1/3 2564
2/0 2478
2/1 2475
2/2 2465
3/0 2544
4/0 Finished!
0/2 2415 0/1 3267
0/2 3642
0/3 5261
0/4 4251
1/0 2367
1/1 3246
1/2 5216
1/3 2541
2/0 &n

