Hi Guys,

Trying to create a tictactoe game, and am working on a function for getting one of the two users playing to see what the outcome of the game is. So far I have got it as follows:

Code:
TicTacToe:: Status TicTacToe:: gameStatus gameStatus(void)
{  
  // Check for win in diagonals //
  if (board [0][0]!= '_' && board [0][0] == board [1][1] 
  && board [0][0] == board [2][2])
  return WIN;
  else if (board [0][2]!= '_' && board [0][2] == board [1][1] 
  && board [0][2] == board [2][0])
  return WIN;
  //** End Check for win in diagonals ** //

  // Check for win in rows  //
  if (board [0][0]!= '_' && board [0][0] == board [1][0] 
  && board [0][0] == board [2][0])
  return WIN;
    else if (board [0][1]!= '_' && board [0][1] == board [1][1] 
  && board [0][1] == board [2][2])
  return WIN; 
    else if (board [0][2]!= '_' && board [0][2] == board [1][2] 
  && board [0][2] == board [2][2])
  return WIN; 
  //** End Check for win in rows  **//  
  
  // Check for win in columns  //
  if (board [0][0]!= '_' && board [0][0] == board [0][1] 
  && board [0][0] == board [0][2])
  return WIN;
    else if (board [1][0]!= '_' && board [1][0] == board [1][1] 
  && board [1][0] == board [1][2])
  return WIN;
   else if (board [2][0]!= '_' && board [2][0] == board [2][1] 
  && board [2][0] == board [2][2])
  return WIN; 
  // ** End Check for win in columns ** //
  
  // Check for a completed game //
   return CONTINUE;     // game is not finished
  // ** End Check for completed game ** //

  
 // Check for a draw // 
return DRAW; // game is a draw
  // ** End Check for draw ** //

}
Now as you can see I have tried to do is say get the winners for diagonals, columns and rows.

What I need to do now is check for a drawn game, which I think I need to state something like, if move >9 (it’s a 3x3 board) then Return Draw. And also check for a completed game? But I’m stuck on how to do these two!

Can someone please advise if I am going right so far and also how I’d go about checking for a completed game and a draw?

Many Thanks

Rebel