What is Cows & Bulls?
Cows & Bulls is a classic code-breaking game. It predates both the famous board game Mastermind and the game which is a craze these days, Wordle! There are multiple variations but in its simplest one, you need to guess a secret four digit number picked by the computer. To learn about the history of this game, click here.
RULES:
- All four digits of this secret number are different.
- Each digit can be any number from 0 to 9.
- You start with a random four digit number as a guess.
- If a digit from your guess matches but is not in the correct position in the secret number, it is a "Cow".
- If a digit matches and is in the correct position, it is a "Bull".
GOAL:
To get four bulls in 7 guesses or less!
EXAMPLE:
- Secret number: 4596
- Guess: 5193
- Result: 1 bull and 1 cow (5 is a cow and 9 is a bull)
Demo & Screens
Here is a quick demo of the app!
The app has three screens:
- Home screen - From here, you can either:
- start a new game
- check your results (they are stored locally and so are specific to your device. If you play this game on two different mobile devices or on a desktop browser, your scores will not be the same across these devices)
- navigate to the How to screen to read the rules
- How To Play screen - Includes all the rules of the game including examples
- Game screen - This screen is broken down into two main sections:
- Guesses list where you can see all the guesses in a given game with the counts of cows and bulls in each guess
- Number entry. A few features that stand out:
- The text boxes aren't really text boxes. They are labels.
- There is an on-screen keyboard. This is because there were certain restrictions I wanted to place. For example, once a digit is clicked, it shouldn't be available for selection again in the same guess. Plus, when you click on a text box and the device's keyboard shows up, it kind of moves the app up and isn't the best user experience. And this is why I used labels instead of text boxes.
Cows & Bulls app sample
Two versions (MSAPP file, and ZIP package for import) of this game can be found here.
1 thought on “How to build Cows & Bulls – the numeric Wordle!”