Word Bulls & Cows

Programming Word Bulls & Cows

Our program for playing Word Bulls and Cows works as follows.

For each number of letters the program uses a dictionary of words with that number of letters. It first calculates a list of all the candidate words that are consistent with the replies given by the player so far.

If there is only one candidate, this must be the answer (unless the player has made a mistake), and this is given as the next guess.

To ensure that the program responds promptly it imposes a time limit on the calculations. If there is not time to perform further processing the program returns one of these candidates selected at random.

Otherwise the program calculates the benefit of asking every possible word. The word that is expected to eliminate the greatest number of candidates is then used as the next guess. As explained in Strategy, this is not necessarily one of the candidates.

Other topics




BlogRSS FeedAbout Pencil and Paper GamesContact Us