CPS 108, Spring 1997, Jotto
The word game Jotto is similar to mastermind, but played with
five-letter words instead of colored pegs. Two players each pick a
secret word that is not revealed. Players than take turns guessing five
letter words. For each guessed word the opponent tells how many letters
are in common with the secret word. For example, if player A picks
"flops" as the secret word, and player B guesses
"spore", then Player A responds that "spore" has 3 letters in
common with his secret word. The player who determines
the oponent's secret word with the fewest guesses wins.
Note that if the secret word is "tooth", the guess "pores" has one
letter in common: 'o', and the guess "spoof" has two letters in common
'o' and 'o'.
Files accessible for use in this program are available
in ~ola/cps108/java/jotto on acpub and below.
The CompPlayer class above has minimal intelligence, but
works.
You are to implement a class so that the computer plays Jotto. You must
subclass the abstract class Player whose interface is
provided in Player.java and reproduced below.
public abstract class Player
{
public abstract String getSecretWord(); // returns secret word
public abstract String getGuess(); // returns player's guess
public abstract void makeNewSecret(); // make new secret word
// process guess = word, with # letter in common = common
// and isSecret = true iff word is the opponent's secret word
public abstract void processGuess(String word, int common,
boolean isSecret);
public abstract void debug(); // help in debugging
public static final int SIZE = 5;
public static final String ALL_DONE = "hopeless";
}
See the class Jotto.java for an example of how a Computer
player plays against a human. You must submit a .java file that
for a class that extends Player so that the class can compete
against other classes. To instantiate your class you must supply
a class that implements JFactory. For example,
the class Ola below implements JFactory by returning
an instance of the class OlaPlayer (which presumably extends
player).
public interface JFactory
{
/**
* @param dictionary = sorted vector of words that comprises
* all valid words (the Jotto dictionary)
* @param name = player's name
*
* @returns a Player who can play Jotto (extends class Player)
*/
Player makePlayer(Vector dictionary, String name);
}
public class Ola implements JFactory
{
Player makePlayer(Vector dictionary, String name);
{
return new OlaPlayer(dictionary, name);
}
}
The class Jotto will load the file ~ola/data/knuth.dat
which is a file of over 5,700 five letter words.
When all classes are submitted, there will be a tournament
in which all classes try to guess a sequence of words. The
player/classes requiring the fewest guesses wins. The top three classes
will receive bonus points of +10, +6, +4, respectively. The program
itself is worth 20 points.
Submit using
submit108 jotto README ...
Owen L. Astrachan
Last modified: Sat Apr 26 12:47:00 EDT 1997