tictactoe_solver.cpp
// Calculates the game score of the given board
// 
// A positive score indicates that 'X' is winning, and a negative score
// indicates that 'O' is winning. If the score is 0 the current game state is a
// tie. 
// 
// Points are awarded for having control of a given dirrection without being
// blocked by the other player. Points are also awarded for winning the game.
//
// @param board the board to calculate the game score of
// 
// @return the score of the game

Calculates the game score of the given board
A positive score indicates that 'X' is winning, and a negative score
indicates that 'O' is winning. If the score is 0 the current game state is a
tie.

Points are awarded for having control of a given dirrection without being
blocked by the other player. Points are also awarded for winning the game.
Calculates the game score of the given board A positive score indicates that ' X ' is winning and a negative score indicates that ' O ' is winning . If the score is 0 the current game state is a tie . Points are awarded for having control of a given dirrection without being blocked by the other player . Points are also awarded for winning the game .
int tictactoeai::CalcGameScore(const tictactoe::TicTacToe &board)
{
  int x = 0;
  int o = 0;
  for (unsigned int i = 0; i < board.get_width(); ++i)
  {
    for (unsigned int j = 0; j < board.get_height(); ++j)
    {
      char piece = board.get_board_data()[i][j];
      if (piece != ' ')
      {
        if (!IsRowBlocked(board, i, j))
        {
          if (piece == 'X')
            x += 1;
          else
            o += 1;
        }
        if (!IsColumnBlocked(board, i, j))
        {
          if (piece == 'X')
            x += 1;
          else
            o += 1;
        }
        if (!IsRightDiagnolBlocked(board, i, j))
        {
          if (piece == 'X')
            x += 1;
          else
            o += 1;
        }
        if (!IsLeftDiagnolBlocked(board, i, j))
        {
          if (piece == 'X')
            x += 1;
          else
            o += 1;
        }
      }
    }
  }
  std::pair<bool, char> win_data = board.CheckForWin();
  if (win_data.second == 'X')
    x+=100;
  else if (win_data.second == 'O')
    o+=100;
  return x-o;
}
int tictactoeai :: CalcGameScore ( const tictactoe :: TicTacToe & board ) { int x = 0 ; int o = 0 ; for ( unsigned int i = 0 ; i < board . get_width ( ) ; ++ i ) { for ( unsigned int j = 0 ; j < board . get_height ( ) ; ++ j ) { char piece = board . get_board_data ( ) [ i ] [ j ] ; if ( piece != ' ' ) { if ( ! IsRowBlocked ( board , i , j ) ) { if ( piece == ' ' ) x += 1 ; else o += 1 ; } if ( ! IsColumnBlocked ( board , i , j ) ) { if ( piece == ' ' ) x += 1 ; else o += 1 ; } if ( ! IsRightDiagnolBlocked ( board , i , j ) ) { if ( piece == ' ' ) x += 1 ; else o += 1 ; } if ( ! IsLeftDiagnolBlocked ( board , i , j ) ) { if ( piece == ' ' ) x += 1 ; else o += 1 ; } } } } std :: pair < bool , char > win_data = board . CheckForWin ( ) ; if ( win_data . second == ' ' ) x += 100 ; else if ( win_data . second == ' ' ) o += 100 ; return x - o ; }
Calculates the game score of the given board
A positive score indicates that 'X' is winning, and a negative score
indicates that 'O' is winning.
Calculates the game score of the given board A positive score indicates that ' X ' is winning and a negative score indicates that ' O ' is winning .
// Scores for each player
 // Check if the four dirrections are blocked in any case
 // Award 100 points if there is a winner
