/* aittt - Tic-Tac-Toe Versus AI

Copyright (c) 2017 David Meyer <[email protected]>  +JMJ

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <iostream>
#include <sstream>
#include <string>

using namespace std;

// DATA TYPES

enum epostat_t {EMPTY, X, O};

// FUNCTIONS PROTOTYPES

void print_board ();
char cpos (int ipos, bool highlight);
string spos (int ipos, bool highlight);
char symbol (epostat_t state, bool highlight);

// GLOBAL VARIABLES

const int MAXP = 0;
epostat_t epos[] = {EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY};

// M A I N

int main()
{
   epos[0] = O;
   epos[4] = X;
   print_board();
   return 0;
}

// SUBROUTINES

void print_board ()
{
   cout << spos (0, true) << '|' << spos (1, false) << '|' << spos (2, false) << endl
        << "---+---+---" << endl
        << spos (3, false) << '|' << spos (4, false) << '|' << spos (5, false) << endl
        << "---+---+---" << endl
        << spos (6, false) << '|' << spos (7, false) << '|' << spos (8, false) << endl;
}

// FUNCTIONS

char cpos (int ipos, bool highlight)
{
   switch (epos[ipos]) {
   case X:
       return (highlight ? 'X' : 'x');
       break;
   case O:
       return (highlight ? 'O' : 'o');
       break;
   default:
       return '1' + ipos;
   }
}

string spos (int ipos, bool highlight)
{
   stringstream spos;
   switch (epos[ipos]) {
   case X:
       spos << '.' << (highlight ? 'X' : 'x') << '.';
       break;
   case O:
       spos << '.' << (highlight ? 'O' : 'o') << '.';
       break;
   default:
       spos << ' ' << ipos+1 << ' ';
   }
   return spos.str ();
}

char symbol (epostat_t state, bool highlight)
{
   switch (state) {
   case X:
       return (highlight ? 'X' : 'x');
       break;
   case O:
       return (highlight ? 'O' : 'o');
       break;
   default:
       return ' ';
   }
}