//=============================================================================

#include "board.h"
#include "computer.h"
#include "human.h"
#include "move.h"
#include <iostream>
using std::cout;

//-----------------------------------------------------------------------------

int main()
{
   cout << "Aufg_15_05_Tic_Tac_Toe_2\n\n";

   board b;
   human pl1(color::white);
   computer pl2(color::black);

   b.print();

   for (;;)
   {
      move m = pl1.next(b);

      cout << '\n' << pl1.name() << " macht Zug: ";
      m.print();
      cout << "\n\n";

      b.set(m);
      b.print();

      if (b.wins(pl1.get_color()))
      {
         cout << '\n' << pl1.name() << " hat gewonnen\n";
         return 0;
      }
      if (b.full())
      {
         cout << "\nDas Spiel ist remis ausgegangen\n";
         return 0;
      }

      m = pl2.next(b);
      cout << '\n' << pl2.name() << " macht Zug: ";
      m.print();
      cout << "\n\n";

      b.set(m);
      b.print();

      if (b.wins(pl2.get_color()))
      {
         cout << '\n' << pl2.name() << " hat gewonnen\n";
         return 0;
      }
   }
}
