Jotto has been given as an assignment irregularly in Duke courses since 1988, it was last given in Compsci 100 in 2006, was given in Compsci 6 in 2003 and again in 2011. A variation of the game called bagels was one of the original Nifty Assignments
JottoModel.java
so that a game can be
played with either a command-line interface or the GUI interface. This
means you implement required methods in the class, develop instance
variables/state in the class to allow the game to be played, and test
your code. Details are in the howto.
For extra/A credit you can make your program smarter than the standard, simple, eliminate words game-playing strategy outlined here and in the howto. There is no command-line version in this assignment, but there could be!
You can play Jotto online via several sites. The screen shots below are from a version whose website isn't active, but the game appears to be live here now. You can play with this link too. The screen shots show a version 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.
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?
When the computer guesses your word, the code you write will not
mimic what a human does. For extra credit you can use some
human-like reasoning, but as you'll see a simple method allows the
computer to guess most words very quickly.
The main idea is for the computer to guess a word that could be the secret word, choosing one such word at random. When the user responds with the number of letters in common with the user's secret word, the computer eliminates every word in its dictionary that doesn't have this many letters in common. For example, if the computer guesses fruit and the user responds that there are two letters in common with the user's secret word, the computer can remove ghost, ruins, tires and lots of other words from the dictionary since these words have, respectively, one, three, and three letters in common with fruit and thus cannot be the secret word. The computer would leave flips, track, and others in the dictionary since these have two letters in common with fruit and could possibly be the user's secret word. The computer continues to guess a word that could be the secret word until either the computer guesses correctly or there are no words left to guess. The latter could happen, for example, if the user's word is not in the computer's dictionary or if the user makes a mistake in responding about the number of letters in common (see below for examples). |
The computer generates a guess and I type in the number of letters in common with my secret word which is radii in the examples that follow. The computer has guessed my word in nine guesses and I type the number 6 to indicate this is my secret word (as shown on the right). This is an easy way to convey "you guessed right" to the computer which in general expects a number from the user in this version of the game.
Here are two more shots of the computer guessing my word radii. As these show, the computer doesn't use the same sequence of guesses every time, and sometime guesses the word very quickly!
Finally, two more shots of the computer trying to guess radii. On the left it seems like a sequence of very strange guesses leading to the secret word. On the right I made a mistake and entered 3 for the word drain which has four letters in common. The computer can't account for this mistake and indicates no more guesses after six guesses.
JottoModel.java
. You must also submit
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.java
class.
Submit using the submit name jotto.
This assignment is worth 20 points.
Criteria | Points |
---|---|
Computer will guess users's secret word (generally). | 6 |
Everything works well | 6 |
Documentation, style of code | 4 |
README | 4 |