Friday, 24 February 2012

Mastermind conundrum

My kids are now of the age where they enjoy playing Mastermind. It has been agreed that the code-setter will always use four different colours, rather than the more sneaky version where the code-setter is allowed to use two or more of the same colour.

If you use one of each colour, then logically, the 'score' (the little red and white pegs) would be the same, whether you mark the guess on the basis of the answer or vice versa, because each coloured peg only counts once, for example:

Code: Re-Gr-Bl-Ye
Guess: Pu-Pi-Re-Ye

If the code setter marks the guess on the basis of the code, the purple and pink score nothing, the red scores a little white peg and the yellow scores a little red peg.

If the code-setter marks the code on the basis of the guess, the green and blue score nothing, the red scores a little white peg and the yellow scores a little red peg.

So we get the same mark either way - a little red peg and a little white peg. So far so good.
-----------------------------------------
Question: does this reciprocity hold if the code-setter is allowed to use two or more of the same colour? For example:

Code: Re-Gr-Rl-Ye
Guess: Pu-Pi-Ye-Bl

The purple, pink and blue score nothing, leaving a yellow, which scores a little white peg.

Now, with the same code, how do you mark...

Guess: Pu-Pi-Ye-Ye?

The purple and pink score nothing, there's one yellow in the correct place, which scores a little red peg, but what about the other yellow peg? In the absence of the correct yellow peg, it would have scored a little white peg. Some sort of logic and fairness says it gets nothing, because the yellow in the code has been 'used up'.

Further, if you were to mark the code according to the guess, you'd get the same result, the yellow in the code is in the 'correct' position, so that's one little red peg and the two reds and the green score nothing.

So, that's the question: if you are playing the sneaky version where the code setter is allowed to use the same colour more than once, can you ever have a code/guess combination where marking the code would give a different result to marking the answer?

11 comments:

Derek said...

I've always played what you call the sneaky version. In fact it never occurred to me that playing more than one peg of the same colour in the code might be wrong.

The total number of scoring pins is equal to the number of coloured pegs in common between the code and the guess. The number of those pins that are red (or black in the older version that I have) is equal to the number of coloured pegs in the same position in the code and in the guess.

Oh, and it doesn't matter whether you score the guess against the code or the code against the guess since you are looking at what they have in common.

Derek said...

So the answers to your questions are:

1) Pu-Pi-Ye-Ye scores 1 red pin because it has one matching colour and that colour is in the correct place.

2) Marking the code against the guess always gives the same result as marking the guess against the code.

Anonymous said...

"Oh, and it doesn't matter whether you score the guess against the code or the code against the guess since you are looking at what they have in common."

Indeed, in fact I would say it's not meaningful to attempt to distinguish between marking the code and marking the guess for this reason.

Derek said...

I'd also score Ye-Ye-Pu-Pi as 1 white pin because it has one matching colour but that colour is in the wrong place. The fact that I can't tell which of the two Ye pegs is the match doesn't really matter: they are both in the wrong place.

Mark Wadsworth said...

D, F, I also assume that you get the same mark whichever way round you do it, only I'm not 100% sure.

Derek said...

Back in 1979 I wrote a Mastermind scoring program for my programmable calculator. As I recall the operators are all commutative.

Basically to find colours in correct positions I did a straight AND (using arithmetic - tricky) of the colours followed by a count of the non-zero digits in the result. That's a commutative process. For the correct colours, I counted each colour in the code and the guess and then took the lowest of each colour result. Which is again a commutative operation.

So I am certain.

View from the Solent said...

This looks interesting. But I haven't the foggiest what you are talking about ;0

The Hickory Wind said...

My instinctive response is that the propositions are symmetrical and so you must get the same score, but a full analysis would take a little longer (and let's face it, it's Friday night).

I remember, as a lad, buying the numbers version of Mastermind (being a numbers sort of lad), which should have been much more difficult, but in fact (does anyone else remember?) they only gave you the numbers from 1-6 so it was isomorphic with the colours version. Very disappointing.

Mark Wadsworth said...

VFTS, was that addressed at Derek (who seems to know what he's talking about) or at me (who doesn't)?

CI, don;t you mean numbers 1-8, our Mastermind has 8 colours?

The Hickory Wind said...

MW

I daresay you're right. It was a long time ago. I just remember that they didn't have a full set of digits.
What Derek says at 18:21 suggests he's done the analysis and it is indeed symmetric (which is what the operations being commutative means). I hadn't read his comment properly before I posted mine.

Mark Wadsworth said...

CI, ta, so I'll assume the marking is indeed symmetrical/commutative.