How to play Bulls and Cows between you (the host) and your computer (the player)
When completed, your program allows you to host the game (i.e., you create a secret word and score every guess) and it makes guesses until it wins. During the development or testing of your program, you may set a condition (e.g., the total count of guesses is already 10) to allow your program to request to reveal the secret word and quit the game.
In this player mode, your program should:
1. Display a total count of guesses with a new generated guess, which should be a 5-char string with '@' always included and the rest four characters drwan from any of the below 3 sets
characters:
{R, S, T, U, V }
{ 5, 6, 7, 8, 9 }
{ =, ?, %, @, $ }
2. Wait for a score (e.g., '2Bull3Cow') to be returned and entered by the host, who is you. It's suggested the score is entered on the same line of the the count and guess displayed in the above step. So, it would look like
Guess #3 8@XYZ 1Bull2Cow
Guess #4 5@WYZ 1Bull1Cow
Guess #5 @8=%Z 4Bull0Cow
Repeat the above two steps until the guess wins a score of '5Bull0Cow' as shown below.
Guess #3 8@XYZ 1Bull2Cow
Guess #4 5@WYZ 1Bull1Cow
Guess #5 @8=%Z 4Bull0Cow
Guess #6 @8=6Z 5Bull0Cow -- You win!!
Except for the very first guess, your program should implement a strategy or formula to generate a new guess based on all scores collected. A good strategy or formula should use as much as possible the information or hints provided by the scores to quickly approach the secret word. This would be the most challenging component to be implemented in the entire program.
As a clue for everyone, one possible method is to generate a list of all possible secret words (using all scores returned) that could be the next guess, then to prune the list by keeping only those words that would give an equivalent score to how the last guess was scored. Then, the next guess can be any word from the pruned list. Either the guess correctly hits the secret word or run out of words to guess, which indicates a problem with the scoring or a problem with the list itself.