Recently my 4.5 year old son started playing “Mastermind”. This is a game where one player picks a 4 color code, and the other player has to guess it. After each guess, the first player lets the guesser know for how many colors both the color and position were correct, and how many only the color was correct and the position was wrong.
In our box game the code pins can be blue, red, green, yellow, orange or cyan, and there are special black and white pins – black is used to indicate a correct guess (color and position), and white indicates an almost correct guess (only color).
So my son wanted to play with me, and just like any proper troll dad, I started to progressively teach him new techniques.
Guessing effectively
Let’s say you’re the guesser. What would be an effective way to guess the code? My son would try some random colors, and based on the information he received, would try a second guess. When it was my turn to guess – my first guess was all red. Let’s say I got one pin right, because if not I would just move on to the next color. My second guess was one pin red and the rest blue. In each guess I would try to place the first red pin in the correct position while adding the most information about a second correct pin, and so on.
After a couple games like this, we switched and my son was the guesser, and he quickly tried the new technique and we moved on.
Making the code harder v1
So I asked my son if he wanted me to make it an impossible challenge. He said yes. I asked him if I’m allowed to use all the colors. He said yes. So I used black and white (the guess response pins) as my code. After going through all the colors and not being able to get any correct guesses he gave up and looked at my code, and was angry as I expected. Cue a few games where we played with the new setup, and he learned to use the new technique.
Making the code harder v2
Then, as the code picker, I again asked if he wanted me to make it an impossible challenge. He again said yes. So I picked a code with two missing pins, as “missing” or “transparent” can also be considered a color. Same as before, after a few guesses he gave up and looked at the code all frustrated, but afterwards he was happy with the new technique.
Playing it by ear
After the previous technique I was the guesser and my son was very pleased with all the new options of making the code harder (essentially having added 3 new colors – black white and empty). So he picked a code that he thought was going to stump me – 4 missing pins. I knew he would use the missing pins, so after he set the code I lightly tapped the game board with my fingers while thinking. Since tapping the game board made no sound – I immediately knew the code had no pins and got it in one guess. Afterwards I explained what I did and after trying together we saw that with finger tapping we could differentiate between 4, 3 and 2 missing pins. Nice!
Counting cards
For the next game my son picked some code, I think it was 3 colored pins and one missing. I told him I was going to guess it much faster using a trick. So before he set the code – I saw the game box held 10 of each of the colored pins. As soon as he set the code, I just counted the number of missing pins from the box, and knew exactly which pins where in the code, just not the their order. My son was sufficiently impressed, but in subsequent games asked me not to use that cheat again.
Aftermath
My son learned several important lessons:
- His dad is a troll dad
- You can win more if you think outside the box
- Breaking the rules is sometimes ok, depending on the game
Postscript
- Knuth has a very nice algorithm for solving this game, however, the goal of playing with my son was not this kind of optimization, at least not this time.
- Yes, this is similar to the Wordle craze that’s going around, but it’s unrelated. My son picked up Mastermind after he got it as a Hanukka Present.
That’s great! We have a version of this game we play with our daughter… Gonna make her cry!