Hangman is a computer-based version of the classic two-player word game. The human player competes against the computer or the other player to guess a word the opponent has selected. A game of hangman works as follows:
- The program selects a word from a pool of words and displays a number of underscores equal to the word length.
- The user/player begins guessing letters. If the player guesses a letter that is in the word, then all instances of that letter are displayed at their corresponding positions in the word. Otherwise, the guess is incorrect. Every incorrect guess results in a body part being drawn on the gallows. At the first incorrect guess a head is drawn, then the torso, then one arm, then the other arm, then one leg and lastly the other leg.
- The game ends when either all the letters in the word have been guessed or when the player has used 6 incorrect guesses (all body parts have been drawn).