This project is the first of the three “Guess the Number” projects that I’ve completed (before Guess the Number (iOS) and Guess the Number AI). I had played this game long before I wrote this program. During the period when I was self-learning Visual Basic, I decided to make a program of this game which the player guesses the number randomly generated by the program.
The two-player game is also named Bulls and Cows, which one player thinks of a four-digit number with every digit being unique and the other player trying to guess that number. During each turn, the player who guesses speaks a number while the other replies with how many A’s and B’s according to the relationship between the guessed number and answer. The number of A’s indicate how many digits in the guessed number are identical with those in the answer and are on the same location; the number of B’s indicate how many digits are identical but aren’t on the same location (e.g. 2A1B should be replied when a guessed number is 1234 and the answer is 1532). The player guesses until the answer is guessed and the round ends. Players may take turn playing the opposite role and try to guess as few times as possible.
This mini-project encouraged me to design more complex programs, and is an important milestone in my journey of programming.