Compsci 100, Fall 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.

play card
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, 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

What You Do

You write the class 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!

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. These screen shots are from a web-based game. The Jotto game you write has screen shots that are shown after the Jotto explanation below.

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.

jotto1 jotto1
jotto1 jotto1

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

For the code you write there is a standard mode in which the computer guesses your word and a smart/AI mode for extra credit in which the computer uses strategy/logic you write to do more than the eliminate-strategy outlined below and in the howto. Ideally there would be a network version so you could play Jotto with friends online .


Computer Guesses Your Word

Here's a screen shot of me choosing to let the computer guess my secret word by choosing the New Game menu and then choosing Play New Game.

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.

   


Submit and Grading

Submit all the code you write, likely this is in the class 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