Professional Documents
Culture Documents
http://home.iitk.ac.in/~pratikm/content/projects/ta201/msc/report.pdf
http://www.programering.com/a/MTOwgjMwATM.html
http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/03_Strings/Hangman/Proj
ect_04.pdf
how to play
The goal of this project was to write a graphically based game of hangman using Matlab.
The computer program opens a figure window, sets the axes properly and then
draws the "hangman" gallows.
The computer loads a dictionary of words that have been previously generated and saved as a
text file.
The computer then selects any of those words randomly and puts the correct number of
dashes in
the figure window.
The player can then start guessing letters. If the letter appears in the word then the computer
puts the letter in its proper location. If not then the computer adds one more body part to the
hangman. I used 6 body parts (e.g. head-neck, body, arms, legs, feet and hands).
If the entire body is completed then the player loses. If the player guesses the word before the
body is completed then the player wins.
After guessing a letter the letter should be removed from the available alphabet so that it is
not
guessed again.
The user should be alerted if they try to guess the same letter more than once.
Introduction
Hangman is a popular word guessing game where the player attempts to build a missing word
by guessing one letter at a time. After a certain number of incorrect guesses, the game ends and
the player loses. The game also ends if the player correctly identifies all the letters of the
missing word.
PROBLEM
letters guessed: The letters that they have guessed so far (list).
mistakes made: The number of incorrect guesses theyve made so far (int).
You can name these something else if youd like, but use a descriptive name. For now, set
secret word to be claptrap. Once weve finished our program and got it working, then well
change the secret word = claptrap to be get word(), a function that pulls a random
word from the file words.txt. This function is already defined for you. (This is called
incremental programming - instead of trying to get everything right the first time, well get
the basic program working then incrementally add small portions of code.) claptrap was
selected because its reasonably long and has duplicate letters hopefully that will allow us
MAX_GUESSES = 6
Constant just means that we wont change it. This isnt enforced by the compiler, so be
careful not to accidentally change the value of MAX GUESSES. My style is to put variables that
I dont plan to change in all capital letters other people do different things (some would
have written Max guesses, for example.) Any way works. We can decide what to do with this
at the end (for example, should we have an easy, medium, hard mode with different
Idea: At the end of the program, we should test our code with another word, one that has
more than 6 distinct letters, to make sure that the program doesnt accidentally increment