Saint Louis University |
Computer Science 150
|
Dept. of Math & Computer Science |
The goal of this assignment is to write a program which simulates the classic game, Hangman.
See Exercise 4-49 on page. 222 for more detailed requirements. In addition to those requirements, please try to do the following:
The one drawback to our game right now is that someone needs to type
in the secret word, but presumably that shouldn't be the same person
who is guessing. In the long run, we will learn how to open up a
file of words and randomly select one, but for now, I'm willing to
give the snipet of code that is required for this behavior. (the
filename used here is presuming you are working on turing - it could
be adjusted accordingly).
from random import *
def pickSecret(filename='/home/faculty/goldwasser/public/movies.txt'):
choices = file(filename)
secret = ''
linenum = 0
for word in choices:
linenum += 1
if randrange(0,linenum)==0:
secret = word.strip()
return secret
You may safely assume that the underscore character (_) does not appear in any of the secrets.
Note: If you would like to use this file on some machine other than turing, feel free to download it (movies.txt) and save it on your own machine.
For this assignment, you are allowed to work with one other student if you wish (in fact, we suggest that you do so). If any student wishes to have a partner but has not been able to locate one, please let the instructor know so that we can match up partners.
Please make sure you adhere to the policies on academic integrity in this regard.
You should create a new file, hangman.py, which contains all of the code. This file must be submitted electronically.
You should also submit a separate 'readme' text file, as outlined in the general webpage on programming assignments. For this assignment, please explain any interesting design decisions that you made about the user interface or about your implementation techniques. If you worked as a pair, please make this clear and briefly describe the contributions of each person in the effort.
Please see details regarding the submission process from the general programming web page, as well as a discussion of the late policy.
The assignment is worth 10 points.
Use graphics creatively to animate a game in progress.