Steve's Guess Animals Program.

By Steve Baker <>


This is a re-implementation of the classic 'Guess Animals' program. It's been written so many times and in so many languages, it's impossible to say who first thought it up. At any rate, I have no claim to fame in this matter.

You think of an animal - and the computer will ask you some questions and then try to guess what animal you are thinking about.

What's cool is that if it guesses wrong, it asks the user to provide a question that it can ask next time to get that particular mistake fixed.

After a suprisingly little while, the program becomes almost unbeatable. As a game, it's moderately good fun - but what's interesting is that it's self-correcting. Children are always impressed with it.


    make install

If you are running Windoze or something that can't run configure scripts and makefiles, don't sweat it. There is just one C++ source file - no special options or libraries.

No, I won't provide a binary version, project files and such.


This program is offered under the terms of the GNU Public License (GPL).


Just run:


It'll ask a bunch of questions - answer by typing 'y' or 'n' and then pressing Enter (Return). Eventually, it'll say something like

  Is it an Aardvark?

If it guessed right and you say 'y' then it'll keep score and ask you to think of another animal. If it guessed wrong though, you have to answer 'n' and then it'll say:

  OK, you fooled me. It wasn't an Aardvark.

  What was it?
  Type in the name of the animal then press Enter: 
Type in the name of the animal you were thinking of and hit return. Next, it'll ask:

  Well, perhaps you can suggest what I should ask next
  time I need to tell the difference between an Aardvark
  and a FruitBat.
  Please type in a question and then hit Enter,

So, you have to type in a question (one that can be answered with a simple Yes or No) that the computer can ask next time.

  Question: Can it fly

(Don't type in a questionmark)...Now, it'll ask:

  Oh - I see.  So, if you were thinking of a FruitBat and
  I said "Can it fly?",
  would you answer yes or no? this case the answer is 'n'. Once that is cleared up, the computer should now be able to guess a FruitBat the next time around.

Database Files

The database is written to 'animals.dat' in the current directory. If the file doesn't exist, the program will create it (and it'll contain just two animals, a Cow and a Goldfish).

In case you trash your database, there is a 75 animal database in '' - just copy it onto 'animals.dat' and you'll be back up and running.

The database is just an ASCII text file, and at a pinch you can hand-edit it to correct typos and other mistakes. However, whatever you do, don't change the order of the lines, add or remove any entries.