Run update21, if you haven't already, to create the cs21/labs/07 directory. Then cd into your cs21/labs/07 directory and create the python program for lab 7 in this directory.
Remember that your programs are graded on both correctness and style. In particular, each function needs a comment!
You are going to implement a single-player version of the Wheel of Fortune TV game show. Wheel of Fortune is a phrase guessing game, where the player builds up potential winnings by spinning the wheel and correctly guessing consonants in the hidden phrase. If, after seeing some of the letters in the phrase, they can guess what the phrase is, they win the money.
For our version, the computer will read in phrases from a file and randomly choose one for the game. The player then has four options:
The wheel has a variety of cash options, such as $200, $400, etc, as well as a BANKRUPT option. If the user "spins" the wheel and it lands on one of the cash options, the player then guesses a consonant they think is in the phrase. If, for example, the wheel lands on $400, the player guesses a "t", and the phrase has two t's, the player gets 2*$400 added to their potential winnings. Money can only be added to the potential winnings by spinning the wheel and guessing a consonant that's in the phrase. Only one consonant can be guessed per spin.
The BANKRUPT option causes the player to lose the game and any potential winnings!
Since we are only writing a single-player game, ignore the "Lose-A-Turn" option shown on the following wheel.
The player is not allowed to guess vowels *unless* they "buy a vowel" for $250. To do this, the player must have at least $250 in their potential winnings. Whether the bought vowel is in the phrase (one or more times) or not, $250 is always subtracted from their potential winnings.
As correct letters are guessed and vowels are bought, those letters are displayed in the puzzle (originally all -'s, see the examples below). Once the player thinks they know what the phrase is, they can end the game by taking a guess at the phrase. If their guess is correct, they win the money. If not, they lose all potential winnings.
If the users wants to give up early, they can choose to quit which
will then abort the game, display the phrase, and tell them they don't
win *anything*.
The focus of this assignment is for you to practice using top-down design to construct your solution incrementally. This assignment spans two weeks. In the first week, you are required to design your solution and implement minimalistic function stubs for your design. In the second week, you will finish implementing and testing the full game.
Note: Once you have your top-level design
done you need to run handin21 and send me an email that you
have completed your top-level design. I will look at your design
and email you with feedback on your design within 24-48 hours. The
earlier you handin your design, the earlier you can continue working
on your full program. You should wait to hear back from me before
continuing on your program because if I suggest you do something
differently, you may have to redo some of your code.
For the design of a program in the first week, you should have:
Here are two examples of how your wheel-of-fortune program should work.
['-', '-', ' ', '-', '-', '-', '-', ' ', '-', '-']And, after the user has guessed 's', 'w', and bought an 'e', it would be
['W', 'E', ' ', '-', '-', '-', 'E', ' ', '-', 'S']
def main(): playgame() def playgame(): """will do lots of work here to play the game""" return
if 'a' in mystring: ...Use not in to test if a character is not in a string.
>>> word = "apple" >>> charList = list(word) >>> print charList ['a', 'p', 'p', 'l', 'e'] >>> rejoined = ''.join(charList) >>> print rejoined 'apple'
>>> word = "apple" >>> charList = list(word) >>> 'a' in charList True >>> 'z' in charList False
Extensions are not a required part of lab 7, but you may want to try adding some once you have the game fully implemented and tested.
Here are some fun extensions that you might want to add to your program:
$100 $500 $250 $1000 <>======================(here's a nice ASCII text generator)
* what happens when there are only vowels left? * what happens when there are no letters left to guess?
Once you are satisfied with your programs, hand them in by typing handin21 at the unix prompt.
You may run handin21 as many times as you like, and only the most recent submission will be recorded. This is useful if you realize, after handing in some programs, that you'd like to make a few more changes to them.