Bulls and Cows

From Wikipedia, the free encyclopedia
  (Redirected from Bulls and cows)
Jump to navigation Jump to search
4digits, an Open Source version of Bulls and Cows.

Bulls and Cows (also known as Cows and Bulls or Pigs and Bulls) is a code-breaking mind or paper and pencil game for two or more players, predating the commercially marketed board game Mastermind.

The game is played in turns by two opponents who aim to decipher the other's secret code by trial and error.

The numerical version[edit]

The numerical version of the game is usually played with 4 digits, but can also be played with 3 or any other number of digits.

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 in their right positions, they are "bulls", if in 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 player to reveal the other's secret number wins the game.

The game may also be played by two teams of players, with the team members discussing their strategy before selecting a move.

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 among 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 still being difficult and entertaining, there are many computer variants; it is often included on cellphones and PDAs.[citation needed]

It is proved that any number can be solved within seven turns. The average minimal game length is 26274/5040 ≈ 5.2131 turns.[1][2]

The word version[edit]

This version is usually played orally, but is easier to play if each player (or each team) keeps written notes. It is exactly like the numerical version, except instead of 4-digit numbers, 4-letter words are used. They must be real words, according to whatever language or languages you are playing the game in. Alternate versions of the game can be played with 3-letter or 5-letter words, but the 4-letter version is the most popular.

The game play for the word version is as follows.

  • One person (the Host) thinks of an isogram word (i.e. no letter appears twice) and, if the word length is not pre-determined, announces the number of letters in the word.
  • Other players (the Guessers) try to figure out that word by guessing isogram words containing the same number of letters.
  • The Host responds with the number of Cows & Bulls for each guessed word. As with the digit version, "Cow" means a letter in the wrong position and "Bull" means a letter in the right position.

For example, if the secret word is HEAT, a guess of COIN would result in "0 Bulls, 0 Cows" (all of the guessed letters are wrong); a guess of EATS would result in "0 Bulls, 3 Cows" (since E, A, T are all present, but not in the guessed positions), and a guess of TEAL would result in "2 Bulls, 1 Cow" (since E and A are in the right positions, while T is in the wrong position). The game continues until one of the Guessers scores "4 Bulls" for guessing HEAT exactly.

See also[edit]

References[edit]

  1. ^ "Optimal algorithms for bulls and cows game". slovesnov.users.sourceforge.net.
  2. ^ Liu, Chao-Lin. (2001). "Mathematics, Computer Science, and Number Games" (PDF). Science Monthly (in Chinese). 32 (3): 250–255.

External links[edit]