V.Vidhya Logo

V.Vidhya

Hangman Game


Build a text-based Hangman game where the player first selects a word category (e.g., Animals, Countries, Fruits etc.). The program then picks a random word from a pre-defined set of words for that category and the player guesses it one letter at a time. After each wrong guess, display an ASCII-art stick figure that progresses toward a full figure (i.e. hangman). The game ends when the player either uncovers the entire word or the stick figure is fully uncovered i.e. “hung”.

Instructions
  • Let the player choose from a few word categories.
  • The program secretly picks one word at random from the chosen category.
  • Display the word as underscores (one for each letter).
  • Each turn the player guesses a single letter; correct letters are revealed in place.
  • Track wrong guesses and, after each miss, add one part to the ASCII-art hangman.
  • Always show: the current word state, letters guessed so far, and the evolving hangman drawing.
  • The player wins by uncovering the entire word before the hangman is complete; loses if the figure is finished first.
  • ASCII Art Example:
Initial Stage:
  +---+
  |   |
      |
      |
      |
      |
=========

Final Stage:
  +---+
  |   |
  O   |
 /|\  |
 / \  |
      |
=========
  • The parts of this stick figure (i.e. head, body, left-right arm, left-right leg) can be broken into stages and revealed one piece per wrong guess.


Feel free to implement additional features to enhance the gameplay such as,


Prev Post
TicTacToe Game
Next Post
Fake Medicine