This Demonstration lets you play the classic game "Bulls and Cows" against the computer. Other names are "moo" and the trademarked name "Mastermind." The default settings are four pegs and six colors, the same as were used in the physical game. Variants allow the player to select from two through six pegs, and from two through eight colors.
In this game, the computer randomly selects an arrangement of colors (with repetitions allowed). You are to determine that arrangement by making successive guesses. The guesses become more educated at each turn, since feedback is provided.
To make a guess, click the four squares at the top of the pane to change their colors, then press the "submit" button. If you pass a color that you wanted, just keeping clicking—they cycle. Note: at the beginning of the game, and after each turn, the squares return to white, which is one of the permissible colors.
After you press the "submit" button, your guess will appear below along with two numbers. The first number is the number of pegs (colors) that are correct and in the correct position. The second number is the number of remaining pegs (those not counted by the first number) that appear in the correct answer, but in a different position.
Contributed by: Marc Brodie (Wheeling Jesuit University)