The Animal Game


Here is the program I have been re-coding as my own standard problem since the 1960s.[3] It is called "The Animal Game."

[3] I must admit to being proud of having delivered production-quality software within five different decades, starting with the sixties. In the early days, I wrote much of it myself; later on, my colleagues did everything they could to prevent me from writing code. During that span of time, I have had to deal with many different languages.

The program is an interactive dialog between a user and the program. The user is prompted to "Think of an animal." The program then begins by asking, "Is your animal a beagle?"[4] If the user was thinking of a beagle, he answers, "Yes"; the program congratulates itself on its perspicacity, thanks the user for playing, and the game is over.

[4] Homage to Snoopy and his creator, Charles Schulz.

If, on the other hand, the user is not thinking of a beagle, he answers, "No." Downcast, the program responds, "Sorry, I did not guess your animal. Tell me your animal and give me a question that has the answer 'Yes' for your animal, and 'No' for a beagle."

For example, if the person is thinking of a trout, he would enter "trout," followed by the question, "Is it a fish?" The answer is yes for a trout, and no for a beagle.

Having stumped the program and entered his animal and his question, the user is thanked, and the program again terminates.

However, the next time the user plays, something different happens. After being prompted to "Think of an animal," the first question asked is, "Is it a fish?" If the user answers "Yes," then the program asks, "Is it a trout?" But if the user answers "No" to "Is it a fish?" then the program asks, "Is it a beagle?" If the user was thinking either of a beagle or a trout, then the program wins by guessing right. On the other hand, if the person was thinking of some other animal, then once again the program admits defeat and asks for the new animal and a question that will distinguish the new animal from either a beagle or a trout, as appropriate.

So, in the beginning, the program is exceedingly "dumb." But by storing up the new animals and the new questions, it gets "smarter" as it plays. It won't always guess your animal by the shortest possible route, but after a while it can fake intelligence and "guess" your animal almost every time. That's because as its database gets bigger, it appears to "track down your animal" more and more surely.[5]

[5] There is a flaw here. A user can insert a bad question or otherwise get things bollixed uplike reversing the roles of "yes" and "no." Don't laugh; I have seen it done. I have even seen a player forget the animal he was supposed to be thinking of in mid-game. Once this happens, the database is contaminated for future use. Historically, I have had more success with third-graders than with adults; apparently, the simplicity of the game is perfect for eight-year-olds and daunting for their parents.




The Software Development Edge(c) Essays on Managing Successful Projects
The Software Development Edge(c) Essays on Managing Successful Projects
ISBN: N/A
EAN: N/A
Year: 2006
Pages: 269

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net