Canvas Apps Controls Expressions Offline UI

How to build Cows & Bulls – the numeric Wordle!

Cows & Bulls!
Cows & Bulls!

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:

  1. All four digits of this secret number are different.
  2. Each digit can be any number from 0 to 9.
  3. You start with a random four digit number as a guess.
  4. If a digit from your guess matches but is not in the correct position in the secret number, it is a "Cow".
  5. 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:

  1. Secret number: 4596
  2. Guess: 5193
  3. 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:

  1. Home screen - From here, you can either:
    1. start a new game
    2. 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)
    3. navigate to the How to screen to read the rules
  2. How To Play screen - Includes all the rules of the game including examples
  3. Game screen - This screen is broken down into two main sections:
    1. Guesses list where you can see all the guesses in a given game with the counts of cows and bulls in each guess
    2. 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 screens
Cows & Bulls screens

Cows & Bulls app sample

Two versions (MSAPP file, and ZIP package for import) of this game can be found here.

Recent articles

  1. Mastering Dataverse relationships in canvas apps
  2. Power Teleprompter!
  3. Pinterest like gallery!

1 thought on “How to build Cows & Bulls – the numeric Wordle!”

Leave a Reply