How To Play Cows & Bulls Game

Cows & Bulls is a wordle style number game. It definitely pre-dates wordle because we played this game as kids in high school 😀. It is a two player game. In our case, the browser is the first player. The basic premise is to guess the number that was randomly chosen by the computer player. In the current version, there are no limits on the number of attempts you can take to guess the number either.

The rules of the game are very simple. The computer player has a 4 digit number to start the game. The user tries to guess this number. Each time the computer player gives feedback on how close their chosen digits are to the actual number as cows and bulls. Wikipedia has an article on this game too.

Playing the game

  • The starting number is 4 digits wide.
  • Digits do not repeat themselves.
  • Only digits 1-9 are used. 0 is not used in this version.
  • When a digit is guessed correctly and is in the correct position, it is a bull.
  • When a digit is guessed correctly but is in the wrong position, it is a cow.
  • Unlike wordle, though, you do not know which digit is a cow or a bull or neither.

You win when you guess 4 bulls. In this version, we do not limit the number of attempts taken to guess the number.

Planned Upgrades

I wrote this game to practice a bit of functional programming with clojurescript. So I made all assumptions that made the implementation simpler.

That said, I do plan to improve the following things:

  • Ability to limit the number of guesses.
  • Ability to increase number of digits.
  • Ability to include 0 in the list of digits.
  • Allow repeating digits.