コード例 #1
0
 public Maze(int size,int startCellRow,int startCellColumn)
 {
     this.Size = size;
     this.maze = new char[this.size, this.size];
     this.startCell=new Cell(startCellRow,startCellColumn,0);
     this.maze[startCellRow,startCellColumn]='*';
     this.path = new List<Cell>();
 }
コード例 #2
0
 public void AddParent(Cell c)
 {
     this.parentCell = c;
 }
コード例 #3
0
 public Cell(Cell c)
     : this(c.row, c.column, c.distance)
 {
 }
コード例 #4
0
 private void VisitedCell(Queue<Cell> visitedCells, int row, int column, int distance,Cell parent)
 {
     if (this.maze[row, column] != 'x' && this.maze[row,column]!='v') //'v' marks visited cells
     {
         this.maze[row, column] = 'v';
         Cell cell = new Cell(row, column, distance);
         cell.AddParent(parent);
         visitedCells.Enqueue(cell);
     }
 }
コード例 #5
0
        private List<Cell> getPath(Cell c)
        {
            List<Cell> path=new List<Cell>();
            Cell currentCell = c;

            while (currentCell.parentCell != null)
            {
                path.Add(currentCell.parentCell);
                currentCell = currentCell.parentCell;
            }

            return path;
        }