Due: Friday, Feb 25th by 11:59 PM
Acknowledgment: the idea for this assignment comes from Jenny Walter at Vassar College.
Download CS350_Assign3.zip. Import it into your Eclipse workspace (File->Import...->General->Existing projects into workspace->Archive File). You will see a project called CS350_Assign3 in the Package Explorer.
You will modify the main method of the ExpertSystem class. You may add any additional classes or interfaces that you need.
In this assignment you will use a binary tree to implement an expert system. An expert system represents knowledge about some problem domain using a decision tree. Based on the decision tree, the expert system can ask a series of yes or no questions to solve a classification problem. If the expert system fails (reaches a point where the questions it asks do not correctly classify the input that the user is describing), it prompts the user for the correct answer, a new question that will be able to correctly classify the input in the future. In this assignment, the classification problem is "What kind of animal are you?".
Here is an example of the user interacting with the expert system (user input shown in bold):
Welcome to the Animal Guessing Game! I will ask you a sequence of questions with yes or no answers and then I will make a guess. Ready? Here goes!! Are you a mammal? [y or n]: y Are you terrestrial? [y or n]: y My guess is kangaroo. Am I right? [y or n]: n I give up. What are you? horse Please type a question that will distinguish a horse from a kangaroo: Are you a marsupial? Are you a marsupial, horse? [y or n]: n Shall we play again? [y or n]: y Are you a mammal? [y or n]: y Are you terrestrial? [y or n]: y Are you a marsupial? [y or n]: n My guess is horse. Am I right? [y or n]: y Shall we play again? [y or n]: n Thank you for teaching me a thing or two.
In this example, if the initial tree looks like this:
Are you a mammal? /\ y n / \ Are you shark terrestrial? /\ y n / \ kangaroo whale
The final tree looks like this:
Are you a mammal? /\ y n / \ Are you shark terrestrial? /\ y n / \ Are you a whale marsupial? /\ y n / \ kangaroo horse
First, implement the expert system so that it starts out with the following initial decision tree:
Are you a mammal? /\ y n / \ kangaroo shark
By playing the guessing game with the user, the expert system should add additional nodes in order to be able to classify additional animals.
The next task, once you have your expert system working correctly, is that when the user chooses not to play again, the current decision tree should be saved in a file. When the program is restarted, the program should try to re-load the decision tree from that file (falling back to the original fixed initial decision tree if the file cannot be found).
Your decision tree will be a binary tree. The leaf nodes are answers, and the interior nodes are questions.
You can use a recursive method to save the decision tree to a file. Suggestion: store each node of the decision tree as a single line of text. The format might look something like this:
Question:Are you a mammal? Answer:kangaroo Answer:shark
Questions are followed by the "yes" subtree and then the "no" subtree.
Once you can successfully save a decision tree to a file, you should be able to read it back using a very similar method. You can use BufferedReader to read each line of input, and then determine whether each line starts with "Question:" or "Answer:" in order to determine what kind of node should be created. The rest of the line is the text of either a question or an answer.
The file that you use to load and save the decision tree should be called "decisiontree.dat".
Your assignment will be graded as follows:
Export your finished project to a zip file (right-click on the project, then Export...->Archive File). Upload the zip file to the marmoset server as project assign3. The server URL is
IMPORTANT: after uploading, you should download a copy of your submission and double-check it to make sure that it contains the correct files. You are responsible for making sure your submission is correct. You may receive a grade of 0 for an incorrectly submitted assignment.