Project 5: A Game about Animals
Due Date:
Midnight Sunday, May 14, 2000.
Note that this means before 23:59:59 on Sunday evening. The standard
late policy applies. Note that you have nearly
three weeks to complete this project.
Objectives
The objectives of this project are:
- To gain more experience designing classes in C++
- To gain more experience using classes in C++
- To gain experience using trees in programming
The Problem
You must write a program to play a simple game of questions with the computer.
The rules of this game are simple:
- The player thinks of an animal.
- Until the computer has either (a) given up or (b) guessed the right animal or (c) guessed the wrong animal
- the computer asks a yes or no question
- the player answers yes or no based on the animal chosen above
- If the computer gave up or guessed the wrong animal, the computer asks for the answer and a yes/no question that can help it identify this animal in the future.
Computers are not reknowned for their intelligence, so the computer starts out with no idea what animal you're talking about. However, as it plays the game and guesses wrong, it "learns" new information each time and organizes it into a collection of facts and relationships that it has learned. This collection of facts and relationships is sometimes called a "knowledge base". Designing the
computer's knowledge base for this game is the core of this project.
The best way to try to understand this game is watch it being played.
A Sample of the Game
[umbc8] ~> proj5
Ok. Think of an animal. Ready? ('y' to continue): y
I give up. What is it? dog
What question would tell me that it's a dog? Does it have a tail?
Would you like to play again? ('y' or 'n'): y
Ok. Think of an animal. Ready? ('y' to continue): y
Does it have a tail? ('y' or 'n') y
Is it a dog? ('y' or 'n'): n
I give up. What is it? fish
What question would tell me that it's a fish? Does it swim under water?
Would you like to play again? ('y' or 'n'): y
Ok. Think of an animal. Ready? ('y' to continue): y
Does it have a tail? ('y' or 'n') y
Does it swim under water? ('y' or 'n') n
Is it a dog? ('y' or 'n'): n
I give up. What is it? cat
What question would tell me that it's a cat? Does it meow?
Would you like to play again? ('y' or 'n'): y
Ok. Think of an animal. Ready? ('y' to continue): y
Does it have a tail? ('y' or 'n') y
Does it swim under water? ('y' or 'n') n
Does it meow? ('y' or 'n') y
Is it a cat? ('y' or 'n'): y
I win!
Would you like to play again? ('y' or 'n'): n
Note that the computer starts out by giving up. This is because the computer
doesn't "know" anything when the program starts; it's knowledge base is
empty. The program gets one guess at an animal, so your program should
narrow down its choices as much as possible before it guesses. Remember,
if the computer guesses the wrong animal, it loses the game, but
it learns from its loss.
A sample program is now available. You may download
it from here or run/copy it from:
/afs/umbc.edu/users/j/k/jkukla1/pub/cs202/proj5
... on the irix.gl systems. Remember, this is an SGI executable file, so it
won't run on your home PC. You must run it on umbc8/umbc9.
Requirements
Your program must:
- Play the game outlined above.
- Use correct articles ("a" vs. "an") when talking about animals
(note that the user should only enter the animal's name
(see sample))
- Animal names starting with vowels (a,e,i,o,u)
should be preceeded by the article "an".
- All other animal names should be preceeded
by the article "a".
- Prompt the user at the end of each game to find out if they'd
like to play again.
- Use a binary tree to store the knowledge that the program
has acquired.
- Ask as many questions as it can before guessing to increase its
odds of winning.
Coding Standards
For this project you must follow the class
coding standards. Remember, you must
document your code as well as your headers. Comments should be on their own
lines and should not share lines with actual code.
Using Code You Didn't Write
Claiming authorship of code that you didn't write is plagiarism and will
be dealt with as academic dishonesty. You should not use code that you
didn't write; it defeats the learning experience of the project. If you do
use outside code on your project, you must site the source. If a
significant portion of the project comes from an outside source, your grade
may be reduced.
Testing Your Program
Remember, your program must compile and run using the CC
compiler on the IRIX machines (umbc8/9). If your program does not compile
or does not generate the correct output, you will not receive full credit
for this project.
You should be able to adapt your makefile from a previous project to work
for this one. You should make sure that you have a makefile named either
makefile
or Makefile
and that when you type
make
your program compiles to an executable called
proj5
. Failure to follow these simple directions will
result in a reduced grade.
Grading
Now that you are designing your own classes, design will be one of the criteria
for your project grade. The grade for this project will be broken down as
follows:
50% Correctness
This tests that your program behaves the same way that
the sample does.
30% Design and Style
You should follow the coding standards and make sure your
coding style is consistent. In addition, your knowledge base
class should handle only knowledge base operations.
Prompting the user should happen OUTSIDE of the knowledge
base.
20% Documentation
Commenting inline as well as header files.
What to Turn In
You should submit your Makefile
and any
files needed to build your program.
Submitting Your Project
When you have finished and tested your project you can submit it electronically
using submit
. The project name for this assignment is
proj5
. As an example, to submit your Makefile
, you
would type:
submit cs202 proj5 Makefile
More complete documentation for submit
and related commands
can be found here.
Last modified: 24 April 2000