CIT 597 Assignment 5: The Animals! Game
Fall 2006, David Matuszek

Purposes of this assignment:

General idea of the assignment:

Animals! is an old computer game, originally text only. The user thinks of an animal, and the computer asks a series of yes-no questions, ending with guessing the animal. If the computer guesses wrong, the computer asks the user about that animal, so that it can guess better next time.

Your assignment is to design the XML representation of the data, use the DOM parser to read it in, play the game, modify the DOM tree to include any new animals the user provides, and write the modified (larger) DOM tree out again when the user quits the game.


The program starts with a very simple decision tree, such as this one. After asking the user to think of an animal, play may go something like this:

Computer: Does it live in the water?
User: no.
Computer: I know! Is it a horse?
User: no.

At this point the computer has "lost." It then asks the user for information that it can use to enlarge its decision tree, like this:

Computer: What animal were you thinking of?
User: A zebra.
Computer: What question should I ask to distinguish a horse from a zebra?
User: Does it have stripes?
Computer: What is the correct answer for a zebra?
User: Yes.

The computer can now replace its wrong answer ("horse") with a new node containing a question, with its wrong answer as one child and the new animal as the other child.

I will provide you with a version of this game that uses a GUI and keeps its data in a binary tree. It can do all of the above, but when the program quits, it forgets everything that it has "learned." You can use this program as a basis (discarding the binary tree part), or you can write your own program from scratch.

Your assignment:

First, design the XML you will want to hold the "Animals" data. It can be fairly simple--you don't need to use more than the very basic features of XML.

Write a DTD that describes your XML file.

Write a program that:

Provided starter code:

These files are fully commented, but I did not include the Javadoc files. You can easily generate them if you wish.

Due date:

Thursday, October 19, before midnight. Zip your entire project, including DTD and XML files, and submit via Blackboard.