Bulls and Cows (head-to-head)

Start game with computer guessing:
Human
Next guess:
Computer
 
 

Instructions
  • Bulls and cows is a lot like the commercial game MastermindTM, but using four-digit numbers instead of coloured pegs.
  • In this version, you play head-to-head with the computer, taking alternate turns to guess each other's number.
  • The winner is the first player to guess their number. You always play first and so have a small advantage.
  • Each guess is marked according to how many bulls (that is correct digits in correct locations) and how many cows (that is correct digits but in the wrong position) are present in the guess; each guess digit is marked once. The number of bulls and cows for each guess is displayed in red to the right of the guess. For example, if the code is 1233 and the guess is 3243, then the response would be 2 bulls and 1 cow since the guess includes the 2 and the second 3 correctly and in the correct positions, while having guessed the first 3 correctly but in the wrong position.
  • The computer has a simple strategy: its first guess is random, then it tries each next highest number in turn, using the first one it finds that fits the marking so far.
  • To play the game, first enter a number for the computer to guess (it doesn't cheat!) at the top of the table and click 'start', then enter your guesses at the bottom of your column. Alternatively, click 'random' to give the computer a random target.
  • It is possible to beat the computer if you are skilfull! Here is a page that discusses the mathematics of the Mastermind game.


JavaScript © 2004 Mark Huckvale, University College London