Bulls and Cows aka Mastermind

by Rasmus Torkel

Bulls and Cows is a very old game where one player has to guess a sequence (or solution) of known length constructed from a known set of possible symbols or colours. For each guess by the guesser, the marker has to let the guesser know the number of "bulls" and "cows". A "bull" is a symbol or colour in the guess that is also in the set solution and in the same position. A "cow" is a symbol or colour in the guess that is also in the solution but in a different position.

Originally, the game was played with pencil or pen and paper. Later, commercial version were released, sold as "Mastermind", where the marker makes a sequence from coloured pins, hidden from the guesser. The guesser makes his guesses from the same pool of coloured pins. Other pins are used to represent the bulls and cows.

I have built my own version of the game, where the marker is the computer. "Mastermind" is a protected name which I have no right to use to name my version. Inventing a new name would just cause more confusion, so I am sticking to the original name.

Playing my Game

The image shows a completed game, not necessarily played the best possible way. We see four panels. The solution panel at the top shows the solution once the game is completed.

Each row in the guess panel corresponds to one guess and the row in the result panel to the right of it corresponds to the result for the same guess.

To fill in a guess, simply pick for each column one of the colours in the colour panel. You can change your mind as often as you like until you click the result panel. You can even blank a cell out again by clicking on it.

When you are satisfied with your guess, you click the result panel. In the result panel, full green represents a bull, medium yellow represents a cow and small red represents a mismatch. The order is always green, then yellow, then red, regardless of which cells in the guess produced a bull or cow.

A game can end in three ways, apart from simply leaving it:

You know a game has ended when the solution appears in the solution panel.

To play another game, simply start selecting colours again.

My version has two modes, random and tricky. In random mode, the game picks the solution to be guessed totally at random. In tricky mode, the game is rather unconventional in how it picks a solution, to say the least. Expect to need more guesses.