Algorithm for Hangman Game

Algorithm for Hangman

  1. Start
  2. Identify player 1.
  3. Identify player 2.
  4. Player 1 inputs word or phrase.
  5. Identify length of word or phrase.
  6. Player 2 starts out with 6 chances to guess a wrong letter.
  7. While chances > 0,
  8. Have all the letter been correctly guessed?
    1. Yes: Player 2 wins!
      1. End
    2. No: Player 2 guess a letter.
      1. Is the letter correct?
        1. Yes: Print letter and go back to step 8.
        2. No: Loses a chance.
          1. How many chances are left?
            1. 5: Print head.
              1. Go back to step 8.
            2. 4: Add torso to head.
              1. Go back to step 8.
            3. 3: Add left arm to torso.
              1. Go back to step 8.
            4. 2: Add right arm to torso.
              1. Go back to step 8.
            5. 1: Add left leg to torso.
              1. Go back to step 8.
            6. 0: Add right leg to torso.
              1. Player 2 loses.
                1. End