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
- You must write the code in
PlayHangman.py
.
-
The user should have the choice of deciding the length of the word and
the number of misses allowed.
- The secret word generated should be of length 3 or greater.
- 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.
- After each letter guess, you should show
- the correct blanks and guesses for the secret word
- the number of incorrect letter misses left
- letters that have NOT been guessed in alphabetical order. For example,
if they have
only guessed 'a' and 'e', then show the string
"bcdfghijklmnopqrstuvwxyz".
- 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
- You should print a message at the end of the game telling them one of
three things:
- They guessed the correct word.
- They guessed the wrong word, and tell them what the correct word
was.
- They ran out of guesses, and tell them what the correct word
was.
Part 2 - Hangman with Movie Titles
- You must write the code in
PlayHangmanMovies.py
. Suggest
you copy your code from PlayHangman.py to get started.
- Read in the movie titles from the file movies.txt and print the number
of movie titles read in.
-
The user should have the choice of deciding the number of words in the
title and
the number of misses allowed.
- The secret title generated can be one or more words.
- 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.
- After each guess, you should show
- 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.
- the number of incorrect letter misses left
- the number of words in the title that have missing letters
- letters that have NOT been guessed in alphabetical order. For example,
if they have
only guessed 'a' and 'e', then show the string
"bcdfghijklmnopqrstuvwxyz".
- For movies you should allow a user when guessing the
title to type lowercase letters and match a title that has uppercase
letters.
- You should print a message at the end of the game telling them one of
three things:
- They guessed the correct movie.
- They guessed the wrong movie, and tell them what the correct movie
was.
- They ran out of guesses, and tell them what the correct movie
was.
Both Parts
- Your program must consist of functions and function calls. There should be
no global variables in your program.
-
Your program must be reasonably robust in the face of user errors, but don't worry
too much about that.
- 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
-
Please submit the following items to the folder assign5-hangman using
eclipse/ambient or websubmit.
PlayHangman.py
PlayHangmanMovies.py
- Fill out the REFLECT form on the assignment page.