Пример #1
0
 public matrixElement[,] Create_matrix(int row, int column, List <int[]> blocks, int[] start_element, int[] end_element)//بكريت الماتريكس بناء على الانبوت اللى داخلها
 {
     matrixElement[,] matrix = new matrixElement[row, column];
     for (int i = 0; i < row; i++)
     {
         for (int j = 0; j < column; j++)
         {
             matrix[i, j] = new matrixElement();
         }
     }
     for (int k = 0; k < blocks.Count; k++)
     {
         for (int i = 0; i < row; i++)
         {
             for (int j = 0; j < column; j++)
             {
                 if (i == blocks[k][0] && j == blocks[k][1])
                 {
                     matrix[i, j].element_status = false;
                 }
             }
         }
     }
     matrix[start_element[0], start_element[1]].element_type = 1;
     matrix[end_element[0], end_element[1]].element_type     = 2;
     return(matrix);
 }
Пример #2
0
        public List <int[, ]> prog(string path)
        {
            List <int[]> blocks = new List <int[]>();
            int          row = -1, col = -1;
            Task         t = readfile(path);

            Task.WaitAll(t);
            foreach (String line in lines)
            {
                row++;
                col = -1;
                foreach (char c in line)
                {
                    col++;
                    if (c == '*')
                    {
                        blocks.Add(new[] { row, col });
                    }
                    else if (c == 'c')
                    {
                        start = new[] { row, col }
                    }
                    ;
                    else if (c == 'e')
                    {
                        end = new[] { row, col }
                    }
                    ;
                }
            }
            matrixElement[,] matrix = new matrixElement[3, 3];
            operations op = new operations();

            matrix = op.Create_matrix((row + 1), (col + 1), blocks, start, end);
            op.finding_path(matrix, start, start, new[] { (row + 1), (col + 1) });
            return(op.smallest_list());
        }
    }