Compsci 101, Spring 2016, Hangman

Due: Thursday, March 10 by 11:59pm + 121 minutes

10 points

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 decribed 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 Hangman.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. After each 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 been guessed in alphabetical order as a string such as "aemost".

  5. You should print a message at the end telling them if they won or lost, and what the word was.

Part 2 - Hangman with Movie Titles

  1. You must write the code in HangmanMovies.py . Suggest you copy your code from Hangman.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. 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 been guessed in alphabetical order as a string such as "aemost".

  6. You should print a message at the end telling them if they won or lost and what the movie title was.

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