Due: Friday November 13 at 11:59pm
For this assignment you will be writing a program to cheat at the game Hangman. After completing your program, you will submit it via the department's Git server.
The game hangman is a word guessing game. A word is selected and a hint is constructed from the word by replacing all non-guessed letters with underscores. At each turn the player guesses a letter. If that letter is present in the word, the letters that match it in the word are revealed. If not, then the number of incorrect guesses increases.
A player may only guess a single letter at a time, and can not repeat a guess.
The game is over under two conditions. First, when the number of incorrect guesses is at least 5, the player loses. Second, when the player has guessed all of the letters in the word, in which case the player wins.
While you will be writing a program to play Hangman, we want to make it cheat as much as possible, while still presenting only correct information. Instead of selecting a word to start, we will have a list of words. Whenever the player guesses a word, the list of remaining words is partitioned based upon the information that would be revealed about the word. Then the partition with the maximum size is selected as our new word list. By doing this we ensure that at each step there is a maximal amount of possible words that the player needs to guess from.
You are strongly encouraged to leverage the C++ Standard Library as much as possible. Part of the point of this assignment is to learn some of the containers provided by the library which in turn make writing a program in C++ faster.
Three containers that will prove very useful for this assignment are std::map, std::string, and std::vector.
In particular the std::map provides a key,value interface to the data which allows us to partition a word list. In this program, you likely want a std::map
Normally a program like this would read in a text file consisting of the words to play the game with. Since we haven't discussed file I/O in C++ yet, a header file has been prepared that contains a list of 440 words in an array to use as the source words.
Ensure that you have proper tests for all of the code that you write. In particular the starting code suggests functions named filterWords and maskSingleWord. Each of these are independently testable and should be tested.
Start with this code and this header. You should only need to modify the marked areas in the starting code. If any other problems pop up, please email Will.
Your work must be submitted via the department's Git server. To do so, perform the following steps: