コード例 #1
0
        public void FindSteps()
        {
            Queue<Cell> queue = new Queue<Cell>();
            queue.Enqueue(startingCell);
            while (queue.Count > 0)
            {
                Cell currentCell = queue.Dequeue();

                for (int i = 0; i < directions.GetLength(0); i++)
                {
                    int nextRow = currentCell.Row + directions[i, 0];
                    int nextCol = currentCell.Col + directions[i, 1];

                    if (StepPossible(nextRow, nextCol))
                    {
                        Cell nextStep = new Cell(nextRow, nextCol, currentCell.Value + 1);

                        field[nextStep.Row, nextStep.Col] = nextStep.Value.ToString();
                        queue.Enqueue(nextStep);
                    }
                }
            }

            MarkUnpassable();
        }
コード例 #2
0
 public Labyrinth(string[,] inputField)
 {
     this.field = inputField;
     this.height = field.GetLength(0);
     this.width = field.GetLength(1);
     startingCell = FindStartingCell();
 }