animal - % animal knowledge Do you want to play? Yes Does...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
For this assignment, you will write a program “animal” that uses a binary tree to play an interactive, learning, guessing game with the user. As usual, you will design two tree representations – one memory-based, and one file-based. You will begin with a file called “knowledge”, created manually, with a single animal (say, “Horse”) in using your file-based representation of a single node tree. The game will ultimately grow the tree so that all internal nodes are yes/no questions, and all leaf nodes are animals. For example, after playing for some time, the tree may look like: Does your animal have a backbone? Does your animal have hair or fur? Does your animal have a shell? Does your animal eat meat? Goldfish Horse Tiger Snail Octopus At this point, playing the game again, the interaction may proceed as follows:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % animal knowledge Do you want to play? Yes Does your animal have a backbone? Yes Does your animal have hair or fur? No Is it a Goldfish? No I give up. What is your animal? Pigeon Type a question that distinguishes Goldfish from Pigeon: Does it have feathers? What is the answer for Goldfish? No Do you want to play? Yes Does your animal have a backbone? Yes Does your animal have hair or fur? No Does it have feathers? Yes Is it a Pigeon? No I give up. What is your animal? Toucan Type a question that distinguishes Pigeon from Toucan: Is it colorful? What is the answer for Pigeon? No Do you want to play? No % At this point, the le knowledge is updated so that upon playing again, the game knows about Pigeons and Toucans in addition to the previous animals it had learned....
View Full Document

This note was uploaded on 02/23/2010 for the course CIS 121 taught by Professor Tannen during the Spring '09 term at UPenn.

Ask a homework question - tutors are online