Hangman Basics Recall the hangman game from . The goal of the game is to test a person's active vocabulary. If, however, the player's guess reveals new knowledge about the chosen word, the first player indicates where the the letter occurs in the word. The game is over when the second player guesses the complete word or when the first player has completed the stick figure.
Figure contains the data definitions for letters, words, and body-parts.
The figure also defines an incomplete list of words so that the hangman program can randomly pick a word for us to guess. The random picking of words occurs at the beginning of the game, which suggests a random initialization function, similar to that of the color-guessing program in the preceding section. In contrast to the latter, the hangman program must also remember the number of guesses that a player made, because there is only a limited number of them. After ' left-leg is drawn, the game is over. Counting down the number of body parts also implies that as the program checks each guess, it must inform the player not only what the guess revealed but also which body part, if any, was lost.