public static bool checkForObviousMove(char[,] board) { int rows = board.GetLength(0); int cols = board.GetLength(1); int x; int y; int obviousCount; int blankCount; for (int i = 0; i < rows; i++) { x = -1; y = -1; obviousCount = 0; blankCount = 0; for (int j = 0; j < cols; j++) { if (board[i, j] == 'o') { obviousCount++; } if (board[i, j] == ' ') { x = i; y = j; blankCount++; } } if (obviousCount == cols - 1 && blankCount == 1) { writeOnBoard(board, 'o', x, y); return true; } } for (int j = 0; j < cols; j++) { x = -1; y = -1; obviousCount = 0; blankCount = 0; for (int i = 0; i < rows; i++) { if (board[i, j] == 'o') { obviousCount++; } if (board[i, j] == ' ') { x = i; y = j; blankCount++; } } if (obviousCount == rows - 1 && blankCount == 1) { writeOnBoard(board, 'o', x, y); return true; } } x = -1; y = -1; obviousCount = 0; blankCount = 0; for (int i = 0, j = 0; i < rows && j < cols; i++, j++) { if (board[i, j] == 'o') { obviousCount++; } if (board[i, j] == ' ') { x = i; y = j; blankCount++; } } if (obviousCount == rows - 1 && blankCount == 1) { writeOnBoard(board, 'o', x, y); return true; } x = -1; y = -1; obviousCount = 0; blankCount = 0; for (int i = rows - 1, j = 0; i >= 0 && j < cols; i--, j++) { if (board[i, j] == 'o') { obviousCount++; } if (board[i, j] == ' ') { x = i; y = j; blankCount++; } } if (obviousCount == rows - 1 && blankCount == 1) { writeOnBoard(board, 'o', x, y); return true; } return false; }