Compsci 101, Fall 2017, Hangman

Due: Thursday, Oct 26 by 11:59pm

10 points

NOTE: You will start Hangman in Lab 6. Be sure to read the assignment and howto and look at the starter code before going to lab.

See the howto pages for details on starting this project, code, and so on. The pages here describe in broad strokes what this assignment is about.

Hangman is a traditional children's game, typically played with words. It's possible, however, to play Category Hangman --- rather than guessing words the player might guess names of cities, or athletes, or fictional characters, names of US Presidents or top forty song titles --- the list is endless. To play online try hangman.no for some fun.

You'll be writing a program to play a "guess a word letter-by-letter" version of hangman as shown below and described in detail in the howto pages.

According to this article the hardest words to guess in hangman are jazz, buzz, and jazzed if you lose with 8 misses though with 11 misses allowed jazzed is apparently harder to guess than buzz.

Overview

Write a program to play a console-based, word-oriented (one word) game of hangman. Then you will write a second hangman program that guesses movie titles (multiple words).

For the standard word-oriented hangman the user should be allowed to specify the number of letters in the word and the number of misses until the game is lost (see the sample runs for details). The program should be reasonably robust in the face of faulty input from the user, though don't go overboard in writing code to protect against bad input.

Details and guidelines of how to organize the program, including the methods you should write, are described in the howto pages. It's important to adhere to these guidelines.

Sample Runs

Here are sample runs of Hangman. You do not need to follow the format exactly, but you should be sure to include required information.

Click here for sample runs with words

Click here for sample runs with movie titles

Your Task

Snarf the starter files for assignment5. You can also see the files here:

Requirements

There are several parts/requirements to this programming assignment:

Part 1 - Hangman with guessing a word

  1. You must write the code in PlayHangman.py .

  2. The user should have the choice of deciding the length of the word and the number of misses allowed.

  3. The secret word generated should be of length 3 or greater.

  4. The user can guess a letter or can guess the word. To guess the word the user should enter "+" and then they should be asked to guess the word. They don't get any more chances when they guess the word.

  5. After each letter guess, you should show
    1. the correct blanks and guesses for the secret word
    2. the number of incorrect letter misses left
    3. letters that have NOT been guessed in alphabetical order. For example, if they have only guessed 'a' and 'e', then show the string "bcdfghijklmnopqrstuvwxyz".
    4. If the user guesses a letter again by mistake, you should
      • tell the user they have already guessed the letter
      • count that as a miss

  6. You should print a message at the end of the game telling them one of three things:

Part 2 - Hangman with Movie Titles

  1. You must write the code in PlayHangmanMovies.py . Suggest you copy your code from PlayHangman.py to get started.

  2. Read in the movie titles from the file movies.txt and print the number of movie titles read in.
  3. The user should have the choice of deciding the number of words in the title and the number of misses allowed.

  4. The secret title generated can be one or more words.

  5. The user can guess a letter or can guess the title. To guess the title the user should enter "+" and then they should be asked to guess the title. They don't get any more chances when they guess the title.

  6. After each guess, you should show
    1. the correct blanks and guesses for the secret title. Be sure to show blanks between words so you can tell how many letters are in each word.
    2. the number of incorrect letter misses left
    3. the number of words in the title that have missing letters
    4. letters that have NOT been guessed in alphabetical order. For example, if they have only guessed 'a' and 'e', then show the string "bcdfghijklmnopqrstuvwxyz".

  7. For movies you should allow a user when guessing the title to type lowercase letters and match a title that has uppercase letters.
  8. You should print a message at the end of the game telling them one of three things:

Both Parts

  1. Your program must consist of functions and function calls. There should be no global variables in your program.

  2. Your program must be reasonably robust in the face of user errors, but don't worry too much about that.

  3. You must have a comment for each function.

    If you write any additional functions, such as a helper function, then these functions must have comments describing the purpose of the function.

What to Submit