/* This program plays the game of 'animal', in which the player
   thinks of an animal, and the program tries to guess it.  If the
   program is unable to guess the player's animal,  it "learns" to
   distinquish the player's animal from its animal.
  ...
------------------------------------------------------------------*/

#include <iostream.h>
#include "DecisionTree.h"

int PlayMore(void);

int main(void)
{
   cout << "\nWelcome to the game of Animal!\n";

   DecisionTree
      Tree;

   Tree.Load("Animal.data");

   int
      Winner;                  // 0 = the player, 1 = the program

   do
   {
      cout << "\nThink of an animal, and I will try to guess it...\n";

      Winner = Tree.Descend();

      if (Winner)
         cout << "\nHa! Even a computer program can beat you...\n";
      else
         cout << "\nYou're just lucky...\n";
   }
   while (PlayMore());

   Tree.Write("Animal.data");

   return 0;
}

int PlayMore(void)
{
   char
      Answer;

   cout << "\nWant to play again (y or n)? ";
   cin >> Answer;

   return ((Answer == 'y') || (Answer == 'Y'));
}
