Compsci 06, Spring 2011, Jotto Assignment
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.
Jotto is a word game played with five-letter words similar to the
colored-peg game
Mastermind. The
Jotto Wikipedia page has
information about Jotto and variations on the game including changing
the number of letters and providing different information than the
number of letters-in-common. An example of a score/play sheet from the
original game is shown on the left and a complete page can be found on
the Wikipedia site. For this assignment you'll be writing a computer
program to guess a human player's word. The computer program will
be really hard to beat even when it's using a straightforward,
brute force approach to guessing. For extra credit you can write code
that makes the game more "
intelligent" by eliminating letters
that cannot be part of a word rather than simply eliminating words
as described below. An example of this increased intelligence is
described below with a link to an online version of the game.
Jotto has been given as an assignment irregularly in Duke courses since
1988, but has not been given in Compsci 6 since 2003 until the fall of 2011. A variation of the
game called bagels was one of the original Nifty Assignments
What You Do
You write the module jottoModel.py
so that a game can be
played with either a command-line interface or the GUI
interface. This means you implement required functions in the
module, develop global state in the module to allow the game to be
played, and test your code. Details are in the
howto.
We will post an A/extra credit part of the assignment that's a variation
on the number of letters-in-common.
Playing the Game
The explanation below illustrates how to play the game. The
logical-thinking illustrated in the example is not something
you will program except for extra credit. You'll program a much
simpler form of computer "intelligence" described after the
explanation of how the game is played.
You can play Jotto online via several sites. The
site linked
here allows you, a human player, to guess the words, but the
computer helps by eliminating letters that cannot be part of a
word. For example, the series of screen shots below shows what's
displayed as I tried to guess the computer's secret word. The last
screen shot on the right is just before I "win" the game by guessing
the secret word (can you guess it as well?). In this online version,
duplicate letters in word are not allowed. Letters that have been
eliminated from being possible are shown in red, letters that must
be in the word are shown in green.
First Screen Shot
For example, in the first screenshot on the upper-left I guessed the word
stick which had zero letters in common with the
computer's secret word. This results in each letter in
stick being eliminated, so they are shown in red after I
guessed stick. In the second screen on the upper-right guessed two
more words: lamps and ramps. Since
ramps has three letters in common while lamps
has only two, the computer can determine that 'R' must be in the
word and that 'L' cannot be in the word.
Second Screen Shot
The computer has not reasoned completely as a human might at this
point. For example, the word irate has two letters in common,
one is 'R', so the other is either (but not both) of 'A' and
'E'. Similarly one of 'A' or 'Y' must be in the secret word based
on my guess stray, but not both. If 'A' is not in
the word, thann both 'E' and 'Y' must be. However, since
money has only one-letter in common with the secret word
both 'E' and 'Y' cannot be in the word. Thus 'A' must be and 'E'
and 'Y' cannot be. However, the computer hasn't reasoned this
completely --- that kind of logic is harder to program.
Third Screen Shot
The next screen shot (lower-left) shows what happens after I guessed woman
and
stone. After guessing stone the computer knows that
exactly one of 'O', 'N', and 'E' is in the secret word since the
letters 'S' and 'T' have been eliminated. Using the guessed word
money the computer can immediately determine that neither
'M' nor 'Y' is in the secret word since one of 'O','N','E' is in the
word. When 'M' is eliminated from ramps and lamps
we know that 'A' and 'P' are in the secret word as well as
'R'. Because irate has two letters in common, we
eliminate 'E'.
Fourth Screen Shot
After fight has no letters in common the computer was able to
determine that 'O' must be in the word since ghost had one
letter in common. This eliminates 'W' (from woman) and 'N'
(from money). Eliminating 'N' can also be done based on
woman.
After guessing
bound the computer helps by eliminating 'U', 'B', and 'D' since
we know 'O' is in the secret word. only 'J', 'Q', 'V', 'X', and
'Z' are left. Because I know that there are no duplicate letters I
was able to guess the secret word at this point. Can you?
Duke Jotto
Here's a capture of me playing the game, the computer is trying to guess
my word which is bagel: The user's input is in
italics.
Playing a game with 5 letter words
Number of words is 5757
My guess is 'vocab', how many letters in common with your word: 2
Number of words left is 1243
My guess is 'cased', how many letters in common with your word: 2
Number of words left is 495
My guess is 'choke', how many letters in common with your word: 1
Number of words left is 198
My guess is 'braze', how many letters in common with your word: 3
Number of words left is 35
My guess is 'bagel', how many letters in common with your word: 6
I win!! it took me 5 guesses
Here's a screen capture of the GUI version just before the computer
guessed my word which is bagels. When you use
the GUI-version make sure you choose new game from the Jotto menu
to start the play.
Submit and Grading
Submit your source code jottoModel.py
and a README.txt
file: information you should include in the
README file is specified in the general assignment page.
You should also include in your README file
any bugs or problems you notice in your program.
Your grade will be based on how well your program runs, on how robust it
is, and on how well-designed the code is in your
jottoModel.py
module.
Submit using the submit name jotto.