/* animal.cpp 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
 *  (with the player's assistance).
 *  ...
 */

#include <iostream>
#include "DecisionTree.h"
using namespace std;

bool playMore();

int main()
{
   cout << "\nWelcome to the game of Animal!\n";
   
   DecisionTree dTree("animal.data"); // load tree-data from file

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

      int winner = dTree.descend();   // 0 == the person, 1 == the program

      if (winner)
         cout << "\nHa! Even a computer program can beat you...\n";
      else
         cout << "\nYou were just lucky...\n";
   }
   while (playMore());



   return 0;
}  // tree-data is auto-saved to file by DecisionTree destructor


bool playMore()
{
   char answer;
   cout << "\nDo you want to play again (y or n)? ";
   cin >> answer;
   return ((answer == 'y') || (answer == 'Y'));
}
