Piezas.cpp
Piece Piezas::gameState()
{
  //temporarily keep track of X and O totals
  int xTot = 0;
  int oTot = 0;

  //tmp track count of X/O horizontally
  int xHor = 0;
  int oHor = 0;

  //tmp track count of X/O vertically
  int xVer = 0;
  int oVer = 0;

  //if board is empty, game not over
  if(board.empty())
    return Invalid;


  //check the columns first for counts
  for(int i = 0; i < BOARD_ROWS; i++)
  {
    for(int j = 0; j < BOARD_COLS; j++)
    {
      //check if any spaces have blanks or invalids, if so game can't be over
      if( (board[i][j] == Blank)  )
        return Invalid;

      if(board[i][j] == X)
        xVer++;
      else if(board[i][j] == O)
        oVer++;

    }

    if(xTot < xVer)
      xTot = xVer;
    if(oTot < oVer)
      oTot = oVer;
  }

  for(int i = 0; i < BOARD_COLS; i++)
  {
    for(int j = 0; j < BOARD_ROWS; j++)
    {
      //No need to check for blank space here, already checked in above loop

      if(board[j][i] == X)
        xHor++;
      else if(board[j][i] == O)
        oHor++;

    }

    if(xTot < xHor)
      xTot = xHor;
    if(oTot < oHor)
      oTot = oVer;
  }

  if(xTot > oTot)
    return X;
  else if(oTot > xTot)
    return O;
  else
    return Blank;

}
/**
 * Returns which Piece has won, if there is a winner, Invalid if the game
 * is not over, or Blank if the board is filled and no one has won ("tie").
 * For a game to be over, all locations on the board must be filled with X's 
 * and O's (i.e. no remaining Blank spaces). The winner is which player has
 * the most adjacent pieces in a single line. Lines can go either vertically
 * or horizontally. If both X's and O's have the same max number of pieces in a
 * line, it is a tie.
**/
Returns which Piece has won, if there is a winner, Invalid if the game
is not over, or Blank if the board is filled and no one has won ("tie").
For a game to be over, all locations on the board must be filled with X's
and O's . The winner is which player has
the most adjacent pieces in a single line. Lines can go either vertically
or horizontally. If both X's and O's have the same max number of pieces in a
line, it is a tie.
Returns which Piece has won if there is a winner Invalid if the game is not over or Blank if the board is filled and no one has won ( " tie " ) . For a game to be over all locations on the board must be filled with X ' s and O ' s . The winner is which player has the most adjacent pieces in a single line . Lines can go either vertically or horizontally . If both X ' s and O ' s have the same max number of pieces in a line it is a tie .
Piece Piezas::gameState()
{
  int xTot = 0;
  int oTot = 0;
  int xHor = 0;
  int oHor = 0;
  int xVer = 0;
  int oVer = 0;
  if(board.empty())
    return Invalid;
  for(int i = 0; i < BOARD_ROWS; i++)
  {
    for(int j = 0; j < BOARD_COLS; j++)
    {
      if( (board[i][j] == Blank)  )
        return Invalid;
      if(board[i][j] == X)
        xVer++;
      else if(board[i][j] == O)
        oVer++;
    }
    if(xTot < xVer)
      xTot = xVer;
    if(oTot < oVer)
      oTot = oVer;
  }
  for(int i = 0; i < BOARD_COLS; i++)
  {
    for(int j = 0; j < BOARD_ROWS; j++)
    {
      if(board[j][i] == X)
        xHor++;
      else if(board[j][i] == O)
        oHor++;
    }
    if(xTot < xHor)
      xTot = xHor;
    if(oTot < oHor)
      oTot = oVer;
  }
  if(xTot > oTot)
    return X;
  else if(oTot > xTot)
    return O;
  else
    return Blank;
}
Piece Piezas :: gameState ( ) { int xTot = 0 ; int oTot = 0 ; int xHor = 0 ; int oHor = 0 ; int xVer = 0 ; int oVer = 0 ; if ( board . empty ( ) ) return Invalid ; for ( int i = 0 ; i < BOARD_ROWS ; i ++ ) { for ( int j = 0 ; j < BOARD_COLS ; j ++ ) { if ( ( board [ i ] [ j ] == Blank ) ) return Invalid ; if ( board [ i ] [ j ] == X ) xVer ++ ; else if ( board [ i ] [ j ] == O ) oVer ++ ; } if ( xTot < xVer ) xTot = xVer ; if ( oTot < oVer ) oTot = oVer ; } for ( int i = 0 ; i < BOARD_COLS ; i ++ ) { for ( int j = 0 ; j < BOARD_ROWS ; j ++ ) { if ( board [ j ] [ i ] == X ) xHor ++ ; else if ( board [ j ] [ i ] == O ) oHor ++ ; } if ( xTot < xHor ) xTot = xHor ; if ( oTot < oHor ) oTot = oVer ; } if ( xTot > oTot ) return X ; else if ( oTot > xTot ) return O ; else return Blank ; }
Returns which Piece has won, if there is a winner, Invalid if the game
 is not over, or Blank if the board is filled and no one has won ("tie").
Returns which Piece has won if there is a winner Invalid if the game is not over or Blank if the board is filled and no one has won ( " tie " ) .
//temporarily keep track of X and O totals //tmp track count of X/O horizontally //tmp track count of X/O vertically //if board is empty, game not over //check the columns first for counts //check if any spaces have blanks or invalids, if so game can't be over //No need to check for blank space here, already checked in above loop