You should save your program for this assignment in cs21/homework/06. A skeleton version of the program will appear in this directory when you run update21 in a terminal window. The program handin21 will only submit files in this directory.
You may work with one partner on this assignment. If you work with a
partner, put your name and the name of your partner in the list of
authors at the top of your program. Only one partner needs to run
handin21 to submit the files for the group. Both partners
will receive the same grade.
For this assignment, you will write a program that implements the TV game show Lingo. The focus of this assignment is for you to practice using top-down design to construct your solution incrementally.
Lingo is a turn-based guessing game. The computer selects a random word and the player tries to guess the word. Each guess must also be a valid word of the same length (this is what makes the game interesting and hard). After a guess is made, the computer provides status information about how close (or how far) the player is to arriving at the solution. The status information includes which letters are correct, but in the wrong position, and which letters are correct, and in the right position.
To make things concrete, let's use an example where the computer is selecting a five-letter word. Normally, as a player of the game, you would not know what the computer had chosen. However, let's make things easier and peek at the computer's choice: guava.
It's time for you to begin guessing the word. Your initial guess is:
rates. Notice that there is only one letter that you guessed
that's also in the target word (the letter a). Rather than
indicate the number of letters you have correct, the status message
will specify which letters are exactly correct and which are in the
sequence, but in the wrong place. You'll do this by UPPER-CASING the
exact matches, leaving the 'inexact' matches alone, and replacing the
wrong letters with dashes. So, in this case, where the letter
a of your guess rates is an 'inexact' match, you'd
receive the status message:
Clearly you don't know the word yet, so you make another guess:
apply. Again, the only correct letter is the a, and
now it's in a different wrong place. So, the status you would receive
Your next guess is thank. While it's true that you know there
are no t's in the solution (from your guess of rates
earlier), you're trying to see if some of these other letters are
present (the h, n and k) and you're seeing
if you can figure out where the a goes. The status message
now that you have the a in the right position
Here is the complete run of this sample game:
Enter a 5 letter word: rates -a--- Enter a 5 letter word: apply a---- Enter a 5 letter word: thank --A-- Enter a 5 letter word: pious ---u- Enter a 5 letter word: curve -U-V- Enter a 5 letter word: suave -UAV- Enter a 5 letter word: guava You won in 7 turns!
if word in wordList: ...
Warning: When you get this working, be prepared to spend a while playing as it is remarkably addictive!
Once you are satisfied with your program, hand it in by typing handin21 in a terminal window.