Compsci 06, Spring 2011, Hangman

See the howto pages for details on creating projects, files, 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 lego minifigures or top forty song titles --- the list is endless.

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. We'll also see how to translate the Python code students write into a version that will play on the web using other languages. This program will also be the basis for writing a "cheating hangman" that essentially almost never loses (by cheating, though you, the guesser, won't know that.)

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 game of 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 below 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 describd in the howto pages. It's important to adhere to these guidelines so that if we give you some graphics-oriented code to include with hangman pictures you can do that simply after writing your program.

Sample Run

Here's a sample run of Hangman. You do not need to follow the format exactly, but you should include with each turn the player takes the following information:

In the run below the user input is in italics, the other text is printed by the program.


# letters in word:  8
# guesses to hanging:  7
_ _ _ _ _ _ _ _
misses left:  7
guesses so far:  
guess letter:  e
no e
_ _ _ _ _ _ _ _
misses left:  6
guesses so far:  e 
guess letter:  a
no a
_ _ _ _ _ _ _ _
misses left:  5
guesses so far:  a e 
guess letter:  o
no o
_ _ _ _ _ _ _ _
misses left:  4
guesses so far:  a e o 
guess letter:  u
no u
_ _ _ _ _ _ _ _
misses left:  3
guesses so far:  a u e o 
guess letter:  i
_ _ _ i _ _ i _
misses left:  3
guesses so far:  a u e o 
guess letter:  s
no s
_ _ _ i _ _ i _
misses left:  2
guesses so far:  a e o s u 
guess letter:  t
no t
_ _ _ i _ _ i _
misses left:  1
guesses so far:  a e o s u t 
guess letter:  r
_ _ r i _ _ i _
misses left:  1
guesses so far:  a e o s u t 
guess letter:  n
no n
you are hung :-(, secret word is  cyrillic

Submit using the submit name hangman.

Grading

You'll get a grade 0-4 on whether the game works, 0-4 on reliability/robustness (behaves well when the user messes up), and 0-4 on code goodness. The first 0-4 will be doubled and the last can be redone in a later submission.

Extra Credit

Words are kind of old, offer the user the choice of playing hangman in more than one category, reading "words" from files you provide, e.g., instead of words use actors, books, and so on.