Bulls and cows
Bulls and Cows (also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots) is an old code-breaking paper and pencil game for two players, predating the similar commercially marketed board game Mastermind.
It is a game with numbers that may date back a century or more. It is played by two opponents. The game can also be played with 3 digits instead of 4.
On a sheet of paper, the players each write a 4-digit secret number. The digits must be all different. Then, in turn, the players try to guess their opponent's number who gives the number of matches. If the matching digits are on their right positions, they are "bulls", if on different positions, they are "cows". Example:
- Secret number: 4271
- Opponent's try: 1234
- Answer: 1 bull and 2 cows. (The bull is "2", the cows are "4" and "1".)
The first one to reveal the other's secret number wins the game. As the "first one to try" has a logical advantage, on every game the "first" player changes. In some places, the winner of the previous game will play "second". Sometimes, if the "first" player finds the number, the "second" has one more move to make and if he also succeeds, the result is even.
The secret numbers for bulls and cows are usually 4-digit-numbers, but the game can be played with 3 to 6 digit numbers (in every case it is more difficult than with 4).
The game may also be played by two teams of 2–3 players. The players of every team discuss before making their move, much like in chess.
A computer program moo, written in 1970 by J. M. Grochow at MIT in the PL/I computer language for the Multics operating system, was amongst the first Bulls and Cows computer implementations, inspired by a similar program written by Frank King in 1968 and running on the Cambridge University mainframe. Because the game has simple rules, while it is difficult and entertaining, there are many computer variants; it is often included in telephones and PDAs.
See also 
- Fallout 3 and Fallout New Vegas feature a 'letter-version' of this as a minigame for hacking computers.
- Neverwinter Nights 2: Mask of the Betrayer implements a version of this as the "Hells" game, in which the player must guess the correct sequence of nine unique Hells (similar to the digits 1 through 9)
- Jotto—a similar game with words
- Mastermind—a similar game with colored pegs instead of digits
- Optimal algorithms for bulls and cows game.
- http://www.cs.nccu.edu.tw/~chaolin/papers/science3203.pdf (Chinese version) Chao-Lin Liu. "Mathematics, Computer Science, and Number Games", Science Monthly, 32(3), 250-255, 2001.
- 4digits, an Open Source version of Bulls and Cows
- Page with the PL/1 code for Moo by J.M. Grochow
- Description of Bulls and Cows with numbers, and a Web playable version
- Online version of Bulls and Cows game
- Knuth, D. E. "The Computer as a Master Mind". J. Recr. Math. 9, 1-6, 1976-77
- Francis, J. "Strategies for playing MOO, or 'Bulls and Cows'"